Class HarLog


  • public class HarLog
    extends java.lang.Object
    Root object of exported data.
    See Also:
    specification
    • Field Detail

      • DEFAULT_VERSION

        protected static final java.lang.String DEFAULT_VERSION
        See Also:
        Constant Field Values
    • Constructor Detail

      • HarLog

        public HarLog()
    • Method Detail

      • getVersion

        public java.lang.String getVersion()
        Returns:
        Version number of the format. Defaults to DEFAULT_VERSION
      • setVersion

        public void setVersion​(java.lang.String version)
      • getCreator

        public HarCreatorBrowser getCreator()
        Returns:
        Information about the application used to generate HAR.
      • getBrowser

        public HarCreatorBrowser getBrowser()
        Returns:
        Information about the browser used.
      • getPages

        public java.util.List<HarPage> getPages()
        Returns:
        List of all exported pages, may be empty.
      • setPages

        public void setPages​(java.util.List<HarPage> pages)
      • getEntries

        public java.util.List<HarEntry> getEntries()
        Returns:
        List of all exported requests, may be empty.
      • setEntries

        public void setEntries​(java.util.List<HarEntry> entries)
      • getComment

        public java.lang.String getComment()
        Returns:
        Comment provided by the user or application, null if not present.
      • setComment

        public void setComment​(java.lang.String comment)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • findMostRecentEntry

        public java.util.Optional<HarEntry> findMostRecentEntry​(java.util.regex.Pattern url)
        Search the entire log for the most recent entry whose request URL matches the given url.
        Parameters:
        url - Regular expression match of URL to find. URLs are formatted as: scheme://host:port/path?querystring. Port is not included in the URL if it is the standard port for the scheme. Fragments (example.com/#fragment) should not be included in the URL. If more than one URL found, return the most recently requested URL. Pattern examples: - Match a URL with "http" or "https" protocol, "example.com" domain, and "/index.html" exact file path, with no query parameters: "^(http|https)://example\\.com/index\\.html$" - Match a URL with "http" protocol, "example.com" domain, "/customer" exact path, followed by any query string: "^http://example\\.com/customer\\?.*" - Match a URL with "http" protocol, "example.com" domain, "/products" path, and exactly 1 UUID query parameter named "id": "^http://example\\.com/products\\?id=[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}$"
        Returns:
        HarEntry for the most recently requested URL matching the given url pattern.
      • findEntries

        public java.util.List<HarEntry> findEntries​(java.util.regex.Pattern url)
        Search the entire log for entries whose request URL matches the given url.
        Parameters:
        url - Regular expression match of URL to find. URLs are formatted as: scheme://host:port/path?querystring. Port is not included in the URL if it is the standard port for the scheme. Fragments (example.com/#fragment) should not be included in the URL. If more than one URL found, use the most recently requested URL. Pattern examples: - Match a URL with "http" or "https" protocol, "example.com" domain, and "/index.html" exact file path, with no query parameters: "^(http|https)://example\\.com/index\\.html$" - Match a URL with "http" protocol, "example.com" domain, "/customer" exact path, followed by any query string: "^http://example\\.com/customer\\?.*" - Match a URL with "http" protocol, "example.com" domain, "/products" path, and exactly 1 UUID query parameter named "id": "^http://example\\.com/products\\?id=[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}$"
        Returns:
        A list of HarEntry for any requests whose URL matches the given url pattern, or an empty list if none match.