io.undertow.server.handlers.proxy

## Class ProxyHandler

- java.lang.Object
- - io.undertow.server.handlers.proxy.ProxyHandler

All Implemented Interfaces:
  HttpHandler

    public final class ProxyHandler
    extends Object
    implements HttpHandler

An HTTP handler which proxies content to a remote server.

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. This handler uses non blocking IO

Author:
  David M. Lloyd

### Nested Class Summary

Nested Classes
`static class` `ProxyHandler.Builder`

### Field Summary

Fields
`static String` `UTF_8`

### Constructor Summary

Constructors
Constructor and Description
`ProxyHandler(ProxyClient proxyClient, HttpHandler next)` Deprecated.
`ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next)` Deprecated.
`ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next, boolean rewriteHostHeader, boolean reuseXForwarded)` Deprecated.
`ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next, boolean rewriteHostHeader, boolean reuseXForwarded, int maxConnectionRetries)` Deprecated.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`ProxyHandler` `addRequestHeader(HttpString header, ExchangeAttribute attribute)` Deprecated.
`ProxyHandler` `addRequestHeader(HttpString header, String value)` Deprecated.
`ProxyHandler` `addRequestHeader(HttpString header, String attribute, ClassLoader classLoader)` Deprecated.
`static ProxyHandler.Builder` `builder()`
`Predicate` `getIdempotentRequestPredicate()`
`int` `getMaxConnectionRetries()`
`ProxyClient` `getProxyClient()`
`void` `handleRequest(HttpServerExchange exchange)` Handle the request.
`boolean` `isReuseXForwarded()`
`boolean` `isRewriteHostHeader()`
`ProxyHandler` `removeRequestHeader(HttpString header)` Deprecated.
`ProxyHandler` `setMaxConnectionRetries(int maxConnectionRetries)` Deprecated.
`ProxyHandler` `setReuseXForwarded(boolean reuseXForwarded)` Deprecated.
`ProxyHandler` `setRewriteHostHeader(boolean rewriteHostHeader)` Deprecated.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### UTF_8

    public static final String UTF_8

### Constructor Detail

#### ProxyHandler

    @Deprecated
    public ProxyHandler(ProxyClient proxyClient,
                                    int maxRequestTime,
                                    HttpHandler next)

Deprecated.

#### ProxyHandler

    @Deprecated
    public ProxyHandler(ProxyClient proxyClient,
                                    int maxRequestTime,
                                    HttpHandler next,
                                    boolean rewriteHostHeader,
                                    boolean reuseXForwarded)

Deprecated.

Parameters:
  `proxyClient` - the client to use to make the proxy call
  `maxRequestTime` - the maximum amount of time to allow the request to be processed
  `next` - the next handler in line
  `rewriteHostHeader` - 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.

#### ProxyHandler

    @Deprecated
    public ProxyHandler(ProxyClient proxyClient,
                                    int maxRequestTime,
                                    HttpHandler next,
                                    boolean rewriteHostHeader,
                                    boolean reuseXForwarded,
                                    int maxConnectionRetries)

Deprecated.

Parameters:
  `proxyClient` - the client to use to make the proxy call
  `maxRequestTime` - the maximum amount of time to allow the request to be processed
  `next` - the next handler in line
  `rewriteHostHeader` - 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.
  `maxConnectionRetries` -

#### ProxyHandler

    @Deprecated
    public ProxyHandler(ProxyClient proxyClient,
                                    HttpHandler next)

Deprecated.

### Method Detail

#### handleRequest

    public void handleRequest(HttpServerExchange exchange)
                       throws Exception

Description copied from interface: `HttpHandler`
Handle the request.

Specified by:
  `handleRequest` in interface `HttpHandler`
Parameters:
  `exchange` - the HTTP request/response exchange
Throws:
  `Exception`

#### addRequestHeader

    @Deprecated
    public ProxyHandler addRequestHeader(HttpString header,
                                                     ExchangeAttribute attribute)

Deprecated.
Adds a request header to the outgoing request. If the header resolves to null or an empty string it will not be added, however any existing header with the same name will be removed.

Parameters:
  `header` - The header name
  `attribute` - The header value attribute.
Returns:
  this

#### addRequestHeader

    @Deprecated
    public ProxyHandler addRequestHeader(HttpString header,
                                                     String value)

Deprecated.
Adds a request header to the outgoing request. If the header resolves to null or an empty string it will not be added, however any existing header with the same name will be removed.

Parameters:
  `header` - The header name
  `value` - The header value attribute.
Returns:
  this

#### addRequestHeader

    @Deprecated
    public ProxyHandler addRequestHeader(HttpString header,
                                                     String attribute,
                                                     ClassLoader classLoader)

Deprecated.
Adds a request header to the outgoing request. If the header resolves to null or an empty string it will not be added, however any existing header with the same name will be removed.

The attribute value will be parsed, and the resulting exchange attribute will be used to create the actual header value.

Parameters:
  `header` - The header name
  `attribute` - The header value attribute.
Returns:
  this

#### removeRequestHeader

    @Deprecated
    public ProxyHandler removeRequestHeader(HttpString header)

Deprecated.
Removes a request header

Parameters:
  `header` - the header
Returns:
  this

#### getProxyClient

    public ProxyClient getProxyClient()

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### setMaxConnectionRetries

    @Deprecated
    public ProxyHandler setMaxConnectionRetries(int maxConnectionRetries)

Deprecated.

#### isRewriteHostHeader

    public boolean isRewriteHostHeader()

#### setRewriteHostHeader

    @Deprecated
    public ProxyHandler setRewriteHostHeader(boolean rewriteHostHeader)

Deprecated.

#### isReuseXForwarded

    public boolean isReuseXForwarded()

#### setReuseXForwarded

    @Deprecated
    public ProxyHandler setReuseXForwarded(boolean reuseXForwarded)

Deprecated.

#### getMaxConnectionRetries

    public int getMaxConnectionRetries()

#### getIdempotentRequestPredicate

    public Predicate getIdempotentRequestPredicate()

#### builder

    public static ProxyHandler.Builder builder()