Class ServerResponseCaptureFilter

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

    public class ServerResponseCaptureFilter
    extends org.littleshoot.proxy.HttpFiltersAdapter
    This filter captures responses from the server (headers and content). The filter can also decompress contents if desired. The filter can be used in one of three ways: (1) directly, by adding the filter to the filter chain; (2) by subclassing the filter and overriding its filter methods; or (3) by invoking the filter directly from within another filter (see HarCaptureFilter for an example of the latter).
    • Field Summary

      • Fields inherited from class org.littleshoot.proxy.HttpFiltersAdapter

        ctx, NOOP_FILTER, originalRequest
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerResponseCaptureFilter​(io.netty.handler.codec.http.HttpRequest originalRequest, boolean decompressEncodedContent)  
      ServerResponseCaptureFilter​(io.netty.handler.codec.http.HttpRequest originalRequest, io.netty.channel.ChannelHandlerContext ctx, boolean decompressEncodedContent)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void captureContentEncoding​(io.netty.handler.codec.http.HttpResponse httpResponse)  
      protected void captureFullResponseContents()  
      protected void captureTrailingHeaders​(io.netty.handler.codec.http.LastHttpContent lastContent)  
      protected void decompressContents()  
      java.lang.String getContentEncoding()  
      byte[] getFullResponseContents()
      Returns the contents of the entire response.
      io.netty.handler.codec.http.HttpResponse getHttpResponse()  
      byte[] getRawResponseContents()
      Returns the raw contents of the entire response, without decompression.
      io.netty.handler.codec.http.HttpHeaders getTrailingHeaders()  
      boolean isDecompressionSuccessful()  
      boolean isResponseCompressed()  
      io.netty.handler.codec.http.HttpObject serverToProxyResponse​(io.netty.handler.codec.http.HttpObject httpObject)  
      protected void storeResponseContent​(io.netty.handler.codec.http.HttpContent httpContent)  
      • Methods inherited from class org.littleshoot.proxy.HttpFiltersAdapter

        clientToProxyRequest, proxyToClientResponse, proxyToServerConnectionFailed, proxyToServerConnectionQueued, proxyToServerConnectionSSLHandshakeStarted, proxyToServerConnectionStarted, proxyToServerConnectionSucceeded, proxyToServerRequest, proxyToServerRequestSending, proxyToServerRequestSent, proxyToServerResolutionFailed, proxyToServerResolutionStarted, proxyToServerResolutionSucceeded, serverToProxyResponseReceived, serverToProxyResponseReceiving, serverToProxyResponseTimedOut
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ServerResponseCaptureFilter

        public ServerResponseCaptureFilter​(io.netty.handler.codec.http.HttpRequest originalRequest,
                                           boolean decompressEncodedContent)
      • ServerResponseCaptureFilter

        public ServerResponseCaptureFilter​(io.netty.handler.codec.http.HttpRequest originalRequest,
                                           io.netty.channel.ChannelHandlerContext ctx,
                                           boolean decompressEncodedContent)
    • Method Detail

      • 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
      • captureFullResponseContents

        protected void captureFullResponseContents()
      • decompressContents

        protected void decompressContents()
      • captureContentEncoding

        protected void captureContentEncoding​(io.netty.handler.codec.http.HttpResponse httpResponse)
      • captureTrailingHeaders

        protected void captureTrailingHeaders​(io.netty.handler.codec.http.LastHttpContent lastContent)
      • storeResponseContent

        protected void storeResponseContent​(io.netty.handler.codec.http.HttpContent httpContent)
      • getHttpResponse

        public io.netty.handler.codec.http.HttpResponse getHttpResponse()
      • getFullResponseContents

        public byte[] getFullResponseContents()
        Returns the contents of the entire response. If the contents were compressed, decompressEncodedContent is true, and decompression was successful, this method returns the decompressed contents.
        Returns:
        entire response contents, decompressed if possible
      • getRawResponseContents

        public byte[] getRawResponseContents()
        Returns the raw contents of the entire response, without decompression.
        Returns:
        entire response contents, without decompression
      • getTrailingHeaders

        public io.netty.handler.codec.http.HttpHeaders getTrailingHeaders()
      • isResponseCompressed

        public boolean isResponseCompressed()
      • isDecompressionSuccessful

        public boolean isDecompressionSuccessful()
        Returns:
        true if decompression is both enabled and successful
      • getContentEncoding

        public java.lang.String getContentEncoding()