Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http.server

public Class Request

extends Object
Class Inheritance
Imports
java.io.CharConversionException, .IOException, .InputStream, .Reader, .UnsupportedEncodingException, java.nio.charset.Charset, java.security.Principal, java.security.cert.X509Certificate, java.util.ArrayList, .List, .Locale, .Map, .Set, .TreeMap, java.util.concurrent.Executor, java.util.concurrent.atomic.AtomicLong, java.util.logging.Level, .Logger, javax.security.auth.Subject, org.glassfish.grizzly.Buffer, .Connection, .Grizzly, .ReadHandler, .ThreadCache, .WriteHandler, org.glassfish.grizzly.filterchain.FilterChainContext, org.glassfish.grizzly.http.Cookie, .Cookies, .HttpRequestPacket, .Method, .Note, .Protocol, org.glassfish.grizzly.http.io.InputBuffer, .NIOInputStream, .NIOReader, org.glassfish.grizzly.http.server.http2.PushBuilder, org.glassfish.grizzly.http.server.io.ServerInputBuffer, org.glassfish.grizzly.http.server.util.DateTimeFormatters, .Globals, .MappingData, .ParameterMap, .RequestUtils, .StringParser, org.glassfish.grizzly.http.util.Chunk, .DataChunk, .Header, .HttpDateFormat, .Parameters, org.glassfish.grizzly.localization.LogMessages, org.glassfish.grizzly.utils.Charsets

Wrapper object for the Coyote request.
Authors
Remy Maucherat, Craig R. McClanahan
Version
$Revision: 1.2 $ $Date: 2007/03/14 02:15:42 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
protected static interface

Field Summary

Modifier and TypeField and Description
protected final List<AfterServiceListener>
private static final ThreadCache.CachedTypeIndex<Request>
private MappingData
private final Request.PathData
protected Cookie[]
cookies

The set of cookies associated with this Request.

protected boolean
cookiesParsed

Cookies parsed flag.

protected FilterChainContext
protected static final Locale
defaultLocale

The default Locale if none are specified.

private int
dispatchDepth

The current application dispatch depth.

protected Object
dispatcherType

The current dispatcher type.

private static final Boolean
private static final String
private final Request.PathData
protected HttpServerFilter
protected final ServerInputBuffer
inputBuffer

The associated input buffer.

private final NIOInputStreamImpl
inputStream

NIOInputStream.

private String
private static final LocaleParser
protected final ArrayList<Locale>
locales

The preferred Locales associated with this Request.

protected boolean
localesParsed

Parse locales.

private static final Logger
private static final String
match

The match string for identifying a session ID parameter.

private static int
maxDispatchDepth

The maximum allowed application dispatch depth.

protected final ParameterMap
parameterMap

Hash map used in the getParametersMap method.

protected final Parameters
private StringParser
parser

The string parser we will use for parsing request lines.

private final Request.PathData
protected Cookies
private final NIOReaderImpl
reader

Reader.

protected HttpRequestPacket
request

HTTP Request Packet

private static final AtomicLong
protected Object
requestDispatcherPath

The current request dispatcher path.

protected boolean
requestedSessionCookie

Was the requested session ID received in a cookie?

protected String
requestedSessionId

The requested session ID (if any) for this request.

protected boolean
requestedSessionURL

Was the requested session ID received in a URL?

private RequestExecutorProvider
private final String
protected boolean
requestParametersParsed

Request parameters parsed flag.

protected final Response
response

The response with which this request is associated.

private String
scheme

The HTTP request scheme.

protected boolean
secure

Secure flag.

public static final String
SEND_FILE_ATTR

The value of this request attribute, as set by the developer must be a java.io.File that exists, is not a directory, and is readable.

public static final String
SEND_FILE_ENABLED_ATTR

Request attribute will be associated with a boolean value indicating whether or not it's possible to transfer a java.io.File using sendfile.

public static final String
SEND_FILE_START_OFFSET_ATTR

The value of this request attribute signifies the starting offset of the file transfer.

public static final String
SEND_FILE_WRITE_LEN_ATTR

The value of this request attribute signifies the total number of bytes to transfer.

private Session
protected String
protected SessionManager
protected boolean
sessionParsed

Session parsed flag.

protected Subject
subject

The Subject associated with the current AccessControllerContext

protected Map<String, String>
trailers

Trailer headers, if any.

protected Principal
userPrincipal

User principal.

protected boolean
usingInputStream

Using stream flag.

protected boolean
usingReader

Using writer flag.

Constructor Summary

AccessConstructor and Description
public
Request()
Deprecated

Temporarily introduce public constructor to fix GRIZZLY-1782.

protected
Request(final Response response)

Method Summary

Modifier and TypeMethod and Description
public void
addAfterServiceListener(final AfterServiceListener
the listener, which will be notified, once Request processing will be finished.
listener
)

Add the listener, which will be notified, once Request processing will be finished.

public void
addCookie(Cookie
The new cookie
cookie
)

Add a Cookie to the set of Cookies associated with this Request.

public void
addLocale(Locale
The new preferred Locale
locale
)

Add a Locale to the set of preferred Locales for this Request.

public void
addParameter(String
Name of this request parameter
name
,
String[]
Corresponding values for this request parameter
values
)

Add a parameter name and corresponding set of values to this Request.

public static StringBuilder

Returns:

A StringBuilder object containing the appended reconstructed URL
appendRequestURL
(final Request request, final StringBuilder buffer)

Appends the reconstructed URL the client used to make the request.

public static StringBuffer

Returns:

A StringBuffer object containing the appended reconstructed URL
appendRequestURL
(final Request request, final StringBuffer buffer)

Appends the reconstructed URL the client used to make the request.

public boolean
areTrailersAvailable()

Returns: true if trailers are available to be accessed otherwise returns false.

public String

Returns:

the original session id
changeSessionId
()

Change the session id of the current session associated with this request and return the new session id.

private boolean
checkPostContentType(final String contentType)

public void
clearCookies()

Clear the collection of Cookies associated with this Request.

public void
clearHeaders()

Clear the collection of Headers associated with this Request.

public void
clearLocales()

Clear the collection of Locales associated with this Request.

public void
clearParameters()

Clear the collection of parameters associated with this Request.

protected void
configureSessionCookie(final Cookie
The session cookie to be configured
cookie
)

Configures the given session cookie.

public static Request
public NIOInputStream
createInputStream()

Create and return a NIOInputStream to read the content associated with this Request.

public static <
the Note type.
E
>
Note<E>

Returns:

the Note.
createNote
(final String
the Note name.
name
)

Create a named Note associated with this Request.

public int
decrementDispatchDepth()

Decrement the depth of application dispatch

protected Session
doGetSession(final boolean create)

public Object

Returns:

the specified request attribute if it exists; otherwise, return null.
getAttribute
(final String
Name of the request attribute to return
name
)

Return the specified request attribute if it exists; otherwise, return null.

public Set<String>
getAttributeNames()

Return the names of all request attributes for this Request, or an empty Set if there are none.

public String
getAuthorization()

Returns: the authorization credentials sent with this request.

public String
getAuthType()

Return the authentication type used for this Request.

public String
getCharacterEncoding()

Return the character encoding for this Request.

public Connection<?>
getConnection()

Returns: underlying connection used by the request

public int
getContentLength()

Return the content length for this Request.

public long
getContentLengthLong()

Return the content length for this Request represented by Java long type.

public String
getContentType()

Return the content type for this Request.

public FilterChainContext
public String

Returns:

a String specifying the portion of the request URI that indicates the context of the request
getContextPath
()

Returns the portion of the request URI that indicates the context of the request.

public Cookie[]
getCookies()

Return the set of Cookies received with this Request.

public long
getDateHeader(String
Name of the requested date header
name
)

Return the value of the specified date header, if any; otherwise return -1.

public long
getDateHeader(Header
the requested date Header
header
)

Return the value of the specified date header, if any; otherwise return -1.

public String

Returns:

the URL decoded request URI
getDecodedRequestURI
()

Get the decoded request URI.

public String
getHeader(String
Name of the requested header
name
)

Return the first value of the specified header, if any; otherwise, return null

public String
getHeader(final Header
the requested Header
header
)

Return the first value of the specified header, if any; otherwise, return null

public Iterable<String>
getHeaderNames()

Return the names of all headers received with this request.

public Iterable<String>
getHeaders(String
Name of the requested header
name
)

Return all of the values of the specified header, if any; otherwise, return an empty enumeration.

public Iterable<String>
getHeaders(final Header
the requested Header
header
)

Return all of the values of the specified header, if any; otherwise, return an empty enumeration.

public HttpServerFilter
getHttpFilter()

Returns: HttpServerFilter, which dispatched this request

public String

Returns:

a String containing the name or path of the HttpHandler being called, as specified in the request URL
getHttpHandlerPath
()

Returns the part of this request's URL that calls the HttpHandler.

public InputBuffer
getInputBuffer()

Returns: the InputBuffer associated with this request, which is the source for getInputStream(), getReader(), getNIOInputStream(), and getNIOReader()

public InputStream

Returns:

the NIOInputStream for this Request.
getInputStream
()

Return the InputStream for this Request.

public int
getIntHeader(String
Name of the requested header
name
)

Return the value of the specified header as an integer, or -1 if there is no such header for this request.

public int
getIntHeader(final Header
the requested Header
header
)

Return the value of the specified header as an integer, or -1 if there is no such header for this request.

public String

Returns:

The jroute id of this request, or null if this request does not carry any jroute id
getJrouteId
()

Gets the jroute id of this request, which may have been sent as a separate JROUTE cookie or appended to the session identifier encoded in the URI (if cookies have been disabled).

public String
getLocalAddr()

Returns the Internet Protocol (IP) address of the interface on which the request was received.

public Locale
getLocale()

Return the preferred Locale that the client will accept content in, based on the value for the first Accept-Language header that was encountered.

public List<Locale>
getLocales()

Return the set of preferred Locales that the client will accept content in, based on the values for any Accept-Language headers that were encountered.

public String
getLocalName()

Returns the host name of the Internet Protocol (IP) interface on which the request was received.

public int
getLocalPort()

Returns the Internet Protocol (IP) port number of the interface on which the request was received.

public static int
public Method
getMethod()

Return the HTTP request method used in this Request.

public NIOInputStream

Returns:

the NIOInputStream for this Request.
getNIOInputStream
()

Return the NIOInputStream for this Request.

public NIOReader

Returns:

NIOReader
getNIOReader
()

Returns the NIOReader associated with this Request.

public <E> E
getNote(final Note<E>
Note value to be returned
note
)

Return the Note value associated with this Request, or null if no such binding exists.

public Set<String>

Returns:

a Set containing the String names of all note bindings that exist for this request.
getNoteNames
()

Return a Set containing the String names of all note bindings that exist for this request.

public String
getParameter(final String
Name of the desired request parameter
name
)

Return the value of the specified request parameter, if any; otherwise, return null.

public Map<String, String[]>

Returns:

A java.util.Map containing parameter names as keys and parameter values as map values.
getParameterMap
()

Returns a java.util.Map of the parameters of this request.

public Set<String>
getParameterNames()

Return the names of all defined request parameters for this request.

public Parameters

Returns:

Parameters.
getParameters
()

Returns the low-level parameters holder for finer control over parameters.

public String[]
getParameterValues(String
Name of the desired request parameter
name
)

Return the defined values for the specified request parameter, if any; otherwise, return null.

public String

Returns:

a String specifying extra path information that comes after the HttpHandler path but before the query string in the request URL; or null if the URL does not have any extra path information
getPathInfo
()

Returns any extra path information associated with the URL the client sent when it made this request.

public Buffer

Returns:

The POST body of this request
getPostBody
(final int len)

Gets the POST body of this request.

public Protocol
getProtocol()

Return the protocol and version used to make this Request.

public String
getProtocolRequestId()

Returns: an empty string or identifier managed by the underlying protocol (HTTP2)

public String
getQueryString()

Returns: the query string associated with this request.

protected Cookies
getRawCookies()

TODO DOCS

public Reader

Returns:

the NIOReader associated with this Request.
getReader
()

Returns the Reader associated with this Request.

public String
getRemoteAddr()

Return the remote IP address making this Request.

public String
getRemoteHost()

Return the remote host name making this Request.

public int
getRemotePort()

Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.

public String
getRemoteUser()

Return the name of the remote user that has been authenticated for this Request.

public HttpRequestPacket
getRequest()

Returns: the Coyote request.

public String
getRequestedSessionId()

Return the session identifier included in this request, if any.

public Executor
getRequestExecutor()

Returns: the Executor responsible for notifying ReadHandler, WriteHandler associated with this Request processing.

public String
getRequestId()

Returns: identifier of the request generated by this class.

public String
getRequestURI()

Return the request URI for this request.

public StringBuilder

Returns:

A StringBuffer object containing the reconstructed URL
getRequestURL
()

Reconstructs the URL the client used to make the request.

public Response
getResponse()

Returns: the Response with which this Request is associated.

public String
getScheme()

Returns: the scheme used to make this Request.

pack-priv final HttpServerFilter
public String
getServerName()

Returns: the server name responding to this Request.

public int
getServerPort()

Returns: the server port responding to this Request.

public Session
getSession()

Return the session associated with this Request, creating one if necessary.

public Session
getSession(final boolean
Create a new session if one does not exist
create
)

Return the session associated with this Request, creating one if necessary and requested.

public String
getSessionCookieName()

Returns: session cookie name, if not set default JSESSIONID name will be used

protected SessionManager
public Map<String, String>

Returns:

A Map of trailers headers, if any were present.
getTrailers
()

Get the request trailer headers.

public Principal
getUserPrincipal()

Return the principal that has been authenticated for this Request.

public int
incrementDispatchDepth()

Increment the depth of application dispatch

public void
initialize(final HttpRequestPacket request, final FilterChainContext ctx, final HttpServerFilter httpServerFilter)

pack-priv static boolean
isAlpha(String value)

Returns: true if the given string is composed of upper- or lowercase letters only, false otherwise.

public boolean
isMaxDispatchDepthReached()

Check if the application dispatching has reached the maximum

public boolean
isPushEnabled()

Returns: true if HTTP/2 push is enabled, otherwise, false.

public boolean
isRequestedSessionIdFromCookie()

Returns: true if the session identifier included in this request came from a cookie.

public boolean
isRequestedSessionIdFromURL()

Return true if the session identifier included in this request came from the request URI.

public boolean
isRequestedSessionIdValid()

Returns: true if the session identifier included in this request identifies a valid session.

public boolean
isSecure()

Returns: true if this request received on a secure connection

pack-priv static boolean
isSSLAttribute(final String name)

Test if a given name is one of the special Servlet-spec SSL attributes.

private Charset
lookupCharset(final String enc)

public PushBuilder
newPushBuilder()

Returns: a new PushBuilder for issuing server push responses from the current request.

public final MappingData
protected String
protected void
protected void
parseCookies()

Parse cookies.

pack-priv void
parseJrouteCookie()

Parses the value of the JROUTE cookie, if present.

protected void
parseLocales()

Parse request locales.

protected void
parseLocalesHeader(String value)

Parse accept-language header value.

protected void
parseRequestParameters()

Parse request parameters.

protected void
parseSessionId()

Parse session id in URL.

private boolean
parseSessionId(final Chunk uriChunk)

private boolean
parseSessionId(DataChunk dataChunkStr)

protected void
recycle()

Release all object references, and initialize instance variables, in preparation for reuse of this object.

public void
removeAfterServiceListener(final AfterServiceListener
the "after-service" listener, which was previously added by addAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).
listener
)

Remove the "after-service" listener, which was previously added by addAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).

public void
removeAttribute(String
Name of the request attribute to remove
name
)

Remove the specified request attribute if it exists.

public <E> E
removeNote(final Note<E>
Note value to be removed
note
)

Remove the Note value associated with this request.

public void
replayPayload(final Buffer
payload
buffer
)

Replays request's payload by setting new payload Buffer.

public boolean
requiresAcknowledgement()

Returns: true if this request requires acknowledgment.

public void
setAttribute(final String
Name of the request attribute to set
name
,
final Object
The associated value
value
)

Set the specified request attribute to the specified value.

public void
setCharacterEncoding(final String
String containing the name of the character encoding.
encoding
)

Overrides the name of the character encoding used in the body of this request.

protected void
setContextPath(final String contextPath)

protected void
setContextPath(final Request.PathResolver contextPath)

public void
setCookies(Cookie[] cookies)

Set the set of cookies received with this Request.

protected void
setHttpHandlerPath(final String httpHandlerPath)

protected void
setHttpHandlerPath(final Request.PathResolver httpHandlerPath)

pack-priv void
setJrouteId(String
The jroute id
jrouteId
)

Sets the jroute id of this request.

public static void
setMaxDispatchDepth(int depth)

Static setter method for the maximum dispatch depth

public void
setMethod(String
the HTTP request method used in this Request.
method
)

Sets the HTTP request method used in this Request.

public <E> void
setNote(final Note<E>
Note to which the object should be bound
note
,
final E
the Note value be bound to the specified Note.
value
)

Bind the Note value to this Request, replacing any existing binding for this name.

protected void
setPathInfo(final String pathInfo)

protected void
public void
setQueryString(String
the query string associated with this request.
queryString
)

Sets the query string associated with this request.

public void
setRequestedSessionCookie(boolean
The new flag
flag
)

Set a flag indicating whether or not the requested session ID for this request came in through a cookie.

public void
setRequestedSessionId(String
The new session id
id
)

Set the requested session ID for this request.

public void
setRequestedSessionURL(boolean
The new flag
flag
)

Set a flag indicating whether or not the requested session ID for this request came in through a URL.

protected void
public void
setRequestParameters(final Parameters
the parameters to expose via this request.
parameters
)

This method may be used if some other entity processed request parameters and wishes to expose them via the request.

public void
setRequestURI(String
the request URI for this request.
uri
)

Sets the request URI for this request.

public void
setServerName(String
The server name
name
)

Set the name of the server (virtual host) to process this request.

public void
setServerPort(int
The server port
port
)

Set the port number of the server to process this request.

public void
setSessionCookieName(String sessionCookieName)

Set the session cookie name, if not set default JSESSIONID name will be used

protected void
setSessionManager(final SessionManager sessionManager)

Set SessionManager, null value implies DefaultSessionManager

public void
setUserPrincipal(Principal
The user Principal
principal
)

Set the Principal who has been authenticated for this Request.

protected void
skipPostBody(final int
how much of the POST body to skip.
len
)

Skips the POST body of this request.

protected String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait