org.littleshoot.proxy
Interface HttpFilters

All Known Implementing Classes:
HttpFiltersAdapter

public interface HttpFilters

Interface for objects that filter HttpObjects, including both requests and responses.

Multiple methods are defined, corresponding to different steps in the request processing lifecycle. Each of these methods is given the current object (request, response or chunk) and is allowed to modify it in place.

Because HTTP transfers can be chunked, for any given request or response, the filter methods may be called multiple times, once for the initial HttpRequest or HttpResponse, and once for each subsequent HttpContent. The last chunk will always be a LastHttpContent and can be checked for being last using ProxyUtils.isLastChunk(HttpObject).

HttpFiltersSource.getMaximumRequestBufferSizeInBytes() and HttpFiltersSource.getMaximumResponseBufferSizeInBytes() can be used to instruct the proxy to buffer the HttpObjects sent to all of its request/response filters, in which case it will buffer up to the specified limit and then send either complete HttpRequests or HttpResponses to the filter methods. When buffering, if the proxy receives more data than fits in the specified maximum bytes to buffer, the proxy will stop processing the request and respond with a 502 Bad Gateway error.

A new instance of HttpFilters is created for each request, so these objects can be stateful.


Method Summary
 io.netty.handler.codec.http.HttpResponse requestPost(io.netty.handler.codec.http.HttpObject httpObject)
          Filters requests on their way from the proxy to the server.
 io.netty.handler.codec.http.HttpResponse requestPre(io.netty.handler.codec.http.HttpObject httpObject)
          Filters requests on their way from the client to the proxy.
 io.netty.handler.codec.http.HttpObject responsePost(io.netty.handler.codec.http.HttpObject httpObject)
          Filters responses on their way from the proxy to the client.
 io.netty.handler.codec.http.HttpObject responsePre(io.netty.handler.codec.http.HttpObject httpObject)
          Filters responses on their way from the server to the proxy.
 

Method Detail

requestPre

io.netty.handler.codec.http.HttpResponse requestPre(io.netty.handler.codec.http.HttpObject httpObject)
Filters requests on their way from the client to the proxy.

Parameters:
httpObject -
Returns:
if you want to interrupted processing and return a response to the client, return it here, otherwise return null to continue processing as usual

requestPost

io.netty.handler.codec.http.HttpResponse requestPost(io.netty.handler.codec.http.HttpObject httpObject)
Filters requests on their way from the proxy to the server.

Parameters:
httpObject -
Returns:
if you want to interrupted processing and return a response to the client, return it here, otherwise return null to continue processing as usual

responsePre

io.netty.handler.codec.http.HttpObject responsePre(io.netty.handler.codec.http.HttpObject httpObject)
Filters responses on their way from the server to the proxy.

Parameters:
httpObject -
Returns:
the modified (or unmodified) HttpObject. Returning null will force a disconnect.

responsePost

io.netty.handler.codec.http.HttpObject responsePost(io.netty.handler.codec.http.HttpObject httpObject)
Filters responses on their way from the proxy to the client.

Parameters:
httpObject -
Returns:
the modified (or unmodified) HttpObject. Returning null will force a disconnect.


Copyright © 2009-2014 LittleShoot. All Rights Reserved.