public class ForwardedFilter extends Filter
Filter
that applies the X-Forwarded-Proto, X-Forwarded-Host, and
X-Forwarded-Port HTTP headers to the request's references.
These de facto standard headers are widely used by reverse proxies to
specify the scheme and port for which the request is forwarded. For example,
a reverse proxy might be accepting and terminating SSL (https) requests, but
will forward them to an unencrypted (http) server. This filter will make sure
that the request references (Request.getResourceRef()
,
Request.getRootRef()
, Request.getOriginalRef()
) will have the
correct URI scheme and port for the client's protocol.
Note that Request.getHostRef()
is left intact, as it is independently
determined by the Host HTTP header.
Support for X-Forwarded-For is handled elsewhere in Restlet. See
HttpServerHelper
and ClientInfo
.
Modifier and Type | Field and Description |
---|---|
static String |
X_FORWARDED_HOST_HEADER
The X-Forwarded-Host HTTP header.
|
static String |
X_FORWARDED_PORT_HEADER
The X-Forwarded-Port HTTP header.
|
static String |
X_FORWARDED_PROTO_HEADER
The X-Forwarded-Proto HTTP header.
|
Constructor and Description |
---|
ForwardedFilter()
Constructor.
|
ForwardedFilter(Context context)
Constructor.
|
ForwardedFilter(Context context,
Restlet next)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected int |
beforeHandle(Request request,
Response response) |
boolean |
isApplying()
True if we are applying the forwarded header values to references.
|
void |
setApplying(boolean isApplying) |
afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stop
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
public static final String X_FORWARDED_PROTO_HEADER
public static final String X_FORWARDED_HOST_HEADER
public static final String X_FORWARDED_PORT_HEADER
public ForwardedFilter()
public ForwardedFilter(Context context)
context
- The contextpublic boolean isApplying()
public void setApplying(boolean isApplying)
isApplying
- Whether we are applying the forwarded header values to referencesisApplying()
protected int beforeHandle(Request request, Response response)
beforeHandle
in class Filter
Copyright © 2009-2016 Three Crickets LLC.