Class HarCaptureFilter

  • All Implemented Interfaces:
    org.littleshoot.proxy.HttpFilters

    public class HarCaptureFilter
    extends HttpsAwareFiltersAdapter
    • Constructor Detail

      • HarCaptureFilter

        public HarCaptureFilter​(io.netty.handler.codec.http.HttpRequest originalRequest,
                                io.netty.channel.ChannelHandlerContext ctx,
                                Har har,
                                java.lang.String currentPageRef,
                                java.util.Set<CaptureType> dataToCapture)
        Create a new instance of the HarCaptureFilter that will capture request and response information. If no har is specified in the constructor, this filter will do nothing. Regardless of the CaptureTypes specified in dataToCapture, the HarCaptureFilter will always capture:
        • Request and response sizes
        • HTTP request and status lines
        • Page timing information
        Parameters:
        originalRequest - the original HttpRequest from the HttpFiltersSource factory
        har - a reference to the ProxyServer's current HAR file at the time this request is received (can be null if HAR capture is not required)
        currentPageRef - the ProxyServer's currentPageRef at the time this request is received from the client
        dataToCapture - the data types to capture for this request. null or empty set indicates only basic information will be captured (see CaptureType for information on data collected for each CaptureType)
        ctx - ChannelHandlerContext ctx
    • Method Detail

      • clientToProxyRequest

        public io.netty.handler.codec.http.HttpResponse clientToProxyRequest​(io.netty.handler.codec.http.HttpObject httpObject)
        Specified by:
        clientToProxyRequest in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        clientToProxyRequest in class org.littleshoot.proxy.HttpFiltersAdapter
      • serverToProxyResponse

        public io.netty.handler.codec.http.HttpObject serverToProxyResponse​(io.netty.handler.codec.http.HttpObject httpObject)
        Specified by:
        serverToProxyResponse in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        serverToProxyResponse in class org.littleshoot.proxy.HttpFiltersAdapter
      • serverToProxyResponseTimedOut

        public void serverToProxyResponseTimedOut()
        Specified by:
        serverToProxyResponseTimedOut in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        serverToProxyResponseTimedOut in class org.littleshoot.proxy.HttpFiltersAdapter
      • captureQueryParameters

        protected void captureQueryParameters​(io.netty.handler.codec.http.HttpRequest httpRequest)
      • captureRequestHeaderSize

        protected void captureRequestHeaderSize​(io.netty.handler.codec.http.HttpRequest httpRequest)
      • captureRequestCookies

        protected void captureRequestCookies​(io.netty.handler.codec.http.HttpRequest httpRequest)
      • captureRequestHeaders

        protected void captureRequestHeaders​(io.netty.handler.codec.http.HttpRequest httpRequest)
      • captureTrailingHeaders

        protected void captureTrailingHeaders​(io.netty.handler.codec.http.LastHttpContent lastHttpContent)
      • captureHeaders

        protected void captureHeaders​(io.netty.handler.codec.http.HttpHeaders headers)
      • captureRequestContent

        protected void captureRequestContent​(io.netty.handler.codec.http.HttpRequest httpRequest,
                                             byte[] fullMessage)
      • captureResponseContent

        protected void captureResponseContent​(io.netty.handler.codec.http.HttpResponse httpResponse,
                                              byte[] fullMessage)
      • captureResponse

        protected void captureResponse​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureResponseMimeType

        protected void captureResponseMimeType​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureResponseCookies

        protected void captureResponseCookies​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureResponseHeaderSize

        protected void captureResponseHeaderSize​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureResponseHeaders

        protected void captureResponseHeaders​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureRedirectUrl

        protected void captureRedirectUrl​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureRequestSize

        protected void captureRequestSize​(io.netty.handler.codec.http.HttpContent httpContent)
        Adds the size of this httpContent to the requestBodySize.
        Parameters:
        httpContent - HttpContent to size
      • captureResponseSize

        protected void captureResponseSize​(io.netty.handler.codec.http.HttpContent httpContent)
        Adds the size of this httpContent to the responseBodySize.
        Parameters:
        httpContent - HttpContent to size
      • captureConnectTiming

        protected void captureConnectTiming()
        Populates ssl and connect timing info in the HAR if an entry for this client and server exist in the cache.
      • populateAddressFromCache

        protected void populateAddressFromCache​(io.netty.handler.codec.http.HttpRequest httpRequest)
        Populates the serverIpAddress field of the harEntry using the internal hostname->IP address cache.
        Parameters:
        httpRequest - HTTP request to take the hostname from
      • proxyToServerResolutionStarted

        public java.net.InetSocketAddress proxyToServerResolutionStarted​(java.lang.String resolvingServerHostAndPort)
        Specified by:
        proxyToServerResolutionStarted in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerResolutionStarted in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerResolutionFailed

        public void proxyToServerResolutionFailed​(java.lang.String hostAndPort)
        Specified by:
        proxyToServerResolutionFailed in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerResolutionFailed in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerResolutionSucceeded

        public void proxyToServerResolutionSucceeded​(java.lang.String serverHostAndPort,
                                                     java.net.InetSocketAddress resolvedRemoteAddress)
        Specified by:
        proxyToServerResolutionSucceeded in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerResolutionSucceeded in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerConnectionQueued

        public void proxyToServerConnectionQueued()
        Specified by:
        proxyToServerConnectionQueued in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerConnectionQueued in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerConnectionStarted

        public void proxyToServerConnectionStarted()
        Specified by:
        proxyToServerConnectionStarted in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerConnectionStarted in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerConnectionFailed

        public void proxyToServerConnectionFailed()
        Specified by:
        proxyToServerConnectionFailed in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerConnectionFailed in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerConnectionSucceeded

        public void proxyToServerConnectionSucceeded​(io.netty.channel.ChannelHandlerContext serverCtx)
        Specified by:
        proxyToServerConnectionSucceeded in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerConnectionSucceeded in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerRequestSending

        public void proxyToServerRequestSending()
        Specified by:
        proxyToServerRequestSending in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerRequestSending in class org.littleshoot.proxy.HttpFiltersAdapter
      • proxyToServerRequestSent

        public void proxyToServerRequestSent()
        Specified by:
        proxyToServerRequestSent in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        proxyToServerRequestSent in class org.littleshoot.proxy.HttpFiltersAdapter
      • serverToProxyResponseReceiving

        public void serverToProxyResponseReceiving()
        Specified by:
        serverToProxyResponseReceiving in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        serverToProxyResponseReceiving in class org.littleshoot.proxy.HttpFiltersAdapter
      • serverToProxyResponseReceived

        public void serverToProxyResponseReceived()
        Specified by:
        serverToProxyResponseReceived in interface org.littleshoot.proxy.HttpFilters
        Overrides:
        serverToProxyResponseReceived in class org.littleshoot.proxy.HttpFiltersAdapter