public interface HttpFilters
Interface for objects that filter HttpObject
s, including both
requests and responses, and informs of different steps in request/response.
Multiple methods are defined, corresponding to different steps in the request processing lifecycle. Some of these methods is given the current object (request, response or chunk) and is allowed to modify it in place. Others provide a notification of when specific operations happen (i.e. connection in queue, DNS resolution, SSL handshaking and so forth).
Because HTTP transfers can be chunked, for any given request or response, the
filter methods that can modify request/response in place 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 HttpObject
s sent to all of its
request/response filters, in which case it will buffer up to the specified
limit and then send either complete HttpRequest
s or
HttpResponse
s 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.
To monitor (and time measure?) the different steps the request/response goes through, many informative methods are provided. Those steps are reported in the following order:
Modifier and Type | Method and Description |
---|---|
io.netty.handler.codec.http.HttpResponse |
clientToProxyRequest(io.netty.handler.codec.http.HttpObject httpObject)
Filters requests on their way from the client to the proxy.
|
io.netty.handler.codec.http.HttpObject |
proxyToClientResponse(io.netty.handler.codec.http.HttpObject httpObject)
Filters responses on their way from the proxy to the client.
|
void |
proxyToServerConnectionFailed()
Informs filter that proxy to server connection has failed.
|
void |
proxyToServerConnectionQueued()
Informs filter that proxy to server connection is in queue.
|
void |
proxyToServerConnectionSSLHandshakeStarted()
Informs filter that proxy to server ssl handshake is initiating.
|
void |
proxyToServerConnectionStarted()
Informs filter that proxy to server connection is initiating.
|
void |
proxyToServerConnectionSucceeded(io.netty.channel.ChannelHandlerContext serverCtx)
Informs filter that proxy to server connection has succeeded.
|
io.netty.handler.codec.http.HttpResponse |
proxyToServerRequest(io.netty.handler.codec.http.HttpObject httpObject)
Filters requests on their way from the proxy to the server.
|
void |
proxyToServerRequestSending()
Informs filter that proxy to server request is being sent.
|
void |
proxyToServerRequestSent()
Informs filter that the HTTP request, including any content, has been sent.
|
void |
proxyToServerResolutionFailed(String hostAndPort)
Informs filter that proxy to server DNS resolution failed for the specified host and port.
|
InetSocketAddress |
proxyToServerResolutionStarted(String resolvingServerHostAndPort)
Filter DNS resolution from proxy to server.
|
void |
proxyToServerResolutionSucceeded(String serverHostAndPort,
InetSocketAddress resolvedRemoteAddress)
Informs filter that proxy to server DNS resolution has happened.
|
io.netty.handler.codec.http.HttpObject |
serverToProxyResponse(io.netty.handler.codec.http.HttpObject httpObject)
Filters responses on their way from the server to the proxy.
|
void |
serverToProxyResponseReceived()
Informs filter that server to proxy response has been received.
|
void |
serverToProxyResponseReceiving()
Informs filter that server to proxy response is being received.
|
void |
serverToProxyResponseTimedOut()
Informs filter that a timeout occurred before the server response was received by the client.
|
io.netty.handler.codec.http.HttpResponse clientToProxyRequest(io.netty.handler.codec.http.HttpObject httpObject)
httpObject
- Client to Proxy HttpRequest (and HttpContent, if chunked)io.netty.handler.codec.http.HttpResponse proxyToServerRequest(io.netty.handler.codec.http.HttpObject httpObject)
httpObject
- Proxy to Server HttpRequest (and HttpContent, if chunked)void proxyToServerRequestSending()
void proxyToServerRequestSent()
io.netty.handler.codec.http.HttpObject serverToProxyResponse(io.netty.handler.codec.http.HttpObject httpObject)
httpObject
- Server to Proxy HttpResponse (and HttpContent, if chunked)void serverToProxyResponseTimedOut()
HttpProxyServerBootstrap.withIdleConnectionTimeout(int)
for information on setting the timeout.void serverToProxyResponseReceiving()
void serverToProxyResponseReceived()
io.netty.handler.codec.http.HttpObject proxyToClientResponse(io.netty.handler.codec.http.HttpObject httpObject)
httpObject
- Proxy to Client HttpResponse (and HttpContent, if chunked)void proxyToServerConnectionQueued()
InetSocketAddress proxyToServerResolutionStarted(String resolvingServerHostAndPort)
resolvingServerHostAndPort
- Server "HOST:PORT"void proxyToServerResolutionFailed(String hostAndPort)
hostAndPort
- hostname and port the proxy failed to resolvevoid proxyToServerResolutionSucceeded(String serverHostAndPort, InetSocketAddress resolvedRemoteAddress)
serverHostAndPort
- Server "HOST:PORT"resolvedRemoteAddress
- Address it was proxyToServerResolutionSucceeded tovoid proxyToServerConnectionStarted()
void proxyToServerConnectionSSLHandshakeStarted()
void proxyToServerConnectionFailed()
void proxyToServerConnectionSucceeded(io.netty.channel.ChannelHandlerContext serverCtx)
serverCtx
- the ChannelHandlerContext
used to connect to the serverCopyright © 2009–2017 LittleShoot. All rights reserved.