public final class ProxyHandler extends Object implements HttpHandler
This handler acts like a filter. The ProxyClient
has a chance to decide if it knows how to proxy the request. If it does then it will provide a connection that can used to connect to the remote server, otherwise the next handler will be invoked and the request will proceed as normal.
Modifier and Type | Class and Description |
---|---|
static class | ProxyHandler.Builder |
Constructor and Description |
---|
ProxyHandler(ProxyClient proxyClient, HttpHandler next) |
ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next) |
ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next, boolean rewriteHostHeader, boolean reuseXForwarded) |
Modifier and Type | Method and Description |
---|---|
ProxyHandler | addRequestHeader(HttpString header, ExchangeAttribute attribute) Adds a request header to the outgoing request. |
ProxyHandler | addRequestHeader(HttpString header, String value) Adds a request header to the outgoing request. |
ProxyHandler | addRequestHeader(HttpString header, String attribute, ClassLoader classLoader) Adds a request header to the outgoing request. |
ProxyClient | getProxyClient() |
void | handleRequest(HttpServerExchange exchange) Handle the request. |
ProxyHandler | removeRequestHeader(HttpString header) Removes a request header |
public static final String UTF_8
public ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next)
public ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next, boolean rewriteHostHeader, boolean reuseXForwarded)
proxyClient
- the client to use to make the proxy callmaxRequestTime
- the maximum amount of time to allow the request to be processednext
- the next handler in linerewriteHostHeader
- should the HOST header be rewritten to use the target host of the call.reuseXForwarded
- should any existing X-Forwarded-For header be used or should it be overwritten.public ProxyHandler(ProxyClient proxyClient, HttpHandler next)
public void handleRequest(HttpServerExchange exchange) throws Exception
HttpHandler
handleRequest
in interface HttpHandler
exchange
- the HTTP request/response exchangeException
public ProxyHandler addRequestHeader(HttpString header, ExchangeAttribute attribute)
header
- The header nameattribute
- The header value attribute.public ProxyHandler addRequestHeader(HttpString header, String value)
header
- The header namevalue
- The header value attribute.public ProxyHandler addRequestHeader(HttpString header, String attribute, ClassLoader classLoader)
The attribute value will be parsed, and the resulting exchange attribute will be used to create the actual header value.
header
- The header nameattribute
- The header value attribute.public ProxyHandler removeRequestHeader(HttpString header)
header
- the headerpublic ProxyClient getProxyClient()
Copyright © 2015 JBoss by Red Hat. All rights reserved.