public class StaticRequestFilter extends GenericFilter
form
field, which is included in an entity encoded in
application/x-www-form-urlencoded
format if request method is POST
, or
otherwise as (additional) query parameters in the URI.Modifier and Type | Class and Description |
---|---|
static class |
StaticRequestFilter.Heaplet
Creates and initializes a request filter in a heap environment.
|
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_RESTORE
By default, do not restore the original
Request back into exchange.request . |
logger, storage
Constructor and Description |
---|
StaticRequestFilter(String method)
Builds a new
StaticRequestFilter that will uses the given HTTP method on the resource. |
Modifier and Type | Method and Description |
---|---|
StaticRequestFilter |
addFormParameter(String name,
Expression value)
Adds a new form parameter using the given
key with the given Expression . |
StaticRequestFilter |
addHeaderValue(String key,
Expression value)
Adds a new header value using the given
key with the given Expression . |
void |
filter(Exchange exchange,
Handler next)
Filters the request and/or response of an exchange.
|
void |
setRestore(boolean restore)
Sets to false if this filter should not restore the original Request after execution.
|
void |
setUri(Expression uri)
Sets the target URI as an expression to allow dynamic URI construction.
|
void |
setVersion(String version)
Sets the new request message's version.
|
public static final boolean DEFAULT_RESTORE
Request
back into exchange.request
.public StaticRequestFilter(String method)
StaticRequestFilter
that will uses the given HTTP method on the resource.method
- The HTTP method to be performed on the resourcepublic void setUri(Expression uri)
uri
- target URI expressionpublic void setVersion(String version)
version
- Protocol version (e.g. "HTTP/1.1"
).public void setRestore(boolean restore)
restore
- true if restore is required, false otherwisepublic StaticRequestFilter addHeaderValue(String key, Expression value)
key
with the given Expression
. As headers are
multi-valued objects, it's perfectly legal to call this method multiple times with the same key.key
- Header namevalue
- Expression
that represents the value of the new headerpublic StaticRequestFilter addFormParameter(String name, Expression value)
key
with the given Expression
. As form parameters are
multi-valued objects, it's perfectly legal to call this method multiple times with the same key.name
- Form parameter namevalue
- Expression
that represents the value of the parameterpublic void filter(Exchange exchange, Handler next) throws HandlerException, IOException
Filter
exchange.request
contains the request to be filtered. To pass the request to the next filter or handler
in the chain, the filter calls next.handle(exchange)
. After this call,
exchange.response
contains the response that can be filtered.
This method may elect not to pass the request to the next filter or handler, and instead
handle the request itself. It can achieve this by merely avoiding a call to
next.handle(exchange)
and creating its own response object the exchange. The
filter is also at liberty to replace a response with another of its own after the call
to next.handle(exchange)
.
Important note: If an existing response exists in the exchange object
and the filter intends to replace it with its own, it must first check to see if the
existing response has an entity, and if it does, must call its close
method in
order to signal that the processing of the response from a remote server is complete.
exchange
- the exchange containing the request and response to filter.next
- the next filter or handler in the chain to handle the exchange.HandlerException
- if an exception occurred handling the exchange.IOException
- if an I/O exception occurred.Copyright © 2014 ForgeRock AS. All rights reserved.