Class HttpFiltersAdapter

    • Method Detail

      • clientToProxyRequest

        public HttpResponse clientToProxyRequest​(HttpObject httpObject)
        Description copied from interface: HttpFilters
        Filters requests on their way from the client to the proxy. To interrupt processing of this request and return a response to the client immediately, return an HttpResponse here. Otherwise, return null to continue processing as usual.

        Important: When returning a response, you must include a mechanism to allow the client to determine the length of the message (see RFC 7230, section 3.3.3: https://tools.ietf.org/html/rfc7230#section-3.3.3 ). For messages that may contain a body, you may do this by setting the Transfer-Encoding to chunked, setting an appropriate Content-Length, or by adding a "Connection: close" header to the response (which will instruct LittleProxy to close the connection). If the short-circuit response contains body content, it is recommended that you return a FullHttpResponse.

        Specified by:
        clientToProxyRequest in interface HttpFilters
        Parameters:
        httpObject - Client to Proxy HttpRequest (and HttpContent, if chunked)
        Returns:
        a short-circuit response, or null to continue processing as usual
      • proxyToServerRequest

        public HttpResponse proxyToServerRequest​(HttpObject httpObject)
        Description copied from interface: HttpFilters
        Filters requests on their way from the proxy to the server. To interrupt processing of this request and return a response to the client immediately, return an HttpResponse here. Otherwise, return null to continue processing as usual.

        Important: When returning a response, you must include a mechanism to allow the client to determine the length of the message (see RFC 7230, section 3.3.3: https://tools.ietf.org/html/rfc7230#section-3.3.3 ). For messages that may contain a body, you may do this by setting the Transfer-Encoding to chunked, setting an appropriate Content-Length, or by adding a "Connection: close" header to the response. (which will instruct LittleProxy to close the connection). If the short-circuit response contains body content, it is recommended that you return a FullHttpResponse.

        Specified by:
        proxyToServerRequest in interface HttpFilters
        Parameters:
        httpObject - Proxy to Server HttpRequest (and HttpContent, if chunked)
        Returns:
        a short-circuit response, or null to continue processing as usual
      • proxyToServerRequestSending

        public void proxyToServerRequestSending()
        Description copied from interface: HttpFilters
        Informs filter that proxy to server request is being sent.
        Specified by:
        proxyToServerRequestSending in interface HttpFilters
      • proxyToServerRequestSent

        public void proxyToServerRequestSent()
        Description copied from interface: HttpFilters
        Informs filter that the HTTP request, including any content, has been sent.
        Specified by:
        proxyToServerRequestSent in interface HttpFilters
      • serverToProxyResponse

        public HttpObject serverToProxyResponse​(HttpObject httpObject)
        Description copied from interface: HttpFilters
        Filters responses on their way from the server to the proxy.
        Specified by:
        serverToProxyResponse in interface HttpFilters
        Parameters:
        httpObject - Server to Proxy HttpResponse (and HttpContent, if chunked)
        Returns:
        the modified (or unmodified) HttpObject. Returning null will force a disconnect.
      • serverToProxyResponseTimedOut

        public void serverToProxyResponseTimedOut()
        Description copied from interface: HttpFilters
        Informs filter that a timeout occurred before the server response was received by the client. The timeout may have occurred while the client was sending the request, waiting for a response, or after the client started receiving a response (i.e. if the response from the server "stalls"). See HttpProxyServerBootstrap.withIdleConnectionTimeout(int) for information on setting the timeout.
        Specified by:
        serverToProxyResponseTimedOut in interface HttpFilters
      • serverToProxyResponseReceiving

        public void serverToProxyResponseReceiving()
        Description copied from interface: HttpFilters
        Informs filter that server to proxy response is being received.
        Specified by:
        serverToProxyResponseReceiving in interface HttpFilters
      • serverToProxyResponseReceived

        public void serverToProxyResponseReceived()
        Description copied from interface: HttpFilters
        Informs filter that server to proxy response has been received.
        Specified by:
        serverToProxyResponseReceived in interface HttpFilters
      • proxyToClientResponse

        public HttpObject proxyToClientResponse​(HttpObject httpObject)
        Description copied from interface: HttpFilters
        Filters responses on their way from the proxy to the client.
        Specified by:
        proxyToClientResponse in interface HttpFilters
        Parameters:
        httpObject - Proxy to Client HttpResponse (and HttpContent, if chunked)
        Returns:
        the modified (or unmodified) HttpObject. Returning null will force a disconnect.
      • proxyToServerConnectionQueued

        public void proxyToServerConnectionQueued()
        Description copied from interface: HttpFilters
        Informs filter that proxy to server connection is in queue.
        Specified by:
        proxyToServerConnectionQueued in interface HttpFilters
      • proxyToServerResolutionStarted

        public InetSocketAddress proxyToServerResolutionStarted​(String resolvingServerHostAndPort)
        Description copied from interface: HttpFilters
        Filter DNS resolution from proxy to server.
        Specified by:
        proxyToServerResolutionStarted in interface HttpFilters
        Parameters:
        resolvingServerHostAndPort - Server "HOST:PORT"
        Returns:
        alternative address resolution. Returning null will let normal DNS resolution continue.
      • proxyToServerResolutionFailed

        public void proxyToServerResolutionFailed​(String hostAndPort)
        Description copied from interface: HttpFilters
        Informs filter that proxy to server DNS resolution failed for the specified host and port.
        Specified by:
        proxyToServerResolutionFailed in interface HttpFilters
        Parameters:
        hostAndPort - hostname and port the proxy failed to resolve
      • proxyToServerResolutionSucceeded

        public void proxyToServerResolutionSucceeded​(String serverHostAndPort,
                                                     InetSocketAddress resolvedRemoteAddress)
        Description copied from interface: HttpFilters
        Informs filter that proxy to server DNS resolution has happened.
        Specified by:
        proxyToServerResolutionSucceeded in interface HttpFilters
        Parameters:
        serverHostAndPort - Server "HOST:PORT"
        resolvedRemoteAddress - Address it was proxyToServerResolutionSucceeded to
      • proxyToServerConnectionStarted

        public void proxyToServerConnectionStarted()
        Description copied from interface: HttpFilters
        Informs filter that proxy to server connection is initiating.
        Specified by:
        proxyToServerConnectionStarted in interface HttpFilters
      • proxyToServerConnectionFailed

        public void proxyToServerConnectionFailed()
        Description copied from interface: HttpFilters
        Informs filter that proxy to server connection has failed.
        Specified by:
        proxyToServerConnectionFailed in interface HttpFilters
      • proxyToServerAllowMitm

        public boolean proxyToServerAllowMitm()
        Description copied from interface: HttpFilters
        Allow this proxy to act as an SSL man in the middle.

        Has no impact if man in the middle is not enabled.

        Specified by:
        proxyToServerAllowMitm in interface HttpFilters
        Returns:
        true to allow mitm, false to not mitm the proxy to server connection.