Package org.microproxy
Class HttpFiltersChain
java.lang.Object
org.microproxy.HttpFiltersChain
- All Implemented Interfaces:
HttpFiltersSource
Runs several filters sources as one, in order. For each request every source may contribute
filters, and they form a pipeline:
- Request hooks run first to last; the first short-circuit response wins and later filters
do not see the request.
proxyToServerFailureworks the same way: the first response wins. - Response hooks (
serverToProxyResponse,proxyToClientResponse),filterWebSocketFrameandfilterWebSocketMessagealso run first to last, each receiving the previous one's result;nullaborts (or drops the frame or message). WithfilterWebSocketMessages, every message one filter returns goes through the next, in the direction it now travels. - Buffer sizes are the largest any filter asks for; the connect and TLS handshake timeouts are the shortest; the retry backoff is the first filter's that names one.
- Interception needs every filter's consent (both
proxyToServerAllowMitmhooks), whileproxyToServerAllowOfflineMitmneeds any one filter's. - The first filter that names a TLS identity (
proxyToServerTlsIdentity) sets it. - Notifications go to every filter;
exchangeEndedreaches every filter even when one of them throws.
So a cache placed last stores responses after earlier filters have rewritten them, and earlier filters see requests before the cache can answer them.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe filters of several sources for one request. -
Method Summary
Modifier and TypeMethodDescriptionfilterRequest(HttpRequest originalRequest, FlowContext flowContext) Returns the filters for a request, ornullto proxy it unfiltered.intWhen positive, request bodies are buffered (up to this many bytes) and filters receive a singleFullHttpRequest.intWhen positive, response bodies are buffered (up to this many bytes) and filters receive a singleFullHttpResponse.static HttpFiltersSourceof(HttpFiltersSource... sources) Chainssources, flattening nested chains.sources()Returns the chained sources, in order.
-
Method Details
-
of
Chainssources, flattening nested chains.- Parameters:
sources- the filter sources, in execution order- Returns:
- the combined filter source
-
sources
Returns the chained sources, in order.- Returns:
- the chained sources, in order
-
filterRequest
Description copied from interface:HttpFiltersSourceReturns the filters for a request, ornullto proxy it unfiltered.- Specified by:
filterRequestin interfaceHttpFiltersSource- Parameters:
originalRequest- a copy of the request as received from the clientflowContext- the client connection the request arrived on- Returns:
- the per-request filters, or
nullto leave the request unfiltered
-
getMaximumRequestBufferSizeInBytes
public int getMaximumRequestBufferSizeInBytes()Description copied from interface:HttpFiltersSourceWhen positive, request bodies are buffered (up to this many bytes) and filters receive a singleFullHttpRequest. Larger requests get413.- Specified by:
getMaximumRequestBufferSizeInBytesin interfaceHttpFiltersSource- Returns:
- the maximum request buffer size in bytes, or zero for streaming
-
getMaximumResponseBufferSizeInBytes
public int getMaximumResponseBufferSizeInBytes()Description copied from interface:HttpFiltersSourceWhen positive, response bodies are buffered (up to this many bytes) and filters receive a singleFullHttpResponse. Larger responses get502.- Specified by:
getMaximumResponseBufferSizeInBytesin interfaceHttpFiltersSource- Returns:
- the maximum response buffer size in bytes, or zero for streaming
-