Class HttpFiltersChain.Chained
- All Implemented Interfaces:
HttpFilters
- Enclosing class:
HttpFiltersChain
-
Method Summary
Modifier and TypeMethodDescriptionThe backoff between this request's connection attempts when a chained proxy (or the direct fallback) fails and the next route theChainedProxyManageroffered is tried, instead of the server's (HttpProxyServerBootstrap.withChainedProxyRetryBackoff(RetryBackoff)).clientToProxyRequest(HttpObject httpObject) Filters requests on their way from the client to the proxy.voidexchangeEnded(boolean completed) Called exactly once when this exchange is over, however it ended, so per-exchange resources (a concurrency permit, a span, a temporary file) can be released: afterHttpFilters.proxyToClientResponseSent(org.microproxy.http.HttpResponse, org.microproxy.ResponseSource)for a response written in full, whoever made it (the server, the proxy's failure answer, a filter's short-circuit, the cache); for aCONNECTthat became a byte tunnel, or a request upgraded with101(WebSocket), when the tunnel closes; for an interceptedCONNECT, once interception starts: the requests inside the session are exchanges of their own; when the exchange was abandoned: the client disconnected, the server failed half-way through the response, a filter returnednull, a filter or the proxy threw, or the proxy was stopped.filterWebSocketFrame(WebSocketFrame frame, boolean fromClient) Rewrites or drops a WebSocket frame on an upgraded connection, afterHttpFilters.webSocketFrameReceived(WebSocketFrame, boolean)has seen it.filterWebSocketMessage(WebSocketMessage message, boolean fromClient) Rewrites or drops a whole WebSocket message on an upgraded connection.filterWebSocketMessages(WebSocketMessage message, boolean fromClient) The messages to send in place ofmessage, in order.members()Returns the member filters, in order.proxyToClientResponse(HttpObject httpObject) Filters responses on their way from the proxy to the client.voidproxyToClientResponseSent(HttpResponse response, ResponseSource source) Called once the whole response has been written to the client, whoever made it: the server, the proxy, a filter or the cache.booleanWhether this CONNECT request may be intercepted when aMitmManageris configured.booleanproxyToServerAllowMitm(ClientHello clientHello) Whether this CONNECT (or transparent TLS connection) may be intercepted, now that the client's TLSClientHellois known: return false to tunnel the bytes untouched, so the client sees the real server's certificate.booleanFor a CONNECT that is being intercepted but whose server cannot be reached: return true to intercept it anyway, with a certificate made from the requested host name alone, so these filters can answer the requests inside the session (from a cache, for example).voidCalled when an upstream connection attempt fails.voidCalled before the upstream TLS handshake starts.voidCalled before an upstream TCP connection attempt starts.voidproxyToServerConnectionSucceeded(FullFlowContext serverContext) Called once the connection to the server (or chained proxy) is ready for traffic.The connect timeout for this request's connection attempts: to the server, or to each chained proxy tried.proxyToServerFailure(ProxyFailure failure) Called when the proxy is about to answer this request itself because offailure(the server could not be reached, timed out or answered badly, the request was refused, ...).When the proxy runs its TLS handshake with the server for thisCONNECT, which it intercepts, instead of what theProtocolPolicyof the client's protocol says (ProtocolPolicy.mitmServerHandshake()):MitmServerHandshake.DEFERREDafter answering it and reading the client's ClientHello,MitmServerHandshake.EAGERbefore answering it.proxyToServerRequest(HttpObject httpObject) Filters requests on their way from the proxy to the server, after the proxy has rewritten headers.voidCalled just before the request head is written to the server.voidCalled after the complete request, including its body, has been written to the server.voidproxyToServerResolutionFailed(String hostAndPort) Called when the upstream host name cannot be resolved.proxyToServerResolutionStarted(String hostAndPort) Called before the server's host name is resolved.voidproxyToServerResolutionSucceeded(String serverHostAndPort, InetSocketAddress resolvedRemoteAddress) Called after the upstream host name is resolved.The TLS handshake timeout for this request's upstream handshakes: with the server when the proxy speaks TLS to it (an interceptedCONNECT, an absolutehttps://URL, HTTP/2 to the server), and with each TLS chained proxy tried (https://andh2://ones), including the server's handshake inside a tunnel through one.proxyToServerTlsIdentity(String serverHostAndPort) The TLS identity of this request's connection toserverHostAndPort: the server name sent as SNI and the host the server's certificate is verified against, when they are not the request's host, e.g. for a route that dials an IP address or an internal load balancer (HttpFilters.proxyToServerResolutionStarted(java.lang.String), a resolver, a chained proxy) while the service presents a certificate for its public name.intrequestBufferSizeInBytes(HttpRequest request) Asks for this request to be buffered, beforeHttpFilters.clientToProxyRequest(org.microproxy.http.HttpObject)sees it: return a positive size to receive the head and body as oneFullHttpRequest, or 0 to stream.intresponseBufferSizeInBytes(HttpResponse response) Asks for this response to be buffered, after seeing its head: return a positive size to receive the head and body as oneFullHttpResponseinHttpFilters.serverToProxyResponse(org.microproxy.http.HttpObject), or 0 to stream.serverToProxyResponse(HttpObject httpObject) Filters responses on their way from the server to the proxy.voidCalled when the server has finished sending a response.voidCalled when the server begins sending a response.voidCalled when the server did not respond within the idle timeout.voidwebSocketFrameReceived(Supplier<byte[]> frameBytes, boolean fromClient) LittleProxy-compatible form ofHttpFilters.webSocketFrameReceived(WebSocketFrame, boolean): supplies the raw frame bytes as on the wire (header and still-masked payload).voidwebSocketFrameReceived(WebSocketFrame frame, boolean fromClient) Called for every WebSocket frame relayed after this request was upgraded (101 Switching ProtocolswithUpgrade: websocket), including inside intercepted TLS sessions.
-
Method Details
-
members
Returns the member filters, in order.- Returns:
- the member filters, in order
-
requestBufferSizeInBytes
Description copied from interface:HttpFiltersAsks for this request to be buffered, beforeHttpFilters.clientToProxyRequest(org.microproxy.http.HttpObject)sees it: return a positive size to receive the head and body as oneFullHttpRequest, or 0 to stream. A body larger than the size is answered with413. Not consulted forCONNECT, or when the source already buffers.- Specified by:
requestBufferSizeInBytesin interfaceHttpFilters- Parameters:
request- the request being handled- Returns:
- the requested body buffer limit in bytes, or zero to stream
-
clientToProxyRequest
Description copied from interface:HttpFiltersFilters requests on their way from the client to the proxy. Return a response to answer the client directly ("short-circuit") without contacting the server; only the return value for the request head is honoured.- Specified by:
clientToProxyRequestin interfaceHttpFilters- Parameters:
httpObject- the request head or body piece- Returns:
- a short-circuit response, or
nullto continue forwarding
-
proxyToServerRequest
Description copied from interface:HttpFiltersFilters requests on their way from the proxy to the server, after the proxy has rewritten headers. Return a response to short-circuit; only the return value for the request head is honoured.- Specified by:
proxyToServerRequestin interfaceHttpFilters- Parameters:
httpObject- the request head or body piece- Returns:
- a short-circuit response, or
nullto continue forwarding
-
proxyToServerRequestSending
public void proxyToServerRequestSending()Description copied from interface:HttpFiltersCalled just before the request head is written to the server.- Specified by:
proxyToServerRequestSendingin interfaceHttpFilters
-
proxyToServerRequestSent
public void proxyToServerRequestSent()Description copied from interface:HttpFiltersCalled after the complete request, including its body, has been written to the server.- Specified by:
proxyToServerRequestSentin interfaceHttpFilters
-
serverToProxyResponse
Description copied from interface:HttpFiltersFilters responses on their way from the server to the proxy. Return the (possibly modified or replaced) object, ornullto abort and disconnect the client. ACONNECT's200 Connection established, which the proxy makes once the server is connected, comes here too (then toHttpFilters.proxyToClientResponse(org.microproxy.http.HttpObject)), as the server's acceptance: a filter may turn it into a refusal. Not withHttpProxyServerBootstrap.withLittleProxyCompatibility(boolean), as in LittleProxy.- Specified by:
serverToProxyResponsein interfaceHttpFilters- Parameters:
httpObject- the response head or body piece- Returns:
- the object to forward, or
nullto abort the exchange
-
responseBufferSizeInBytes
Description copied from interface:HttpFiltersAsks for this response to be buffered, after seeing its head: return a positive size to receive the head and body as oneFullHttpResponseinHttpFilters.serverToProxyResponse(org.microproxy.http.HttpObject), or 0 to stream. UnlikeHttpFiltersSource.getMaximumResponseBufferSizeInBytes(), a body larger than the size is not an error: it is streamed through as usual. Ignored when the source already buffers.- Specified by:
responseBufferSizeInBytesin interfaceHttpFilters- Parameters:
response- the response being handled- Returns:
- the requested body buffer limit in bytes, or zero to stream
-
serverToProxyResponseTimedOut
public void serverToProxyResponseTimedOut()Description copied from interface:HttpFiltersCalled when the server did not respond within the idle timeout.- Specified by:
serverToProxyResponseTimedOutin interfaceHttpFilters
-
proxyToServerFailure
Description copied from interface:HttpFiltersCalled when the proxy is about to answer this request itself because offailure(the server could not be reached, timed out or answered badly, the request was refused, ...). Return a response to send instead of the proxy's default, ornull. It is framed by the proxy and passesHttpFilters.proxyToClientResponse(org.microproxy.http.HttpObject)like any proxy-made response. Filters are asked before theFailureResponder; the more specific callbacks (HttpFilters.proxyToServerResolutionFailed(java.lang.String),HttpFilters.proxyToServerConnectionFailed(),HttpFilters.serverToProxyResponseTimedOut()) are still called as well, before this one.Not called when the failure happens after the response has started (the client connection is closed instead), or for requests the proxy could not parse.
- Specified by:
proxyToServerFailurein interfaceHttpFilters- Parameters:
failure- the proxy failure to answer- Returns:
- a replacement failure response, or
nullfor the default
-
serverToProxyResponseReceiving
public void serverToProxyResponseReceiving()Description copied from interface:HttpFiltersCalled when the server begins sending a response.- Specified by:
serverToProxyResponseReceivingin interfaceHttpFilters
-
serverToProxyResponseReceived
public void serverToProxyResponseReceived()Description copied from interface:HttpFiltersCalled when the server has finished sending a response.- Specified by:
serverToProxyResponseReceivedin interfaceHttpFilters
-
proxyToClientResponse
Description copied from interface:HttpFiltersFilters responses on their way from the proxy to the client. Return the (possibly modified) object, ornullto abort and disconnect the client.This also sees the responses the proxy answers with itself, its error responses and the short-circuit responses returned from earlier hooks, as the
ProtocolPolicyof the client's protocol says (ProtocolPolicy.generatedResponses()): by default a replacement is sent; it may be limited to changes in place (GeneratedResponses.IN_PLACE), or keep them from this hook (GeneratedResponses.SKIP).FlowContext.responseSource()says where the response came from. The proxy's200to aCONNECTpassesHttpFilters.serverToProxyResponse(org.microproxy.http.HttpObject)and this hook (unlessProtocolPolicy.filterConnectAnswer()is off); its407challenge reaches no filter. To change the proxy's own error pages, useHttpFilters.proxyToServerFailure(org.microproxy.ProxyFailure)or aFailureResponder.- Specified by:
proxyToClientResponsein interfaceHttpFilters- Parameters:
httpObject- the response head or body piece- Returns:
- the object to send, or
nullto abort the exchange
-
proxyToClientResponseSent
Description copied from interface:HttpFiltersCalled once the whole response has been written to the client, whoever made it: the server, the proxy, a filter or the cache.FlowContext.timings()then covers the whole exchange. Not called when the exchange was aborted or failed half-way through the response, or for the407challenge sent before filters are created.- Specified by:
proxyToClientResponseSentin interfaceHttpFilters- Parameters:
response- the response head as it was sent (after every filter)source- where it came from, as reported toActivityTracker.responseSentToClient(FlowContext, HttpResponse, ResponseSource)
-
exchangeEnded
public void exchangeEnded(boolean completed) Description copied from interface:HttpFiltersCalled exactly once when this exchange is over, however it ended, so per-exchange resources (a concurrency permit, a span, a temporary file) can be released:- after
HttpFilters.proxyToClientResponseSent(org.microproxy.http.HttpResponse, org.microproxy.ResponseSource)for a response written in full, whoever made it (the server, the proxy's failure answer, a filter's short-circuit, the cache); - for a
CONNECTthat became a byte tunnel, or a request upgraded with101(WebSocket), when the tunnel closes; - for an intercepted
CONNECT, once interception starts: the requests inside the session are exchanges of their own; - when the exchange was abandoned: the client disconnected, the server failed half-way
through the response, a filter returned
null, a filter or the proxy threw, or the proxy was stopped.
It runs on the connection's thread before the next request on the connection is read. Exceptions it throws are logged and ignored.
- Specified by:
exchangeEndedin interfaceHttpFilters- Parameters:
completed- whether the response was written in full (HttpFilters.proxyToClientResponseSent(org.microproxy.http.HttpResponse, org.microproxy.ResponseSource)was called)
- after
-
proxyToServerResolutionStarted
Description copied from interface:HttpFiltersCalled before the server's host name is resolved. Return an address to skip resolution and connect there instead.- Specified by:
proxyToServerResolutionStartedin interfaceHttpFilters- Parameters:
hostAndPort- the destination host and port being resolved- Returns:
- the address to connect to, or
nullto resolve normally
-
proxyToServerResolutionFailed
Description copied from interface:HttpFiltersCalled when the upstream host name cannot be resolved.- Specified by:
proxyToServerResolutionFailedin interfaceHttpFilters- Parameters:
hostAndPort- the destination host and port, ornullwhen unavailable
-
proxyToServerResolutionSucceeded
public void proxyToServerResolutionSucceeded(String serverHostAndPort, InetSocketAddress resolvedRemoteAddress) Description copied from interface:HttpFiltersCalled after the upstream host name is resolved.- Specified by:
proxyToServerResolutionSucceededin interfaceHttpFilters- Parameters:
serverHostAndPort- the requested server host and portresolvedRemoteAddress- the resolved address to connect to
-
proxyToServerConnectTimeout
Description copied from interface:HttpFiltersThe connect timeout for this request's connection attempts: to the server, or to each chained proxy tried.null(the default), zero or a negative duration keeps the server's (HttpProxyServerBootstrap.withConnectTimeout(int)). Asked when the request needs a new connection, afterHttpFilters.proxyToServerRequest(org.microproxy.http.HttpObject); a request that reuses a connection makes none. It bounds the TCP connect only, not name resolution or TLS handshakes (HttpFilters.proxyToServerTlsHandshakeTimeout()). In aHttpFiltersChainthe shortest timeout wins.- Specified by:
proxyToServerConnectTimeoutin interfaceHttpFilters- Returns:
- the connect timeout override, or
nullfor the server setting
-
proxyToServerTlsHandshakeTimeout
Description copied from interface:HttpFiltersThe TLS handshake timeout for this request's upstream handshakes: with the server when the proxy speaks TLS to it (an interceptedCONNECT, an absolutehttps://URL, HTTP/2 to the server), and with each TLS chained proxy tried (https://andh2://ones), including the server's handshake inside a tunnel through one.null(the default), zero or a negative duration keeps the server's (HttpProxyServerBootstrap.withTlsHandshakeTimeout(java.time.Duration)); a request cannot turn the limit off. Asked when the request needs a new connection, afterHttpFilters.proxyToServerRequest(org.microproxy.http.HttpObject); a request that reuses a connection makes no handshake. A handshake that runs out of time fails the attempt withProxyFailure.TlsFailed(aSocketTimeoutExceptioncause, response flagUF), and the next chained proxy, if any, is tried, as after other failures. In aHttpFiltersChainthe shortest timeout wins.Upstream HTTP/3 (QUIC) handshakes keep
Http3Options.upstreamHandshakeTimeout(): their connections are shared by every client, and one that is not made in time does not fail the request but sends it over TCP, whose TLS handshake this timeout then bounds.- Specified by:
proxyToServerTlsHandshakeTimeoutin interfaceHttpFilters- Returns:
- the TLS handshake timeout override, or
nullfor the server setting
-
proxyToServerMitmHandshake
Description copied from interface:HttpFiltersWhen the proxy runs its TLS handshake with the server for thisCONNECT, which it intercepts, instead of what theProtocolPolicyof the client's protocol says (ProtocolPolicy.mitmServerHandshake()):MitmServerHandshake.DEFERREDafter answering it and reading the client's ClientHello,MitmServerHandshake.EAGERbefore answering it.null(the default) keeps the policy's. Asked once the proxy has decided to intercept theCONNECT, after proxy authentication,HttpFilters.clientToProxyRequest(org.microproxy.http.HttpObject)andHttpFilters.proxyToServerAllowMitm(), so the choice can depend on the authenticated user (FlowContext.getClientDetails()) or anything the request says. In aHttpFiltersChainthe first filter that returns a choice wins.- Specified by:
proxyToServerMitmHandshakein interfaceHttpFilters- Returns:
- when the server's handshake runs, or
nullfor the policy's choice
-
chainedProxyRetryBackoff
Description copied from interface:HttpFiltersThe backoff between this request's connection attempts when a chained proxy (or the direct fallback) fails and the next route theChainedProxyManageroffered is tried, instead of the server's (HttpProxyServerBootstrap.withChainedProxyRetryBackoff(RetryBackoff)).null(the default) keeps the server's;RetryBackoff.none()tries the next route at once. Asked when an attempt has failed and another route remains, so a request that connects on its first attempt never asks. The server's limits apply to it too: no wait before the first attempt or after the last, the policy's budget of waiting in all (by default at most 30 seconds or the connect timeout; seeRetryBackoff.withBudget(java.time.Duration)andRetryBackoff.unbudgeted()), and a client that leaves ends the wait. In aHttpFiltersChainthe first filter that returns a backoff wins.- Specified by:
chainedProxyRetryBackoffin interfaceHttpFilters- Returns:
- the retry backoff override, or
nullfor the server setting
-
proxyToServerConnectionStarted
public void proxyToServerConnectionStarted()Description copied from interface:HttpFiltersCalled before an upstream TCP connection attempt starts.- Specified by:
proxyToServerConnectionStartedin interfaceHttpFilters
-
proxyToServerConnectionSSLHandshakeStarted
public void proxyToServerConnectionSSLHandshakeStarted()Description copied from interface:HttpFiltersCalled before the upstream TLS handshake starts.- Specified by:
proxyToServerConnectionSSLHandshakeStartedin interfaceHttpFilters
-
proxyToServerConnectionFailed
public void proxyToServerConnectionFailed()Description copied from interface:HttpFiltersCalled when an upstream connection attempt fails.- Specified by:
proxyToServerConnectionFailedin interfaceHttpFilters
-
proxyToServerConnectionSucceeded
Description copied from interface:HttpFiltersCalled once the connection to the server (or chained proxy) is ready for traffic.- Specified by:
proxyToServerConnectionSucceededin interfaceHttpFilters- Parameters:
serverContext- the server connection context
-
proxyToServerAllowMitm
public boolean proxyToServerAllowMitm()Description copied from interface:HttpFiltersWhether this CONNECT request may be intercepted when aMitmManageris configured. Return false to tunnel the bytes untouched instead.- Specified by:
proxyToServerAllowMitmin interfaceHttpFilters- Returns:
- whether this CONNECT may be intercepted
-
proxyToServerAllowMitm
Description copied from interface:HttpFiltersWhether this CONNECT (or transparent TLS connection) may be intercepted, now that the client's TLSClientHellois known: return false to tunnel the bytes untouched, so the client sees the real server's certificate. Called once the client has sent itsClientHello, afterHttpFilters.proxyToServerAllowMitm(), the host rules (HttpProxyServerBootstrap.withIgnoreHosts(java.lang.String...),HttpProxyServerBootstrap.withAllowHosts(java.lang.String...)) andMitmManager.shouldIntercept(org.microproxy.ClientHello, org.microproxy.FlowContext)have allowed interception; not called for clients that do not speak TLS. True by default.- Specified by:
proxyToServerAllowMitmin interfaceHttpFilters- Parameters:
clientHello- the client's ClientHello, with its server name (SNI) and ALPN protocols- Returns:
- whether the connection may be intercepted
-
proxyToServerAllowOfflineMitm
public boolean proxyToServerAllowOfflineMitm()Description copied from interface:HttpFiltersFor a CONNECT that is being intercepted but whose server cannot be reached: return true to intercept it anyway, with a certificate made from the requested host name alone, so these filters can answer the requests inside the session (from a cache, for example). Those requests fail as usual if they do need the server.- Specified by:
proxyToServerAllowOfflineMitmin interfaceHttpFilters- Returns:
- whether interception may proceed without an upstream connection
-
proxyToServerTlsIdentity
Description copied from interface:HttpFiltersThe TLS identity of this request's connection toserverHostAndPort: the server name sent as SNI and the host the server's certificate is verified against, when they are not the request's host, e.g. for a route that dials an IP address or an internal load balancer (HttpFilters.proxyToServerResolutionStarted(java.lang.String), a resolver, a chained proxy) while the service presents a certificate for its public name.null(the default) keeps both derived from the request's host. The address dialled is not affected, nor is the TLS with a chained proxy itself (ChainedProxy.requiresEncryption()).Asked for requests that reach the server over TLS (intercepted sessions, TLS origination, a reverse proxy's
https://upstream) before a server connection is chosen, and for an interceptedCONNECTbefore the proxy's handshake with its target. A connection made with one identity serves only requests with the same identity: it is never reused, pooled or coalesced (RFC 9113 section 9.1.1) for another, and a request with an identity does not go over HTTP/3. The certificate is still validated with the MITM manager's trust; only the names change. In aHttpFiltersChainthe first member that returns an identity wins.- Specified by:
proxyToServerTlsIdentityin interfaceHttpFilters- Parameters:
serverHostAndPort- the server'shost:port- Returns:
- the identity, or
nullfor the default
-
webSocketFrameReceived
Description copied from interface:HttpFiltersCalled for every WebSocket frame relayed after this request was upgraded (101 Switching ProtocolswithUpgrade: websocket), including inside intercepted TLS sessions. Frames are observed, not modified: they are forwarded unchanged after this returns. The two directions are relayed on separate virtual threads, so this may be called concurrently for client and server frames.Frames are only parsed when the filters class overrides one of the two
webSocketFrameReceivedmethods; otherwise upgraded connections are relayed as raw bytes.Frames whose payload exceeds
HttpProxyServerBootstrap.withMaxWebSocketFrameBufferSize(int)are streamed through and reported withWebSocketFrame.isTruncated()set.The default implementation delegates to the LittleProxy-compatible
HttpFilters.webSocketFrameReceived(Supplier, boolean).- Specified by:
webSocketFrameReceivedin interfaceHttpFilters- Parameters:
frame- the WebSocket framefromClient- true for client-to-server frames
-
webSocketFrameReceived
Description copied from interface:HttpFiltersLittleProxy-compatible form ofHttpFilters.webSocketFrameReceived(WebSocketFrame, boolean): supplies the raw frame bytes as on the wire (header and still-masked payload).- Specified by:
webSocketFrameReceivedin interfaceHttpFilters- Parameters:
frameBytes- the supplier of raw frame bytes, including the header and masked payloadfromClient- whether the frame came from the client
-
filterWebSocketFrame
Description copied from interface:HttpFiltersRewrites or drops a WebSocket frame on an upgraded connection, afterHttpFilters.webSocketFrameReceived(WebSocketFrame, boolean)has seen it. Returnframeto forward it unchanged, another frame (WebSocketFrame.withText(String),WebSocketFrame.text(String), ...) to send instead, ornullto drop it. The proxy masks frames it sends towards the server.- Frames are rewritten one at a time; a message split across continuation frames is seen
piece by piece.
HttpFilters.filterWebSocketMessage(org.microproxy.http.WebSocketMessage, boolean)sees whole messages. - When a filters class overrides this method, payloads compressed with permessage-deflate
(RFC 7692) arrive inflated, with RSV1 clear, and the proxy compresses what it forwards
again. The proxy keeps only permessage-deflate offers in the upgrade request's
Sec-WebSocket-Extensions, since it could not read frames of other extensions. - A frame larger than
HttpProxyServerBootstrap.withMaxWebSocketFrameBufferSize(int)arrives truncated: returning it streams it through,nulldiscards it, and a replacement frame is sent in its place. Compressed frames, and frames of a message thatHttpFilters.filterWebSocketMessage(org.microproxy.http.WebSocketMessage, boolean)will see, are buffered up toHttpProxyServerBootstrap.withMaxWebSocketMessageSize(int)instead. - Like the observer, this is called concurrently for client and server frames.
- Specified by:
filterWebSocketFramein interfaceHttpFilters- Parameters:
frame- the WebSocket framefromClient- true for client-to-server frames- Returns:
- the frame to forward, or
nullto drop it
- Frames are rewritten one at a time; a message split across continuation frames is seen
piece by piece.
-
filterWebSocketMessage
Description copied from interface:HttpFiltersRewrites or drops a whole WebSocket message on an upgraded connection. A text or binary message split across continuation frames arrives joined, and inflated when the connection uses permessage-deflate (RFC 7692). Returnmessageto forward it unchanged, another message (WebSocketMessage.withText(String),WebSocketMessage.text(String, boolean), ...) to send instead, ornullto drop it.- Messages are only joined when a filters class overrides this method or
HttpFilters.filterWebSocketMessages(org.microproxy.http.WebSocketMessage, boolean); otherwise frames are relayed one at a time. - With
HttpFilters.filterWebSocketFrame(org.microproxy.http.WebSocketFrame, boolean)as well, the frame hook sees each frame first, and this hook sees the message joined from what the frame hook returned. Control frames (ping, pong, close) that arrive between a message's frames reach the frame hook and are forwarded at once, without waiting for the message. - A message returned unchanged keeps the fragmentation it arrived with; any other message is sent as a single frame (masked towards the server, compressed when the sender's message was).
- A message larger than
HttpProxyServerBootstrap.withMaxWebSocketMessageSize(int), joined or inflated, fails the connection: both peers get a close frame with status 1009 (message too big). - Like the frame hooks, this is called concurrently for client and server messages.
- Specified by:
filterWebSocketMessagein interfaceHttpFilters- Parameters:
message- the whole messagefromClient- true for client-to-server messages- Returns:
- the message to forward, or
nullto drop it
- Messages are only joined when a filters class overrides this method or
-
filterWebSocketMessages
Description copied from interface:HttpFiltersThe messages to send in place ofmessage, in order. Each goes towards the server when itsWebSocketMessage.fromClient()is true and towards the client otherwise, so a filter can answer a message itself (message.withFromClient(!fromClient)) or send extra ones either way. An empty list drops the message.The default returns what
HttpFilters.filterWebSocketMessage(org.microproxy.http.WebSocketMessage, boolean)returns, if anything; override this one instead to send several messages.- Specified by:
filterWebSocketMessagesin interfaceHttpFilters- Parameters:
message- the whole messagefromClient- true for client-to-server messages- Returns:
- the messages to send
-