Package org.forgerock.json.resource.http
Class HttpContext
java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.json.resource.http.HttpContext
- All Implemented Interfaces:
org.forgerock.services.context.Context
public final class HttpContext
extends org.forgerock.services.context.AbstractContext
A
Context
containing information relating to the originating HTTP request.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Attribute in the serialized JSON form that holds the request headers.static final String
Attribute in the serialised JSON form that holds the HTTP method of the request.static final String
Attribute in the serialized JSON form that holds the query and/or form parameters.static final String
Attribute in the serialised JSON form that holds the full URI of the request, excluding anything beyond the path component (i.e., no query parameters).Fields inherited from class org.forgerock.services.context.AbstractContext
data
-
Constructor Summary
ConstructorDescriptionHttpContext
(JsonValue savedContext, ClassLoader classLoader) Restore from JSON representation. -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable list containing the values of the named HTTP request header.getHeaderAsString
(String name) Returns the first value of the named HTTP request header.Returns an unmodifiable map of the HTTP request headers.Returns the effective HTTP method, taking into account presence of theX-HTTP-Method-Override
header.getParameter
(String name) Returns an unmodifiable list containing the values of the named HTTP request parameter.getParameterAsString
(String name) Returns the first value of the named HTTP request parameter.Returns an unmodifiable map of the HTTP request parameters.getPath()
Returns the HTTP request path.Methods inherited from class org.forgerock.services.context.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
-
Field Details
-
ATTR_HEADERS
Attribute in the serialized JSON form that holds the request headers. -
ATTR_PARAMETERS
Attribute in the serialized JSON form that holds the query and/or form parameters. -
ATTR_METHOD
Attribute in the serialised JSON form that holds the HTTP method of the request. -
ATTR_PATH
Attribute in the serialised JSON form that holds the full URI of the request, excluding anything beyond the path component (i.e., no query parameters).
-
-
Constructor Details
-
HttpContext
Restore from JSON representation.- Parameters:
savedContext
- The JSON representation from which this context's attributes should be parsed. Must be a JSON Object that containsATTR_HEADERS
andATTR_PARAMETERS
attributes.classLoader
- The ClassLoader which can properly resolve the persisted class-name.
-
-
Method Details
-
getHeader
Returns an unmodifiable list containing the values of the named HTTP request header.- Parameters:
name
- The name of the HTTP request header.- Returns:
- An unmodifiable list containing the values of the named HTTP request header, which may be empty if the header is not present in the request.
-
getHeaderAsString
Returns the first value of the named HTTP request header.- Parameters:
name
- The name of the HTTP request header.- Returns:
- The first value of the named HTTP request header, or
null
if the header is not present in the request.
-
getHeaders
Returns an unmodifiable map of the HTTP request headers.- Returns:
- An unmodifiable map of the HTTP request headers.
-
getMethod
Returns the effective HTTP method, taking into account presence of theX-HTTP-Method-Override
header.- Returns:
- The effective HTTP method, taking into account presence of the
X-HTTP-Method-Override
header.
-
getParameter
Returns an unmodifiable list containing the values of the named HTTP request parameter.- Parameters:
name
- The name of the HTTP request parameter.- Returns:
- An unmodifiable list containing the values of the named HTTP request parameter, which may be empty if the parameter is not present in the request.
-
getParameterAsString
Returns the first value of the named HTTP request parameter.- Parameters:
name
- The name of the HTTP request parameter.- Returns:
- The first value of the named HTTP request parameter, or
null
if the parameter is not present in the request.
-
getParameters
Returns an unmodifiable map of the HTTP request parameters.- Returns:
- An unmodifiable map of the HTTP request parameters.
-
getPath
Returns the HTTP request path.- Returns:
- The HTTP request path.
-