Interface BrowserUpProxy

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void abort()
      Like stop(), shuts down the proxy server and no longer accepts incoming connections, but does not wait for any existing network traffic to cease.
      void addFirstHttpFilterFactory​(org.littleshoot.proxy.HttpFiltersSource filterFactory)
      Adds a new filter factory (request/response interceptor) to the beginning of the HttpFilters chain.
      void addHeader​(java.lang.String name, java.lang.String value)
      Adds a new HTTP header to every request.
      void addHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
      Adds the specified HTTP headers to every request.
      void addLastHttpFilterFactory​(org.littleshoot.proxy.HttpFiltersSource filterFactory)
      Adds a new filter factory (request/response interceptor) to the end of the HttpFilters chain.
      void addRequestFilter​(RequestFilter filter)
      Adds a new RequestFilter that can be used to examine and manipulate the request before sending it to the server.
      void addResponseFilter​(ResponseFilter filter)
      Adds a new ResponseFilter that can be used to examine and manipulate the response before sending it to the client.
      void addWhitelistPattern​(java.lang.String urlPattern)
      Adds a URL-matching regular expression to an existing whitelist.
      AssertionResult assertAnyUrlContentContains​(java.util.regex.Pattern url, java.lang.String text)
      Assert that responses content for all requests found by a given URL pattern contain specified value.
      AssertionResult assertAnyUrlContentDoesNotContain​(java.util.regex.Pattern url, java.lang.String text)
      Assert that responses content for all requests found by a given URL pattern don't contain specified value.
      AssertionResult assertAnyUrlContentLengthLessThanOrEquals​(java.util.regex.Pattern url, java.lang.Long max)
      Assert that content length of all responses found by url pattern do not exceed max value.
      AssertionResult assertAnyUrlContentMatches​(java.util.regex.Pattern url, java.util.regex.Pattern contentPattern)
      Assert that responses content for all requests found by url pattern matches content pattern.
      AssertionResult assertAnyUrlResponseHeaderContains​(java.util.regex.Pattern url, java.lang.String value)
      Assert that headers of all responses found by url pattern contain specified value.
      AssertionResult assertAnyUrlResponseHeaderContains​(java.util.regex.Pattern url, java.lang.String name, java.lang.String value)
      Assert that if responses found by url pattern have headers with specified name - among them must be one header with value containing specified text.
      AssertionResult assertAnyUrlResponseHeaderDoesNotContain​(java.util.regex.Pattern url, java.lang.String value)
      Assert that headers of all responses found by url pattern don't contain specified value.
      AssertionResult assertAnyUrlResponseHeaderDoesNotContain​(java.util.regex.Pattern url, java.lang.String name, java.lang.String value)
      Assert that if responses found by url pattern have headers with specified name - their values must not contain specified value.
      default AssertionResult assertAnyUrlResponseHeaderMatches​(java.util.regex.Pattern url, java.util.regex.Pattern valuePattern)
      Assert that all headers of all responses found by url pattern have values matching value pattern.
      AssertionResult assertAnyUrlResponseHeaderMatches​(java.util.regex.Pattern url, java.util.regex.Pattern namePattern, java.util.regex.Pattern valuePattern)
      Assert that if responses found by url pattern have headers with name found by name pattern - their values should match value pattern.
      AssertionResult assertMostRecentResponseContentContains​(java.util.regex.Pattern url, java.lang.String text)
      Assert that response content for the most recent request found by a given URL pattern contains specified value.
      AssertionResult assertMostRecentResponseContentDoesNotContain​(java.util.regex.Pattern url, java.lang.String text)
      Assert that response content for the most recent request found by a given URL pattern doesn't contain specified value.
      AssertionResult assertMostRecentResponseContentLengthLessThanOrEqual​(java.util.regex.Pattern url, java.lang.Long max)
      Assert that content length of the most recent response found by url pattern does not exceed max value.
      AssertionResult assertMostRecentResponseContentMatches​(java.util.regex.Pattern url, java.util.regex.Pattern contentPattern)
      Assert that response content for the most recent request found by a given URL pattern matches content pattern.
      default AssertionResult assertMostRecentResponseHeaderContains​(java.util.regex.Pattern url, java.lang.String value)
      Assert that headers of the most recent response found by url pattern contain specified value.
      AssertionResult assertMostRecentResponseHeaderContains​(java.util.regex.Pattern url, java.lang.String name, java.lang.String value)
      Assert that if the most recent response found by url pattern has header with specified name - it's value must contain specified text.
      default AssertionResult assertMostRecentResponseHeaderDoesNotContain​(java.util.regex.Pattern url, java.lang.String value)
      Assert that headers of the most recent response found by url pattern do not contain specified value.
      AssertionResult assertMostRecentResponseHeaderDoesNotContain​(java.util.regex.Pattern url, java.lang.String name, java.lang.String value)
      Assert that if the most recent response found by url pattern has header with specified name - it's value must not contain specified text.
      default AssertionResult assertMostRecentResponseHeaderMatches​(java.util.regex.Pattern url, java.util.regex.Pattern value)
      Assert that all headers of the most recent response found by url pattern have values matching value pattern.
      AssertionResult assertMostRecentResponseHeaderMatches​(java.util.regex.Pattern url, java.util.regex.Pattern name, java.util.regex.Pattern value)
      Assert that if the most recent response found by url pattern has header with name found by name pattern - it's value should match value pattern.
      AssertionResult assertMostRecentResponseStatusCode​(HttpStatusClass clazz)
      Assert that the most recent response has status belonging to specified class.
      AssertionResult assertMostRecentResponseStatusCode​(java.lang.Integer status)
      Assert that the most recent response has specified status.
      AssertionResult assertMostRecentResponseStatusCode​(java.util.regex.Pattern url, HttpStatusClass clazz)
      Assert that the most recent response found by url pattern has status belonging to specified class.
      AssertionResult assertMostRecentResponseStatusCode​(java.util.regex.Pattern url, java.lang.Integer status)
      Assert that the most recent response found by url pattern has specified status.
      AssertionResult assertMostRecentResponseTimeLessThanOrEqual​(java.util.regex.Pattern url, long milliseconds)
      Assert that the response time for the most recent request found by a given URL pattern is less than or equal to a given number of milliseconds.
      AssertionResult assertResponseStatusCode​(HttpStatusClass clazz)
      Assert that all responses of current step have statuses belonging to the same class.
      AssertionResult assertResponseStatusCode​(java.lang.Integer status)
      Assert that all responses of current step have specified status.
      AssertionResult assertResponseStatusCode​(java.util.regex.Pattern url, HttpStatusClass clazz)
      Assert that all responses found by url pattern have statuses belonging to the same class.
      AssertionResult assertResponseStatusCode​(java.util.regex.Pattern url, java.lang.Integer status)
      Assert that all responses found by url pattern have specified http status.
      AssertionResult assertResponseTimeLessThanOrEqual​(java.util.regex.Pattern url, long milliseconds)
      Assert that the response times for all requests found by a given URL pattern are less than or equal to a given number of milliseconds.
      void autoAuthorization​(java.lang.String domain, java.lang.String username, java.lang.String password, AuthType authType)
      Enables automatic authorization for the specified domain and auth type.
      void blacklistRequests​(java.lang.String urlPattern, int statusCode)
      Adds a URL-matching regular expression to the blacklist.
      void blacklistRequests​(java.lang.String urlPattern, int statusCode, java.lang.String httpMethodPattern)
      Adds a URL-matching regular expression to the blacklist.
      void chainedProxyAuthorization​(java.lang.String username, java.lang.String password, AuthType authType)
      Enables chained proxy authorization using the Proxy-Authorization header described in RFC 7235, section 4.4 (https://tools.ietf.org/html/rfc7235#section-4.4).
      void clearBlacklist()
      Clears any existing blacklist.
      void clearRewriteRules()
      Clears all existing rewrite rules.
      void disableHarCaptureTypes​(CaptureType... captureTypes)
      Disables the specified HAR capture types.
      void disableHarCaptureTypes​(java.util.Set<CaptureType> captureTypes)
      Disables the specified HAR capture types.
      void disableWhitelist()
      Clears any existing whitelist and disables whitelisting.
      void enableEmptyWhitelist​(int statusCode)
      Enables the whitelist, but with no matching URLs.
      void enableHarCaptureTypes​(CaptureType... captureTypes)
      Enables the specified HAR capture types.
      void enableHarCaptureTypes​(java.util.Set<CaptureType> captureTypes)
      Enables the specified HAR capture types.
      Har endHar()
      Stops capturing traffic in the HAR.
      java.util.Collection<HarEntry> findEntries​(java.util.regex.Pattern url)
      Search the entire log for entries whose request URL matches the given url.
      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.
      java.util.Map<java.lang.String,​java.lang.String> getAllHeaders()
      Returns all headers previously added with addHeader(String name, String value).
      java.util.Collection<BlacklistEntry> getBlacklist()
      Returns all blacklist entries currently in effect.
      java.net.InetSocketAddress getChainedProxy()
      Returns the address and port of the upstream proxy.
      java.net.InetAddress getClientBindAddress()
      Returns the address of the network interface on which the proxy is listening for client connections.
      default Har getHar()
      Retrieves the current HAR.
      Har getHar​(boolean cleanHar)
      If cleanHar is false - returns current HAR.
      java.util.EnumSet<CaptureType> getHarCaptureTypes()  
      AdvancedHostResolver getHostNameResolver()
      Returns the current host name resolver.
      int getPort()
      Returns the actual port on which the proxy is listening for client connections.
      long getReadBandwidthLimit()
      Returns the current bandwidth limit for reading, in bytes per second.
      java.util.Map<java.lang.String,​java.lang.String> getRewriteRules()
      Returns all rewrite rules currently in effect.
      java.net.InetAddress getServerBindAddress()
      Returns the address address of the network interface the proxy will use to initiate upstream connections.
      int getWhitelistStatusCode()
      Returns the status code returned for all URLs that do not match the whitelist.
      java.util.Collection<java.lang.String> getWhitelistUrls()
      Returns the URL-matching regular expressions currently in effect.
      long getWriteBandwidthLimit()
      Returns the current bandwidth limit for writing, in bytes per second.
      boolean isStarted()
      Returns true if the proxy is started and listening for connections, otherwise false.
      boolean isWhitelistEnabled()
      Returns true if the whitelist is enabled, otherwise false.
      Har newHar()
      Starts a new HAR file with the default page name (see newPage().
      Har newHar​(java.lang.String initialPageRef)
      Starts a new HAR file with the specified initialPageRef as the page name and page title.
      Har newHar​(java.lang.String initialPageRef, java.lang.String initialPageTitle)
      Starts a new HAR file with the specified page name and page title.
      Har newPage()
      Starts a new HAR page using the default page naming convention.
      Har newPage​(java.lang.String pageRef)
      Starts a new HAR page using the specified pageRef as the page name and the page title.
      Har newPage​(java.lang.String pageRef, java.lang.String pageTitle)
      Starts a new HAR page using the specified pageRef as the page name and the pageTitle as the page title.
      void removeAllHeaders()
      Removes all headers previously added with addHeader(String name, String value).
      void removeHeader​(java.lang.String name)
      Removes a header previously added with addHeader(String name, String value).
      void removeRewriteRule​(java.lang.String urlPattern)
      Removes an existing rewrite rule whose urlPattern matches the specified pattern.
      void rewriteUrl​(java.lang.String urlPattern, java.lang.String replacementExpression)
      Adds a rewrite rule for the specified URL-matching regular expression.
      void rewriteUrls​(java.util.Map<java.lang.String,​java.lang.String> rewriteRules)
      Replaces existing rewrite rules with the specified patterns and replacement expressions.
      void setBlacklist​(java.util.Collection<BlacklistEntry> blacklist)
      Replaces any existing blacklist with the specified blacklist.
      void setChainedProxy​(java.net.InetSocketAddress chainedProxyAddress)
      Instructs this proxy to route traffic through an upstream proxy.
      void setChainedProxyHTTPS​(boolean chainedProxyHTTPS)
      Instructs this proxy to route traffic through an upstream proxy using HTTPS.
      void setChainedProxyNonProxyHosts​(java.util.List<java.lang.String> upstreamNonProxyHosts)
      Instructs this proxy to route traffic trough an upstream proxy but handling this addresses as exceptions (non proxy hosts)
      void setConnectTimeout​(int connectionTimeout, java.util.concurrent.TimeUnit timeUnit)
      Maximum amount of time to wait to establish a connection to a remote server.
      void setHarCaptureTypes​(CaptureType... captureTypes)
      Sets the data types that will be captured in the HAR file for future requests.
      void setHarCaptureTypes​(java.util.Set<CaptureType> captureTypes)
      Sets the data types that will be captured in the HAR file for future requests.
      void setHostNameResolver​(AdvancedHostResolver resolver)
      Sets the resolver that will be used to look up host names.
      void setIdleConnectionTimeout​(int idleConnectionTimeout, java.util.concurrent.TimeUnit timeUnit)
      Maximum amount of time to allow a connection to remain idle.
      void setLatency​(long latency, java.util.concurrent.TimeUnit timeUnit)
      The minimum amount of time that will elapse between the time the proxy begins receiving a response from the server and the time the proxy begins sending the response to the client.
      void setMitmDisabled​(boolean mitmDisabled)
      Completely disables MITM for this proxy server.
      void setMitmManager​(org.littleshoot.proxy.MitmManager mitmManager)
      Sets the MITM manager, which is responsible for generating forged SSL certificates to present to clients.
      void setReadBandwidthLimit​(long bytesPerSecond)
      Sets the maximum bandwidth to consume when reading server responses.
      void setRequestTimeout​(int requestTimeout, java.util.concurrent.TimeUnit timeUnit)
      Maximum amount of time to wait for an HTTP response from the remote server after the request has been sent in its entirety.
      void setTrustAllServers​(boolean trustAllServers)
      Disables verification of all upstream servers' SSL certificates.
      void setTrustSource​(com.browserup.bup.mitm.TrustSource trustSource)
      Sets the TrustSource that contains trusted root certificate authorities that will be used to validate upstream servers' certificates.
      void setWriteBandwidthLimit​(long bytesPerSecond)
      Sets the maximum bandwidth to consume when sending requests to servers.
      void start()
      Starts the proxy on port 0 (a JVM-selected open port).
      void start​(int port)
      Starts the proxy on the specified port.
      void start​(int port, java.net.InetAddress bindAddress)
      Starts the proxy on the specified port.
      void start​(int port, java.net.InetAddress clientBindAddress, java.net.InetAddress serverBindAddress)
      Starts the proxy on the specified port.
      void stop()
      Stops accepting new client connections and initiates a graceful shutdown of the proxy server, waiting up to 5 seconds for network traffic to stop.
      void stopAutoAuthorization​(java.lang.String domain)
      Stops automatic authorization for the specified domain.
      boolean waitForQuiescence​(long quietPeriod, long timeout, java.util.concurrent.TimeUnit timeUnit)
      Waits for existing network traffic to stop, and for the specified quietPeriod to elapse.
      void whitelistRequests​(java.util.Collection<java.lang.String> urlPatterns, int statusCode)
      Whitelists URLs matching the specified regular expression patterns.
    • Method Detail

      • start

        void start()
        Starts the proxy on port 0 (a JVM-selected open port). The proxy will bind the listener to the wildcard address (0:0:0:0 - all network interfaces).
        Throws:
        java.lang.IllegalStateException - if the proxy has already been started
      • start

        void start​(int port)
        Starts the proxy on the specified port. The proxy will bind the listener to the wildcard address (0:0:0:0 - all network interfaces).
        Parameters:
        port - port to listen on
        Throws:
        java.lang.IllegalStateException - if the proxy has already been started
      • start

        void start​(int port,
                   java.net.InetAddress bindAddress)
        Starts the proxy on the specified port. The proxy will listen for connections on the network interface specified by the bindAddress, and will also initiate connections to upstream servers on the same network interface.
        Parameters:
        port - port to listen on
        bindAddress - address of the network interface on which the proxy will listen for connections and also attempt to connect to upstream servers.
        Throws:
        java.lang.IllegalStateException - if the proxy has already been started
      • start

        void start​(int port,
                   java.net.InetAddress clientBindAddress,
                   java.net.InetAddress serverBindAddress)
        Starts the proxy on the specified port. The proxy will listen for connections on the network interface specified by the clientBindAddress, and will initiate connections to upstream servers from the network interface specified by the serverBindAddress.
        Parameters:
        port - port to listen on
        clientBindAddress - address of the network interface on which the proxy will listen for connections
        serverBindAddress - address of the network interface on which the proxy will connect to upstream servers
        Throws:
        java.lang.IllegalStateException - if the proxy has already been started
      • isStarted

        boolean isStarted()
        Returns true if the proxy is started and listening for connections, otherwise false.
        Returns:
        is proxy started
      • stop

        void stop()
        Stops accepting new client connections and initiates a graceful shutdown of the proxy server, waiting up to 5 seconds for network traffic to stop. If the proxy was previously stopped or aborted, this method has no effect.
        Throws:
        java.lang.IllegalStateException - if the proxy has not been started.
      • abort

        void abort()
        Like stop(), shuts down the proxy server and no longer accepts incoming connections, but does not wait for any existing network traffic to cease. Any existing connections to clients or to servers may be force-killed immediately. If the proxy was previously stopped or aborted, this method has no effect.
        Throws:
        java.lang.IllegalStateException - if the proxy has not been started
      • getClientBindAddress

        java.net.InetAddress getClientBindAddress()
        Returns the address of the network interface on which the proxy is listening for client connections.
        Returns:
        the client bind address, or null if the proxy has not been started
      • getPort

        int getPort()
        Returns the actual port on which the proxy is listening for client connections.
        Returns:
        port
        Throws:
        java.lang.IllegalStateException - if the proxy has not been started
      • getServerBindAddress

        java.net.InetAddress getServerBindAddress()
        Returns the address address of the network interface the proxy will use to initiate upstream connections. If no server bind address has been set, this method returns null, even if the proxy has been started.
        Returns:
        server bind address if one has been set, otherwise null
      • getHar

        default Har getHar()
        Retrieves the current HAR.
        Returns:
        current HAR, or null if HAR capture is not enabled
      • getHar

        Har getHar​(boolean cleanHar)
        If cleanHar is false - returns current HAR. If cleanHar is true - cleans current HAR and returns HAR with data it has before cleaning.
        Returns:
        current HAR, or null if HAR capture is not enabled
      • newHar

        Har newHar()
        Starts a new HAR file with the default page name (see newPage(). Enables HAR capture if it was not previously enabled.
        Returns:
        existing HAR file, or null if none exists or HAR capture was disabled
      • newHar

        Har newHar​(java.lang.String initialPageRef)
        Starts a new HAR file with the specified initialPageRef as the page name and page title. Enables HAR capture if it was not previously enabled.
        Parameters:
        initialPageRef - initial page name of the new HAR file
        Returns:
        existing HAR file, or null if none exists or HAR capture was disabled
      • newHar

        Har newHar​(java.lang.String initialPageRef,
                   java.lang.String initialPageTitle)
        Starts a new HAR file with the specified page name and page title. Enables HAR capture if it was not previously enabled.
        Parameters:
        initialPageRef - initial page name of the new HAR file
        initialPageTitle - initial page title of the new HAR file
        Returns:
        existing HAR file, or null if none exists or HAR capture was disabled
      • setHarCaptureTypes

        void setHarCaptureTypes​(java.util.Set<CaptureType> captureTypes)
        Sets the data types that will be captured in the HAR file for future requests. Replaces any existing capture types with the specified capture types. A null or empty set will not disable HAR capture, but will disable collection of additional CaptureType data types. CaptureType provides several convenience methods to retrieve commonly-used capture settings. Note: HAR capture must still be explicitly enabled via newHar() or newHar(String) to begin capturing any request and response contents.
        Parameters:
        captureTypes - HAR data types to capture
      • setHarCaptureTypes

        void setHarCaptureTypes​(CaptureType... captureTypes)
        Sets the data types that will be captured in the HAR file for future requests. Replaces any existing capture types with the specified capture types. A null or empty set will not disable HAR capture, but will disable collection of additional CaptureType data types. CaptureType provides several convenience methods to retrieve commonly-used capture settings. Note: HAR capture must still be explicitly enabled via newHar() or newHar(String) to begin capturing any request and response contents.
        Parameters:
        captureTypes - HAR data types to capture
      • getHarCaptureTypes

        java.util.EnumSet<CaptureType> getHarCaptureTypes()
        Returns:
        A copy of HAR capture types currently in effect. The EnumSet cannot be used to modify the HAR capture types currently in effect.
      • enableHarCaptureTypes

        void enableHarCaptureTypes​(java.util.Set<CaptureType> captureTypes)
        Enables the specified HAR capture types. Does not replace or disable any other capture types that may already be enabled.
        Parameters:
        captureTypes - capture types to enable
      • enableHarCaptureTypes

        void enableHarCaptureTypes​(CaptureType... captureTypes)
        Enables the specified HAR capture types. Does not replace or disable any other capture types that may already be enabled.
        Parameters:
        captureTypes - capture types to enable
      • disableHarCaptureTypes

        void disableHarCaptureTypes​(java.util.Set<CaptureType> captureTypes)
        Disables the specified HAR capture types. Does not replace or disable any other capture types that may already be enabled.
        Parameters:
        captureTypes - capture types to disable
      • disableHarCaptureTypes

        void disableHarCaptureTypes​(CaptureType... captureTypes)
        Disables the specified HAR capture types. Does not replace or disable any other capture types that may already be enabled.
        Parameters:
        captureTypes - capture types to disable
      • newPage

        Har newPage()
        Starts a new HAR page using the default page naming convention. The default page naming convention is "Page #", where "#" resets to 1 every time newHar() or newHar(String) is called, and increments on every subsequent call to newPage() or newHar(String). Populates the HarPageTiming.onLoad value based on the amount of time the current page has been captured.
        Returns:
        the HAR as it existed immediately after ending the current page
        Throws:
        java.lang.IllegalStateException - if HAR capture has not been enabled via newHar() or newHar(String)
      • newPage

        Har newPage​(java.lang.String pageRef)
        Starts a new HAR page using the specified pageRef as the page name and the page title. Populates the HarPageTiming.onLoad value based on the amount of time the current page has been captured.
        Parameters:
        pageRef - name of the new page
        Returns:
        the HAR as it existed immediately after ending the current page
        Throws:
        java.lang.IllegalStateException - if HAR capture has not been enabled via newHar() or newHar(String)
      • newPage

        Har newPage​(java.lang.String pageRef,
                    java.lang.String pageTitle)
        Starts a new HAR page using the specified pageRef as the page name and the pageTitle as the page title. Populates the HarPageTiming.onLoad value based on the amount of time the current page has been captured.
        Parameters:
        pageRef - name of the new page
        pageTitle - title of the new page
        Returns:
        the HAR as it existed immediately after ending the current page
        Throws:
        java.lang.IllegalStateException - if HAR capture has not been enabled via newHar() or newHar(String)
      • endHar

        Har endHar()
        Stops capturing traffic in the HAR. Populates the HarPageTiming.onLoad value for the current page based on the amount of time it has been captured.
        Returns:
        the existing HAR
      • setReadBandwidthLimit

        void setReadBandwidthLimit​(long bytesPerSecond)
        Sets the maximum bandwidth to consume when reading server responses.
        Parameters:
        bytesPerSecond - maximum bandwidth, in bytes per second
      • getReadBandwidthLimit

        long getReadBandwidthLimit()
        Returns the current bandwidth limit for reading, in bytes per second.
        Returns:
        ReadBandwidthLimit
      • setWriteBandwidthLimit

        void setWriteBandwidthLimit​(long bytesPerSecond)
        Sets the maximum bandwidth to consume when sending requests to servers.
        Parameters:
        bytesPerSecond - maximum bandwidth, in bytes per second
      • getWriteBandwidthLimit

        long getWriteBandwidthLimit()
        Returns the current bandwidth limit for writing, in bytes per second.
        Returns:
        WriteBandwidthLimit
      • setLatency

        void setLatency​(long latency,
                        java.util.concurrent.TimeUnit timeUnit)
        The minimum amount of time that will elapse between the time the proxy begins receiving a response from the server and the time the proxy begins sending the response to the client.
        Parameters:
        latency - minimum latency, or 0 for no minimum
        timeUnit - TimeUnit for the latency
      • setConnectTimeout

        void setConnectTimeout​(int connectionTimeout,
                               java.util.concurrent.TimeUnit timeUnit)
        Maximum amount of time to wait to establish a connection to a remote server. If the connection has not been established within the specified time, the proxy will respond with an HTTP 502 Bad Gateway. The default value is 60 seconds.
        Parameters:
        connectionTimeout - maximum time to wait to establish a connection to a server, or 0 to wait indefinitely
        timeUnit - TimeUnit for the connectionTimeout
      • setIdleConnectionTimeout

        void setIdleConnectionTimeout​(int idleConnectionTimeout,
                                      java.util.concurrent.TimeUnit timeUnit)
        Maximum amount of time to allow a connection to remain idle. A connection becomes idle when it has not received data from a server within the the specified timeout. If the proxy has not yet begun to forward the response to the client, the proxy will respond with an HTTP 504 Gateway Timeout. If the proxy has already started forwarding the response to the client, the connection to the client may be closed abruptly. The default value is 60 seconds.
        Parameters:
        idleConnectionTimeout - maximum time to allow a connection to remain idle, or 0 to wait indefinitely.
        timeUnit - TimeUnit for the idleConnectionTimeout
      • setRequestTimeout

        void setRequestTimeout​(int requestTimeout,
                               java.util.concurrent.TimeUnit timeUnit)
        Maximum amount of time to wait for an HTTP response from the remote server after the request has been sent in its entirety. The HTTP request must complete within the specified time. If the proxy has not yet begun to forward the response to the client, the proxy will respond with an HTTP 504 Gateway Timeout. If the proxy has already started forwarding the response to the client, the connection to the client may be closed abruptly. The default value is 0 (wait indefinitely).
        Parameters:
        requestTimeout - maximum time to wait for an HTTP response, or 0 to wait indefinitely
        timeUnit - TimeUnit for the requestTimeout
      • autoAuthorization

        void autoAuthorization​(java.lang.String domain,
                               java.lang.String username,
                               java.lang.String password,
                               AuthType authType)
        Enables automatic authorization for the specified domain and auth type. Every request sent to the specified domain will contain the specified authorization information.
        Parameters:
        domain - domain automatically send authorization information to
        username - authorization username
        password - authorization password
        authType - authorization type
      • stopAutoAuthorization

        void stopAutoAuthorization​(java.lang.String domain)
        Stops automatic authorization for the specified domain.
        Parameters:
        domain - domain to stop automatically sending authorization information to
      • chainedProxyAuthorization

        void chainedProxyAuthorization​(java.lang.String username,
                                       java.lang.String password,
                                       AuthType authType)
        Enables chained proxy authorization using the Proxy-Authorization header described in RFC 7235, section 4.4 (https://tools.ietf.org/html/rfc7235#section-4.4). Currently, only AuthType.BASIC authentication is supported.
        Parameters:
        username - the username to use to authenticate with the chained proxy
        password - the password to use to authenticate with the chained proxy
        authType - the auth type to use (currently, must be BASIC)
      • rewriteUrl

        void rewriteUrl​(java.lang.String urlPattern,
                        java.lang.String replacementExpression)
        Adds a rewrite rule for the specified URL-matching regular expression. If there are any existing rewrite rules, the new rewrite rule will be applied last, after all other rewrite rules are applied. The specified urlPattern will be replaced with the specified replacement expression. The urlPattern is treated as a Java regular expression and must be properly escaped (see Pattern). The replacementExpression may consist of capture groups specified in the urlPattern, denoted by a $ (see Matcher.appendReplacement(StringBuffer, String). For HTTP requests (not HTTPS), if the hostname and/or port is changed as a result of a rewrite rule, the Host header of the request will be modified to reflect the updated hostname/port. For HTTPS requests, the host and port cannot be changed by rewrite rules (use getHostNameResolver() and AdvancedHostResolver.remapHost(String, String) to direct HTTPS requests to a different host). Note: The rewriting applies to the entire URL, including scheme (http:// or https://), hostname/address, port, and query string. Note that this means a urlPattern of "http://www\.website\.com/page" will NOT match http://www.website.com:80/page. For example, the following rewrite rule:
           proxy.rewriteUrl("http://www\\.(yahoo|bing)\\.com/\\?(\\w+)=(\\w+)", "http://www.google.com/?originalDomain=$1&$2=$3");
        will match an HTTP request (but not HTTPS!) to www.yahoo.com or www.bing.com with exactly 1 query parameter, and replace it with a call to www.google.com with an 'originalDomain' query parameter, as well as the original query parameter. When applied to the URL:
           http://www.yahoo.com?theFirstParam=someValue
        will result in the proxy making a request to:
           http://www.google.com?originalDomain=yahoo&theFirstParam=someValue
        When applied to the URL:
           http://www.bing.com?anotherParam=anotherValue
        will result in the proxy making a request to:
           http://www.google.com?originalDomain=bing&anotherParam=anotherValue
        Parameters:
        urlPattern - URL-matching regular expression
        replacementExpression - an expression, which may optionally contain capture groups, which will replace any URL which matches urlPattern
      • rewriteUrls

        void rewriteUrls​(java.util.Map<java.lang.String,​java.lang.String> rewriteRules)
        Replaces existing rewrite rules with the specified patterns and replacement expressions. The rules will be applied in the order specified by the Map's iterator. See rewriteUrl(String, String) for details on the format of the rewrite rules.
        Parameters:
        rewriteRules - Map<urlPattern, replacementExpression>
      • getRewriteRules

        java.util.Map<java.lang.String,​java.lang.String> getRewriteRules()
        Returns all rewrite rules currently in effect. Iterating over the returned Map is guaranteed to return rewrite rules in the order in which the rules are actually applied.
        Returns:
        Map<URL-matching regex, replacement expression>
      • removeRewriteRule

        void removeRewriteRule​(java.lang.String urlPattern)
        Removes an existing rewrite rule whose urlPattern matches the specified pattern.
        Parameters:
        urlPattern - rewrite rule pattern to remove
      • clearRewriteRules

        void clearRewriteRules()
        Clears all existing rewrite rules.
      • blacklistRequests

        void blacklistRequests​(java.lang.String urlPattern,
                               int statusCode)
        Adds a URL-matching regular expression to the blacklist. Requests that match a blacklisted URL will return the specified HTTP statusCode for all HTTP methods. If there are existing patterns on the blacklist, the urlPattern will be evaluated last, after the URL is checked against all other blacklist entries. The urlPattern matches the full URL of the request, including scheme, host, and port, path, and query parameters for both HTTP and HTTPS requests. For example, to blacklist both HTTP and HTTPS requests to www.google.com, use a urlPattern of "https?://www\\.google\\.com/.*".
        Parameters:
        urlPattern - URL-matching regular expression to blacklist
        statusCode - HTTP status code to return
      • blacklistRequests

        void blacklistRequests​(java.lang.String urlPattern,
                               int statusCode,
                               java.lang.String httpMethodPattern)
        Adds a URL-matching regular expression to the blacklist. Requests that match a blacklisted URL will return the specified HTTP statusCode only when the request's HTTP method (GET, POST, PUT, etc.) matches the specified httpMethodPattern regular expression. If there are existing patterns on the blacklist, the urlPattern will be evaluated last, after the URL is checked against all other blacklist entries. See blacklistRequests(String, int) for details on the URL the urlPattern will match.
        Parameters:
        urlPattern - URL-matching regular expression to blacklist
        statusCode - HTTP status code to return
        httpMethodPattern - regular expression matching a request's HTTP method
      • setBlacklist

        void setBlacklist​(java.util.Collection<BlacklistEntry> blacklist)
        Replaces any existing blacklist with the specified blacklist. URLs will be evaluated against the blacklist in the order specified by the Collection's iterator.
        Parameters:
        blacklist - new blacklist entries
      • getBlacklist

        java.util.Collection<BlacklistEntry> getBlacklist()
        Returns all blacklist entries currently in effect. Iterating over the returned Collection is guaranteed to return blacklist entries in the order in which URLs are actually evaluated against the blacklist.
        Returns:
        blacklist entries, or an empty collection if none exist
      • clearBlacklist

        void clearBlacklist()
        Clears any existing blacklist.
      • whitelistRequests

        void whitelistRequests​(java.util.Collection<java.lang.String> urlPatterns,
                               int statusCode)
        Whitelists URLs matching the specified regular expression patterns. Replaces any existing whitelist. The urlPattern matches the full URL of the request, including scheme, host, and port, path, and query parameters for both HTTP and HTTPS requests. For example, to whitelist both HTTP and HTTPS requests to www.google.com, use a urlPattern of "https?://www\\.google\\.com/.*". Note: All HTTP CONNECT requests are automatically whitelisted and cannot be short-circuited using the whitelist response code.
        Parameters:
        urlPatterns - URL-matching regular expressions to whitelist; null or an empty collection will enable an empty whitelist
        statusCode - HTTP status code to return to clients when a URL matches a pattern
      • addWhitelistPattern

        void addWhitelistPattern​(java.lang.String urlPattern)
        Adds a URL-matching regular expression to an existing whitelist.
        Parameters:
        urlPattern - URL-matching regular expressions to whitelist
        Throws:
        java.lang.IllegalStateException - if the whitelist is not enabled
      • enableEmptyWhitelist

        void enableEmptyWhitelist​(int statusCode)
        Enables the whitelist, but with no matching URLs. All requests will generated the specified HTTP statusCode.
        Parameters:
        statusCode - HTTP status code to return to clients on all requests
      • disableWhitelist

        void disableWhitelist()
        Clears any existing whitelist and disables whitelisting.
      • getWhitelistUrls

        java.util.Collection<java.lang.String> getWhitelistUrls()
        Returns the URL-matching regular expressions currently in effect. If the whitelist is disabled, this method always returns an empty collection. If the whitelist is enabled but empty, this method return an empty collection.
        Returns:
        whitelist currently in effect, or an empty collection if the whitelist is disabled or empty
      • getWhitelistStatusCode

        int getWhitelistStatusCode()
        Returns the status code returned for all URLs that do not match the whitelist. If the whitelist is not currently enabled, returns -1.
        Returns:
        HTTP status code returned for non-whitelisted URLs, or -1 if the whitelist is disabled.
      • isWhitelistEnabled

        boolean isWhitelistEnabled()
        Returns true if the whitelist is enabled, otherwise false.
        Returns:
        is WhitelistEnabled
      • addHeaders

        void addHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
        Adds the specified HTTP headers to every request. Replaces any existing additional headers with the specified headers.
        Parameters:
        headers - Map<header name, header value> to append to every request.
      • addHeader

        void addHeader​(java.lang.String name,
                       java.lang.String value)
        Adds a new HTTP header to every request. If the header already exists on the request, it will be replaced with the specified header.
        Parameters:
        name - name of the header to add
        value - new header's value
      • removeHeader

        void removeHeader​(java.lang.String name)
        Removes a header previously added with addHeader(String name, String value).
        Parameters:
        name - previously-added header's name
      • getAllHeaders

        java.util.Map<java.lang.String,​java.lang.String> getAllHeaders()
        Returns all headers previously added with addHeader(String name, String value).
        Returns:
        Map<header name, header value>
      • setHostNameResolver

        void setHostNameResolver​(AdvancedHostResolver resolver)
        Sets the resolver that will be used to look up host names. To chain multiple resolvers, wrap a list of resolvers in a ChainedHostResolver.
        Parameters:
        resolver - host name resolver
      • getHostNameResolver

        AdvancedHostResolver getHostNameResolver()
        Returns the current host name resolver.
        Returns:
        current host name resolver
      • waitForQuiescence

        boolean waitForQuiescence​(long quietPeriod,
                                  long timeout,
                                  java.util.concurrent.TimeUnit timeUnit)
        Waits for existing network traffic to stop, and for the specified quietPeriod to elapse. Returns true if there is no network traffic for the quiet period within the specified timeout, otherwise returns false.
        Parameters:
        quietPeriod - amount of time after which network traffic will be considered "stopped"
        timeout - maximum amount of time to wait for network traffic to stop
        timeUnit - TimeUnit for the quietPeriod and timeout
        Returns:
        true if network traffic is stopped, otherwise false
      • setChainedProxy

        void setChainedProxy​(java.net.InetSocketAddress chainedProxyAddress)
        Instructs this proxy to route traffic through an upstream proxy. Note: A chained proxy must be set before the proxy is started, though it can be changed after the proxy is started.
        Parameters:
        chainedProxyAddress - address of the upstream proxy
      • setChainedProxyHTTPS

        void setChainedProxyHTTPS​(boolean chainedProxyHTTPS)
        Instructs this proxy to route traffic through an upstream proxy using HTTPS.
        Parameters:
        chainedProxyHTTPS - address of the upstream proxy
      • setChainedProxyNonProxyHosts

        void setChainedProxyNonProxyHosts​(java.util.List<java.lang.String> upstreamNonProxyHosts)
        Instructs this proxy to route traffic trough an upstream proxy but handling this addresses as exceptions (non proxy hosts)
        Parameters:
        upstreamNonProxyHosts - non proxy hosts also called proxy exceptions
      • getChainedProxy

        java.net.InetSocketAddress getChainedProxy()
        Returns the address and port of the upstream proxy.
        Returns:
        address and port of the upstream proxy, or null of there is none.
      • addFirstHttpFilterFactory

        void addFirstHttpFilterFactory​(org.littleshoot.proxy.HttpFiltersSource filterFactory)
        Adds a new filter factory (request/response interceptor) to the beginning of the HttpFilters chain. Usage note: The actual filter (interceptor) instance is created on every request by implementing the HttpFiltersSource.filterRequest(io.netty.handler.codec.http.HttpRequest, io.netty.channel.ChannelHandlerContext) method and returning an HttpFilters instance (typically, a subclass of HttpFiltersAdapter). To disable or bypass a filter on a per-request basis, the filterRequest() method may return null.
        Parameters:
        filterFactory - factory to generate HttpFilters
      • addLastHttpFilterFactory

        void addLastHttpFilterFactory​(org.littleshoot.proxy.HttpFiltersSource filterFactory)
        Adds a new filter factory (request/response interceptor) to the end of the HttpFilters chain. Usage note: The actual filter (interceptor) instance is created on every request by implementing the HttpFiltersSource.filterRequest(io.netty.handler.codec.http.HttpRequest, io.netty.channel.ChannelHandlerContext) method and returning an HttpFilters instance (typically, a subclass of HttpFiltersAdapter). To disable or bypass a filter on a per-request basis, the filterRequest() method may return null.
        Parameters:
        filterFactory - factory to generate HttpFilters
      • addResponseFilter

        void addResponseFilter​(ResponseFilter filter)
        Adds a new ResponseFilter that can be used to examine and manipulate the response before sending it to the client.
        Parameters:
        filter - filter instance
      • addRequestFilter

        void addRequestFilter​(RequestFilter filter)
        Adds a new RequestFilter that can be used to examine and manipulate the request before sending it to the server.
        Parameters:
        filter - filter instance
      • setMitmDisabled

        void setMitmDisabled​(boolean mitmDisabled)
        Completely disables MITM for this proxy server. The proxy will no longer intercept HTTPS requests, but they will still be pass-through proxied. This option must be set before the proxy is started; otherwise an IllegalStateException will be thrown.
        Parameters:
        mitmDisabled - when true, MITM capture will be disabled
        Throws:
        java.lang.IllegalStateException - if the proxy is already started
      • setMitmManager

        void setMitmManager​(org.littleshoot.proxy.MitmManager mitmManager)
        Sets the MITM manager, which is responsible for generating forged SSL certificates to present to clients. By default, BrowserUp Proxy uses the ca-certificate-rsa.cer root certificate for impersonation. See the documentation at ImpersonatingMitmManager and ImpersonatingMitmManager.Builder for details on customizing the root and server certificate generation.
        Parameters:
        mitmManager - MITM manager to use
      • setTrustAllServers

        void setTrustAllServers​(boolean trustAllServers)
        Disables verification of all upstream servers' SSL certificates. All upstream servers will be trusted, even if they do not present valid certificates signed by certification authorities in the JDK's trust store. This option exposes the proxy to MITM attacks and should only be used when testing in trusted environments.
        Parameters:
        trustAllServers - when true, disables upstream server certificate verification
      • setTrustSource

        void setTrustSource​(com.browserup.bup.mitm.TrustSource trustSource)
        Sets the TrustSource that contains trusted root certificate authorities that will be used to validate upstream servers' certificates. When null, disables certificate validation (see warning at setTrustAllServers(boolean)).
        Parameters:
        trustSource - TrustSource containing root CAs, or null to disable upstream server validation
      • findMostRecentEntry

        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

        java.util.Collection<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.
      • assertMostRecentResponseTimeLessThanOrEqual

        AssertionResult assertMostRecentResponseTimeLessThanOrEqual​(java.util.regex.Pattern url,
                                                                    long milliseconds)
        Assert that the response time for the most recent request found by a given URL pattern is less than or equal to a given number of milliseconds.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        milliseconds - Maximum time in milliseconds, inclusive.
        Returns:
        Assertion result
      • assertResponseTimeLessThanOrEqual

        AssertionResult assertResponseTimeLessThanOrEqual​(java.util.regex.Pattern url,
                                                          long milliseconds)
        Assert that the response times for all requests found by a given URL pattern are less than or equal to a given number of milliseconds.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        milliseconds - Maximum time in milliseconds, inclusive.
        Returns:
        Assertion result
      • assertMostRecentResponseContentContains

        AssertionResult assertMostRecentResponseContentContains​(java.util.regex.Pattern url,
                                                                java.lang.String text)
        Assert that response content for the most recent request found by a given URL pattern contains specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        text - String to search in the content
        Returns:
        Assertion result
      • assertMostRecentResponseContentDoesNotContain

        AssertionResult assertMostRecentResponseContentDoesNotContain​(java.util.regex.Pattern url,
                                                                      java.lang.String text)
        Assert that response content for the most recent request found by a given URL pattern doesn't contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        text - String to search in the content
        Returns:
        Assertion result
      • assertMostRecentResponseContentMatches

        AssertionResult assertMostRecentResponseContentMatches​(java.util.regex.Pattern url,
                                                               java.util.regex.Pattern contentPattern)
        Assert that response content for the most recent request found by a given URL pattern matches content pattern.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        contentPattern - Regular expression match of content to find.
        Returns:
        Assertion result
      • assertAnyUrlContentLengthLessThanOrEquals

        AssertionResult assertAnyUrlContentLengthLessThanOrEquals​(java.util.regex.Pattern url,
                                                                  java.lang.Long max)
        Assert that content length of all responses found by url pattern do not exceed max value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        max - Max length of content, inclusive
        Returns:
        Assertion result
      • assertAnyUrlContentMatches

        AssertionResult assertAnyUrlContentMatches​(java.util.regex.Pattern url,
                                                   java.util.regex.Pattern contentPattern)
        Assert that responses content for all requests found by url pattern matches content pattern.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        contentPattern - Regular expression match of content to find.
        Returns:
        Assertion result
      • assertAnyUrlContentContains

        AssertionResult assertAnyUrlContentContains​(java.util.regex.Pattern url,
                                                    java.lang.String text)
        Assert that responses content for all requests found by a given URL pattern contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        text - String to search in the content
        Returns:
        Assertion result
      • assertAnyUrlContentDoesNotContain

        AssertionResult assertAnyUrlContentDoesNotContain​(java.util.regex.Pattern url,
                                                          java.lang.String text)
        Assert that responses content for all requests found by a given URL pattern don't contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        text - String to search in the content
        Returns:
        Assertion result
      • assertAnyUrlResponseHeaderContains

        AssertionResult assertAnyUrlResponseHeaderContains​(java.util.regex.Pattern url,
                                                           java.lang.String value)
        Assert that headers of all responses found by url pattern contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        value - Header value
        Returns:
        Assertion result
      • assertAnyUrlResponseHeaderContains

        AssertionResult assertAnyUrlResponseHeaderContains​(java.util.regex.Pattern url,
                                                           java.lang.String name,
                                                           java.lang.String value)
        Assert that if responses found by url pattern have headers with specified name - among them must be one header with value containing specified text.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        name - Header name
        value - Header value
        Returns:
        Assertion result
      • assertAnyUrlResponseHeaderDoesNotContain

        AssertionResult assertAnyUrlResponseHeaderDoesNotContain​(java.util.regex.Pattern url,
                                                                 java.lang.String value)
        Assert that headers of all responses found by url pattern don't contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        value - Header value
        Returns:
        Assertion result
      • assertAnyUrlResponseHeaderDoesNotContain

        AssertionResult assertAnyUrlResponseHeaderDoesNotContain​(java.util.regex.Pattern url,
                                                                 java.lang.String name,
                                                                 java.lang.String value)
        Assert that if responses found by url pattern have headers with specified name - their values must not contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        name - Header name
        value - Header value
        Returns:
        Assertion result
      • assertAnyUrlResponseHeaderMatches

        default AssertionResult assertAnyUrlResponseHeaderMatches​(java.util.regex.Pattern url,
                                                                  java.util.regex.Pattern valuePattern)
        Assert that all headers of all responses found by url pattern have values matching value pattern.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        valuePattern - Regular expression match of header value.
        Returns:
        Assertion result
      • assertAnyUrlResponseHeaderMatches

        AssertionResult assertAnyUrlResponseHeaderMatches​(java.util.regex.Pattern url,
                                                          java.util.regex.Pattern namePattern,
                                                          java.util.regex.Pattern valuePattern)
        Assert that if responses found by url pattern have headers with name found by name pattern - their values should match value pattern.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        namePattern - Regular expression match of header name to find.
        valuePattern - Regular expression match of header value.
        Returns:
        Assertion result
      • assertMostRecentResponseHeaderContains

        AssertionResult assertMostRecentResponseHeaderContains​(java.util.regex.Pattern url,
                                                               java.lang.String name,
                                                               java.lang.String value)
        Assert that if the most recent response found by url pattern has header with specified name - it's value must contain specified text.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        name - Header name
        value - Header value
        Returns:
        Assertion result
      • assertMostRecentResponseHeaderContains

        default AssertionResult assertMostRecentResponseHeaderContains​(java.util.regex.Pattern url,
                                                                       java.lang.String value)
        Assert that headers of the most recent response found by url pattern contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        value - Header value
        Returns:
        Assertion result
      • assertMostRecentResponseHeaderDoesNotContain

        AssertionResult assertMostRecentResponseHeaderDoesNotContain​(java.util.regex.Pattern url,
                                                                     java.lang.String name,
                                                                     java.lang.String value)
        Assert that if the most recent response found by url pattern has header with specified name - it's value must not contain specified text.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        name - Header name
        value - Header value
        Returns:
        Assertion result
      • assertMostRecentResponseHeaderDoesNotContain

        default AssertionResult assertMostRecentResponseHeaderDoesNotContain​(java.util.regex.Pattern url,
                                                                             java.lang.String value)
        Assert that headers of the most recent response found by url pattern do not contain specified value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        value - Header value
        Returns:
        Assertion result
      • assertMostRecentResponseHeaderMatches

        AssertionResult assertMostRecentResponseHeaderMatches​(java.util.regex.Pattern url,
                                                              java.util.regex.Pattern name,
                                                              java.util.regex.Pattern value)
        Assert that if the most recent response found by url pattern has header with name found by name pattern - it's value should match value pattern.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        name - Regular expression match of header name to find.
        value - Regular expression match of header value.
        Returns:
        Assertion result
      • assertMostRecentResponseHeaderMatches

        default AssertionResult assertMostRecentResponseHeaderMatches​(java.util.regex.Pattern url,
                                                                      java.util.regex.Pattern value)
        Assert that all headers of the most recent response found by url pattern have values matching value pattern.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        value - Regular expression match of header value.
        Returns:
        Assertion result
      • assertMostRecentResponseContentLengthLessThanOrEqual

        AssertionResult assertMostRecentResponseContentLengthLessThanOrEqual​(java.util.regex.Pattern url,
                                                                             java.lang.Long max)
        Assert that content length of the most recent response found by url pattern does not exceed max value.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        max - Max length of content, inclusive
        Returns:
        Assertion result
      • assertResponseStatusCode

        AssertionResult assertResponseStatusCode​(java.lang.Integer status)
        Assert that all responses of current step have specified status.
        Parameters:
        status - Expected http status
        Returns:
        Assertion result
      • assertResponseStatusCode

        AssertionResult assertResponseStatusCode​(HttpStatusClass clazz)
        Assert that all responses of current step have statuses belonging to the same class.
        Parameters:
        clazz - Http status class
        Returns:
        Assertion result
      • assertResponseStatusCode

        AssertionResult assertResponseStatusCode​(java.util.regex.Pattern url,
                                                 java.lang.Integer status)
        Assert that all responses found by url pattern have specified http status.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        status - Http status
        Returns:
        Assertion result
      • assertResponseStatusCode

        AssertionResult assertResponseStatusCode​(java.util.regex.Pattern url,
                                                 HttpStatusClass clazz)
        Assert that all responses found by url pattern have statuses belonging to the same class.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        clazz - Http status class
        Returns:
        Assertion result
      • assertMostRecentResponseStatusCode

        AssertionResult assertMostRecentResponseStatusCode​(java.lang.Integer status)
        Assert that the most recent response has specified status.
        Parameters:
        status - Http status
        Returns:
        Assertion result
      • assertMostRecentResponseStatusCode

        AssertionResult assertMostRecentResponseStatusCode​(HttpStatusClass clazz)
        Assert that the most recent response has status belonging to specified class.
        Parameters:
        clazz - Http status class
        Returns:
        Assertion result
      • assertMostRecentResponseStatusCode

        AssertionResult assertMostRecentResponseStatusCode​(java.util.regex.Pattern url,
                                                           java.lang.Integer status)
        Assert that the most recent response found by url pattern has specified status.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        status - Http status
        Returns:
        Assertion result
      • assertMostRecentResponseStatusCode

        AssertionResult assertMostRecentResponseStatusCode​(java.util.regex.Pattern url,
                                                           HttpStatusClass clazz)
        Assert that the most recent response found by url pattern has status belonging to specified class.
        Parameters:
        url - Regular expression match of URL to find. See examples findEntries(java.util.regex.Pattern)
        clazz - Http status class
        Returns:
        Assertion result