Class Request
- java.lang.Object
-
- org.glassfish.grizzly.http.server.Request
-
public class Request extends Object
Wrapper object for the Coyote request.- Version:
- $Revision: 1.2 $ $Date: 2007/03/14 02:15:42 $
- Author:
- Remy Maucherat, Craig R. McClanahan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceRequest.PathResolver
-
Field Summary
Fields Modifier and Type Field Description protected List<AfterServiceListener>afterServicesListprotected org.glassfish.grizzly.http.Cookie[]cookiesThe set of cookies associated with this Request.protected booleancookiesParsedCookies parsed flag.protected org.glassfish.grizzly.filterchain.FilterChainContextctxprotected static LocaledefaultLocaleThe default Locale if none are specified.protected ObjectdispatcherTypeThe current dispatcher type.protected HttpServerFilterhttpServerFilterprotected ServerInputBufferinputBufferThe associated input buffer.protected ArrayList<Locale>localesThe preferred Locales associated with this Request.protected booleanlocalesParsedParse locales.protected ParameterMapparameterMapHash map used in the getParametersMap method.protected org.glassfish.grizzly.http.util.Parametersparametersprotected org.glassfish.grizzly.http.CookiesrawCookiesprotected org.glassfish.grizzly.http.HttpRequestPacketrequestHTTP Request Packetprotected ObjectrequestDispatcherPathThe current request dispatcher path.protected booleanrequestedSessionCookieWas the requested session ID received in a cookie?protected StringrequestedSessionIdThe requested session ID (if any) for this request.protected booleanrequestedSessionURLWas the requested session ID received in a URL?protected booleanrequestParametersParsedRequest parameters parsed flag.protected ResponseresponseThe response with which this request is associated.protected booleansecureSecure flag.static StringSEND_FILE_ATTRThe value of this request attribute, as set by the developer must be aFilethat exists, is not a directory, and is readable.static StringSEND_FILE_ENABLED_ATTRRequest attribute will be associated with a boolean value indicating whether or not it's possible to transfer aFileusing sendfile.static StringSEND_FILE_START_OFFSET_ATTRThe value of this request attribute signifies the starting offset of the file transfer.static StringSEND_FILE_WRITE_LEN_ATTRThe value of this request attribute signifies the total number of bytes to transfer.protected StringsessionCookieNameprotected SessionManagersessionManagerprotected booleansessionParsedSession parsed flag.protected SubjectsubjectThe Subject associated with the current AccessControllerContextprotected Map<String,String>trailersTrailer headers, if any.protected PrincipaluserPrincipalUser principal.protected booleanusingInputStreamUsing stream flag.protected booleanusingReaderUsing writer flag.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAfterServiceListener(AfterServiceListener listener)Add the listener, which will be notified, once Request processing will be finished.voidaddCookie(org.glassfish.grizzly.http.Cookie cookie)Add a Cookie to the set of Cookies associated with this Request.voidaddLocale(Locale locale)Add a Locale to the set of preferred Locales for this Request.voidaddParameter(String name, String[] values)Add a parameter name and corresponding set of values to this Request.static StringBufferappendRequestURL(Request request, StringBuffer buffer)Appends the reconstructed URL the client used to make the request.static StringBuilderappendRequestURL(Request request, StringBuilder buffer)Appends the reconstructed URL the client used to make the request.booleanareTrailersAvailable()StringchangeSessionId()Change the session id of the current session associated with this request and return the new session id.voidclearCookies()Clear the collection of Cookies associated with this Request.voidclearHeaders()Clear the collection of Headers associated with this Request.voidclearLocales()Clear the collection of Locales associated with this Request.voidclearParameters()Clear the collection of parameters associated with this Request.protected voidconfigureSessionCookie(org.glassfish.grizzly.http.Cookie cookie)Configures the given session cookie.static Requestcreate()org.glassfish.grizzly.http.io.NIOInputStreamcreateInputStream()Create and return a NIOInputStream to read the content associated with this Request.static <E> org.glassfish.grizzly.http.Note<E>createNote(String name)Create a namedNoteassociated with this Request.intdecrementDispatchDepth()Decrement the depth of application dispatchprotected SessiondoGetSession(boolean create)ObjectgetAttribute(String name)Return the specified request attribute if it exists; otherwise, returnnull.Set<String>getAttributeNames()Return the names of all request attributes for this Request, or an emptySetif there are none.StringgetAuthorization()StringgetAuthType()Return the authentication type used for this Request.StringgetCharacterEncoding()Return the character encoding for this Request.org.glassfish.grizzly.Connection<?>getConnection()intgetContentLength()Return the content length for this Request.longgetContentLengthLong()Return the content length for this Request represented by Java long type.StringgetContentType()Return the content type for this Request.org.glassfish.grizzly.filterchain.FilterChainContextgetContext()StringgetContextPath()Returns the portion of the request URI that indicates the context of the request.org.glassfish.grizzly.http.Cookie[]getCookies()Return the set of Cookies received with this Request.longgetDateHeader(String name)Return the value of the specified date header, if any; otherwise return -1.longgetDateHeader(org.glassfish.grizzly.http.util.Header header)Return the value of the specified date header, if any; otherwise return -1.StringgetDecodedRequestURI()Get the decoded request URI.StringgetHeader(String name)Return the first value of the specified header, if any; otherwise, returnnullStringgetHeader(org.glassfish.grizzly.http.util.Header header)Return the first value of the specified header, if any; otherwise, returnnullIterable<String>getHeaderNames()Return the names of all headers received with this request.Iterable<String>getHeaders(String name)Return all of the values of the specified header, if any; otherwise, return an empty enumeration.Iterable<String>getHeaders(org.glassfish.grizzly.http.util.Header header)Return all of the values of the specified header, if any; otherwise, return an empty enumeration.HttpServerFiltergetHttpFilter()StringgetHttpHandlerPath()Returns the part of this request's URL that calls the HttpHandler.org.glassfish.grizzly.http.io.InputBuffergetInputBuffer()InputStreamgetInputStream()Return theInputStreamfor thisRequest.intgetIntHeader(String name)Return the value of the specified header as an integer, or -1 if there is no such header for this request.intgetIntHeader(org.glassfish.grizzly.http.util.Header header)Return the value of the specified header as an integer, or -1 if there is no such header for this request.StringgetJrouteId()Gets the jroute id of this request, which may have been sent as a separateJROUTEcookie or appended to the session identifier encoded in the URI (if cookies have been disabled).StringgetLocalAddr()Returns the Internet Protocol (IP) address of the interface on which the request was received.LocalegetLocale()Return the preferred Locale that the client will accept content in, based on the value for the firstAccept-Languageheader that was encountered.List<Locale>getLocales()Return the set of preferred Locales that the client will accept content in, based on the values for anyAccept-Languageheaders that were encountered.StringgetLocalName()Returns the host name of the Internet Protocol (IP) interface on which the request was received.intgetLocalPort()Returns the Internet Protocol (IP) port number of the interface on which the request was received.static intgetMaxDispatchDepth()org.glassfish.grizzly.http.MethodgetMethod()Return the HTTP request method used in this Request.org.glassfish.grizzly.http.io.NIOInputStreamgetNIOInputStream()Return theNIOInputStreamfor thisRequest.org.glassfish.grizzly.http.io.NIOReadergetNIOReader()Returns theNIOReaderassociated with thisRequest.<E> EgetNote(org.glassfish.grizzly.http.Note<E> note)Return theNotevalue associated with this Request, ornullif no such binding exists.Set<String>getNoteNames()Return aSetcontaining the String names of all note bindings that exist for this request.StringgetParameter(String name)Return the value of the specified request parameter, if any; otherwise, returnnull.Map<String,String[]>getParameterMap()Returns aMapof the parameters of this request.Set<String>getParameterNames()Return the names of all defined request parameters for this request.org.glassfish.grizzly.http.util.ParametersgetParameters()Returns the low-level parameters holder for finer control over parameters.String[]getParameterValues(String name)Return the defined values for the specified request parameter, if any; otherwise, returnnull.StringgetPathInfo()Returns any extra path information associated with the URL the client sent when it made this request.org.glassfish.grizzly.BuffergetPostBody(int len)Gets the POST body of this request.org.glassfish.grizzly.http.ProtocolgetProtocol()Return the protocol and version used to make this Request.StringgetProtocolRequestId()StringgetQueryString()protected org.glassfish.grizzly.http.CookiesgetRawCookies()TODO DOCSReadergetReader()StringgetRemoteAddr()Return the remote IP address making this Request.StringgetRemoteHost()Return the remote host name making this Request.intgetRemotePort()Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.StringgetRemoteUser()Return the name of the remote user that has been authenticated for this Request.org.glassfish.grizzly.http.HttpRequestPacketgetRequest()StringgetRequestedSessionId()Return the session identifier included in this request, if any.ExecutorgetRequestExecutor()StringgetRequestId()StringgetRequestURI()Return the request URI for this request.StringBuildergetRequestURL()Reconstructs the URL the client used to make the request.ResponsegetResponse()StringgetScheme()StringgetServerName()intgetServerPort()SessiongetSession()Return the session associated with this Request, creating one if necessary.SessiongetSession(boolean create)Return the session associated with this Request, creating one if necessary and requested.StringgetSessionCookieName()protected SessionManagergetSessionManager()Map<String,String>getTrailers()Get the request trailer headers.PrincipalgetUserPrincipal()Return the principal that has been authenticated for this Request.intincrementDispatchDepth()Increment the depth of application dispatchvoidinitialize(org.glassfish.grizzly.http.HttpRequestPacket request, org.glassfish.grizzly.filterchain.FilterChainContext ctx, HttpServerFilter httpServerFilter)booleanisMaxDispatchDepthReached()Check if the application dispatching has reached the maximumbooleanisPushEnabled()booleanisRequestedSessionIdFromCookie()booleanisRequestedSessionIdFromURL()Returntrueif the session identifier included in this request came from the request URI.booleanisRequestedSessionIdValid()booleanisSecure()PushBuildernewPushBuilder()MappingDataobtainMappingData()protected StringobtainSessionCookieName()protected voidonAfterService()protected voidparseCookies()Parse cookies.protected voidparseLocales()Parse request locales.protected voidparseLocalesHeader(String value)Parse accept-language header value.protected voidparseRequestParameters()Parse request parameters.protected voidparseSessionId()Parse session id in URL.protected voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.voidremoveAfterServiceListener(AfterServiceListener listener)Remove the "after-service" listener, which was previously added byaddAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).voidremoveAttribute(String name)Remove the specified request attribute if it exists.<E> EremoveNote(org.glassfish.grizzly.http.Note<E> note)Remove theNotevalue associated with this request.voidreplayPayload(org.glassfish.grizzly.Buffer buffer)Replays request's payload by setting new payloadBuffer.booleanrequiresAcknowledgement()voidsetAttribute(String name, Object value)Set the specified request attribute to the specified value.voidsetCharacterEncoding(String encoding)Overrides the name of the character encoding used in the body of this request.protected voidsetContextPath(String contextPath)protected voidsetContextPath(Request.PathResolver contextPath)voidsetCookies(org.glassfish.grizzly.http.Cookie[] cookies)Set the set of cookies received with this Request.protected voidsetHttpHandlerPath(String httpHandlerPath)protected voidsetHttpHandlerPath(Request.PathResolver httpHandlerPath)static voidsetMaxDispatchDepth(int depth)Static setter method for the maximum dispatch depthvoidsetMethod(String method)Sets the HTTP request method used in this Request.<E> voidsetNote(org.glassfish.grizzly.http.Note<E> note, E value)Bind theNotevalue to this Request, replacing any existing binding for this name.protected voidsetPathInfo(String pathInfo)protected voidsetPathInfo(Request.PathResolver pathInfo)voidsetQueryString(String queryString)Sets the query string associated with this request.voidsetRequestedSessionCookie(boolean flag)Set a flag indicating whether or not the requested session ID for this request came in through a cookie.voidsetRequestedSessionId(String id)Set the requested session ID for this request.voidsetRequestedSessionURL(boolean flag)Set a flag indicating whether or not the requested session ID for this request came in through a URL.protected voidsetRequestExecutorProvider(RequestExecutorProvider requestExecutorProvider)Sets @return theRequestExecutorProviderresponsible for executing user's code inHttpHandler.service(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response)and notifyingReadHandler,WriteHandlerregistered by the user.voidsetRequestParameters(org.glassfish.grizzly.http.util.Parameters parameters)This method may be used if some other entity processed request parameters and wishes to expose them via the request.voidsetRequestURI(String uri)Sets the request URI for this request.voidsetServerName(String name)Set the name of the server (virtual host) to process this request.voidsetServerPort(int port)Set the port number of the server to process this request.voidsetSessionCookieName(String sessionCookieName)Set the session cookie name, if not set default JSESSIONID name will be usedprotected voidsetSessionManager(SessionManager sessionManager)SetSessionManager, null value impliesDefaultSessionManagervoidsetUserPrincipal(Principal principal)Set the Principal who has been authenticated for this Request.protected voidskipPostBody(int len)Skips the POST body of this request.protected Stringunescape(String s)
-
-
-
Field Detail
-
SEND_FILE_ENABLED_ATTR
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 aFileusing sendfile.- Since:
- 2.2
- See Also:
- Constant Field Values
-
SEND_FILE_ATTR
public static final String SEND_FILE_ATTR
The value of this request attribute, as set by the developer must be a
Filethat exists, is not a directory, and is readable. ThisFilewill be transferred using sendfile ifSEND_FILE_ENABLED_ATTRis true. If sendfile support isn't enabled, an IllegalStateException will be raised at runtime. TheHttpHandlerusing this functionality should refrain from writing content via the response.Note that once this attribute is set, the sendfile process will begin.
- Since:
- 2.2
- See Also:
- Constant Field Values
-
SEND_FILE_START_OFFSET_ATTR
public static final String SEND_FILE_START_OFFSET_ATTR
The value of this request attribute signifies the starting offset of the file transfer. If not specified, an offset of zero will be assumed. The type of the value must be
Long.NOTE: In order for this attribute to take effect, it must be set before the
SEND_FILE_ATTRis set.- Since:
- 2.2
- See Also:
- Constant Field Values
-
SEND_FILE_WRITE_LEN_ATTR
public static final String SEND_FILE_WRITE_LEN_ATTR
The value of this request attribute signifies the total number of bytes to transfer. If not specified, the entire file will be transferred. The type of the value must be
LongNOTE: In order for this attribute to take effect, it must be set before the
SEND_FILE_ATTRis set.- Since:
- 2.2
- See Also:
- Constant Field Values
-
request
protected org.glassfish.grizzly.http.HttpRequestPacket request
HTTP Request Packet
-
ctx
protected org.glassfish.grizzly.filterchain.FilterChainContext ctx
-
httpServerFilter
protected HttpServerFilter httpServerFilter
-
afterServicesList
protected final List<AfterServiceListener> afterServicesList
-
cookies
protected org.glassfish.grizzly.http.Cookie[] cookies
The set of cookies associated with this Request.
-
rawCookies
protected org.glassfish.grizzly.http.Cookies rawCookies
-
sessionCookieName
protected String sessionCookieName
-
sessionManager
protected SessionManager sessionManager
-
defaultLocale
protected static final Locale defaultLocale
The default Locale if none are specified.
-
locales
protected final ArrayList<Locale> locales
The preferred Locales associated with this Request.
-
dispatcherType
protected Object dispatcherType
The current dispatcher type.
-
inputBuffer
protected final ServerInputBuffer inputBuffer
The associated input buffer.
-
usingInputStream
protected boolean usingInputStream
Using stream flag.
-
usingReader
protected boolean usingReader
Using writer flag.
-
userPrincipal
protected Principal userPrincipal
User principal.
-
sessionParsed
protected boolean sessionParsed
Session parsed flag.
-
requestParametersParsed
protected boolean requestParametersParsed
Request parameters parsed flag.
-
cookiesParsed
protected boolean cookiesParsed
Cookies parsed flag.
-
secure
protected boolean secure
Secure flag.
-
subject
protected Subject subject
The Subject associated with the current AccessControllerContext
-
parameterMap
protected final ParameterMap parameterMap
Hash map used in the getParametersMap method.
-
parameters
protected final org.glassfish.grizzly.http.util.Parameters parameters
-
requestDispatcherPath
protected Object requestDispatcherPath
The current request dispatcher path.
-
requestedSessionCookie
protected boolean requestedSessionCookie
Was the requested session ID received in a cookie?
-
requestedSessionId
protected String requestedSessionId
The requested session ID (if any) for this request.
-
requestedSessionURL
protected boolean requestedSessionURL
Was the requested session ID received in a URL?
-
localesParsed
protected boolean localesParsed
Parse locales.
-
response
protected final Response response
The response with which this request is associated.
-
-
Constructor Detail
-
Request
@Deprecated public Request()
Deprecated.Temporarily introduce public constructor to fix GRIZZLY-1782. Just to make request instances proxiable. This constructor is not intended for client code consumption and should not be used explicitly as it creates an invalid instance.
-
Request
protected Request(Response response)
-
-
Method Detail
-
create
public static Request create()
-
obtainMappingData
public final MappingData obtainMappingData()
-
initialize
public void initialize(org.glassfish.grizzly.http.HttpRequestPacket request, org.glassfish.grizzly.filterchain.FilterChainContext ctx, HttpServerFilter httpServerFilter)
-
getRequest
public org.glassfish.grizzly.http.HttpRequestPacket getRequest()
- Returns:
- the Coyote request.
-
getResponse
public Response getResponse()
- Returns:
- the Response with which this Request is associated.
-
getSessionCookieName
public String getSessionCookieName()
- Returns:
- session cookie name, if not set default JSESSIONID name will be used
-
setSessionCookieName
public void setSessionCookieName(String sessionCookieName)
Set the session cookie name, if not set default JSESSIONID name will be used
-
isPushEnabled
public boolean isPushEnabled()
- Returns:
trueif HTTP/2 push is enabled, otherwise,false.
-
obtainSessionCookieName
protected String obtainSessionCookieName()
- Returns:
sessionCookieNameif set, or the value returned bySessionManager.getSessionCookieName()ifsessionCookieNameis not set.
-
getSessionManager
protected SessionManager getSessionManager()
- Returns:
SessionManager
-
setSessionManager
protected void setSessionManager(SessionManager sessionManager)
SetSessionManager, null value impliesDefaultSessionManager
-
getRequestExecutor
public Executor getRequestExecutor()
- Returns:
- the
Executorresponsible for notifyingReadHandler,WriteHandlerassociated with this Request processing.
-
setRequestExecutorProvider
protected void setRequestExecutorProvider(RequestExecutorProvider requestExecutorProvider)
Sets @return theRequestExecutorProviderresponsible for executing user's code inHttpHandler.service(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response)and notifyingReadHandler,WriteHandlerregistered by the user.- Parameters:
requestExecutorProvider-RequestExecutorProvider
-
addAfterServiceListener
public void addAfterServiceListener(AfterServiceListener listener)
Add the listener, which will be notified, once Request processing will be finished.- Parameters:
listener- the listener, which will be notified, once Request processing will be finished.
-
removeAfterServiceListener
public void removeAfterServiceListener(AfterServiceListener listener)
Remove the "after-service" listener, which was previously added byaddAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).- Parameters:
listener- the "after-service" listener, which was previously added byaddAfterServiceListener(org.glassfish.grizzly.http.server.AfterServiceListener).
-
onAfterService
protected void onAfterService()
-
recycle
protected void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
-
getAuthorization
public String getAuthorization()
- Returns:
- the authorization credentials sent with this request.
-
newPushBuilder
public PushBuilder newPushBuilder()
- Returns:
- a new
PushBuilderfor issuing server push responses from the current request. If the current connection does not support server push, or server push has been disabled by the client, it will returnnull.
-
replayPayload
public void replayPayload(org.glassfish.grizzly.Buffer buffer)
Replays request's payload by setting new payloadBuffer. If request parameters have been parsed based on prev. request's POST payload - the parameters will be recycled and ready to be parsed again.- Parameters:
buffer- payload
-
createInputStream
public org.glassfish.grizzly.http.io.NIOInputStream createInputStream()
Create and return a NIOInputStream to read the content associated with this Request.- Returns:
NIOInputStream
-
createNote
public static <E> org.glassfish.grizzly.http.Note<E> createNote(String name)
Create a namedNoteassociated with this Request.- Type Parameters:
E- theNotetype.- Parameters:
name- theNotename.- Returns:
- the
Note.
-
getNote
public <E> E getNote(org.glassfish.grizzly.http.Note<E> note)
Return theNotevalue associated with this Request, ornullif no such binding exists. UsecreateNote(java.lang.String)to create a newNote.- Parameters:
note-Notevalue to be returned
-
getNoteNames
public Set<String> getNoteNames()
Return aSetcontaining the String names of all note bindings that exist for this request. UsecreateNote(java.lang.String)to create a newNote.- Returns:
- a
Setcontaining the String names of all note bindings that exist for this request.
-
removeNote
public <E> E removeNote(org.glassfish.grizzly.http.Note<E> note)
Remove theNotevalue associated with this request. UsecreateNote(java.lang.String)to create a newNote.- Parameters:
note-Notevalue to be removed
-
setNote
public <E> void setNote(org.glassfish.grizzly.http.Note<E> note, E value)Bind theNotevalue to this Request, replacing any existing binding for this name. UsecreateNote(java.lang.String)to create a newNote.- Parameters:
note-Noteto which the object should be boundvalue- theNotevalue be bound to the specifiedNote.
-
setServerName
public void setServerName(String name)
Set the name of the server (virtual host) to process this request.- Parameters:
name- The server name
-
setServerPort
public void setServerPort(int port)
Set the port number of the server to process this request.- Parameters:
port- The server port
-
getHttpFilter
public HttpServerFilter getHttpFilter()
- Returns:
HttpServerFilter, which dispatched this request
-
getContextPath
public String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. ForHttpHandlers in the default (root) context, this method returns "". The container does not decode this string.- Returns:
- a String specifying the portion of the request URI that indicates the context of the request
-
setContextPath
protected void setContextPath(String contextPath)
-
setContextPath
protected void setContextPath(Request.PathResolver contextPath)
-
getHttpHandlerPath
public String getHttpHandlerPath()
Returns the part of this request's URL that calls the HttpHandler. This includes either the HttpHandler name or a path to the HttpHandler, but does not include any extra path information or a query string.- Returns:
- a String containing the name or path of the HttpHandler being called, as specified in the request URL
- Throws:
IllegalStateException- if HttpHandler path was not set explicitly and attempt to URI-decodeRequestURIRef.getDecodedURI()failed.
-
setHttpHandlerPath
protected void setHttpHandlerPath(String httpHandlerPath)
-
setHttpHandlerPath
protected void setHttpHandlerPath(Request.PathResolver httpHandlerPath)
-
getPathInfo
public String getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the HttpHandler path but precedes the query string. This method returns null if there was no extra path information.- 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
-
setPathInfo
protected void setPathInfo(String pathInfo)
-
setPathInfo
protected void setPathInfo(Request.PathResolver pathInfo)
-
getAttribute
public Object getAttribute(String name)
Return the specified request attribute if it exists; otherwise, returnnull.- Parameters:
name- Name of the request attribute to return- Returns:
- the specified request attribute if it exists; otherwise, return
null.
-
getAttributeNames
public Set<String> getAttributeNames()
Return the names of all request attributes for this Request, or an emptySetif there are none.
-
getCharacterEncoding
public String getCharacterEncoding()
Return the character encoding for this Request.
-
getContentLength
public int getContentLength()
Return the content length for this Request.
-
getContentLengthLong
public long getContentLengthLong()
Return the content length for this Request represented by Java long type.
-
getContentType
public String getContentType()
Return the content type for this Request.
-
getInputStream
public InputStream getInputStream()
Return the
By default the returnedInputStreamfor thisRequest.NIOInputStreamwill work as blockingInputStream, but it will be possible to callInputSource.isReady(),InputStream.available(), orInputSource.notifyAvailable(org.glassfish.grizzly.ReadHandler)to avoid blocking.- Returns:
- the
NIOInputStreamfor thisRequest. - Throws:
IllegalStateException- ifgetReader()orgetNIOReader()has already been called for this request.- Since:
- 2.2
-
getNIOInputStream
public org.glassfish.grizzly.http.io.NIOInputStream getNIOInputStream()
Return the
NIOInputStreamfor thisRequest. This stream will not block when reading content.NOTE: For now, in order to use non-blocking functionality, this method must be invoked before the
HttpHandler.service(Request, Response)method returns. We hope to have this addressed in the next release.- Returns:
- the
NIOInputStreamfor thisRequest. - Throws:
IllegalStateException- ifgetReader()orgetNIOReader()has already been called for this request.
-
requiresAcknowledgement
public boolean requiresAcknowledgement()
- Returns:
trueif this request requires acknowledgment.
-
getLocale
public Locale getLocale()
Return the preferred Locale that the client will accept content in, based on the value for the firstAccept-Languageheader that was encountered. If the request did not specify a preferred language, the server's default Locale is returned.
-
getLocales
public List<Locale> getLocales()
Return the set of preferred Locales that the client will accept content in, based on the values for anyAccept-Languageheaders that were encountered. If the request did not specify a preferred language, the server's default Locale is returned.
-
getParameters
public org.glassfish.grizzly.http.util.Parameters getParameters()
Returns the low-level parameters holder for finer control over parameters.- Returns:
Parameters.
-
getParameter
public String getParameter(String name)
Return the value of the specified request parameter, if any; otherwise, returnnull. If there is more than one value defined, return only the first one.- Parameters:
name- Name of the desired request parameter
-
getParameterMap
public Map<String,String[]> getParameterMap()
Returns aMapof the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.- Returns:
- A
Mapcontaining parameter names as keys and parameter values as map values.
-
getParameterNames
public Set<String> getParameterNames()
Return the names of all defined request parameters for this request.
-
getParameterValues
public String[] getParameterValues(String name)
Return the defined values for the specified request parameter, if any; otherwise, returnnull.- Parameters:
name- Name of the desired request parameter
-
getProtocol
public org.glassfish.grizzly.http.Protocol getProtocol()
Return the protocol and version used to make this Request.
-
getReader
public Reader getReader()
Returns the
By default the returnedReaderassociated with thisRequest.NIOReaderwill work as blockingReader, but it will be possible to callInputSource.isReady()orInputSource.notifyAvailable(org.glassfish.grizzly.ReadHandler)to avoid blocking.- Returns:
- the
NIOReaderassociated with thisRequest. - Throws:
IllegalStateException- ifgetInputStream()orgetNIOInputStream()has already been called for this request.- Since:
- 2.2
-
getNIOReader
public org.glassfish.grizzly.http.io.NIOReader getNIOReader()
Returns the
NIOReaderassociated with thisRequest. ThisNIOReaderwill not block while reading content.- Returns:
NIOReader- Throws:
IllegalStateException- ifgetInputStream()orgetNIOInputStream()has already been called for this request.
-
getRemoteAddr
public String getRemoteAddr()
Return the remote IP address making this Request.
-
getRemoteHost
public String getRemoteHost()
Return the remote host name making this Request.
-
getRemotePort
public int getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
-
getLocalName
public String getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received.
-
getLocalAddr
public String getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received.
-
getLocalPort
public int getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.
-
getScheme
public String getScheme()
- Returns:
- the scheme used to make this Request.
-
getServerName
public String getServerName()
- Returns:
- the server name responding to this Request.
-
getServerPort
public int getServerPort()
- Returns:
- the server port responding to this Request.
-
isSecure
public boolean isSecure()
- Returns:
- true if this request received on a secure connection
-
removeAttribute
public void removeAttribute(String name)
Remove the specified request attribute if it exists.- Parameters:
name- Name of the request attribute to remove
-
setAttribute
public void setAttribute(String name, Object value)
Set the specified request attribute to the specified value.- Parameters:
name- Name of the request attribute to setvalue- The associated value
-
setCharacterEncoding
public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException
Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input usinggetReader(). Otherwise, it has no effect.- Parameters:
encoding-Stringcontaining the name of the character encoding.- Throws:
UnsupportedEncodingException- if this ServletRequest is still in a state where a character encoding may be set, but the specified encoding is invalid- Since:
- Servlet 2.3
-
setMaxDispatchDepth
public static void setMaxDispatchDepth(int depth)
Static setter method for the maximum dispatch depth
-
getMaxDispatchDepth
public static int getMaxDispatchDepth()
-
incrementDispatchDepth
public int incrementDispatchDepth()
Increment the depth of application dispatch
-
decrementDispatchDepth
public int decrementDispatchDepth()
Decrement the depth of application dispatch
-
isMaxDispatchDepthReached
public boolean isMaxDispatchDepthReached()
Check if the application dispatching has reached the maximum
-
getRequestId
public String getRequestId()
- Returns:
- identifier of the request generated by this class.
-
getProtocolRequestId
public String getProtocolRequestId()
- Returns:
- an empty string or identifier managed by the underlying protocol (HTTP2)
-
getConnection
public org.glassfish.grizzly.Connection<?> getConnection()
- Returns:
- underlying connection used by the request
-
addCookie
public void addCookie(org.glassfish.grizzly.http.Cookie cookie)
Add a Cookie to the set of Cookies associated with this Request.- Parameters:
cookie- The new cookie
-
addLocale
public void addLocale(Locale locale)
Add a Locale to the set of preferred Locales for this Request. The first added Locale will be the first one returned by getLocales().- Parameters:
locale- The new preferred Locale
-
addParameter
public void addParameter(String name, String[] values)
Add a parameter name and corresponding set of values to this Request. (This is used when restoring the original request on a form based login).- Parameters:
name- Name of this request parametervalues- Corresponding values for this request parameter
-
clearCookies
public void clearCookies()
Clear the collection of Cookies associated with this Request.
-
clearHeaders
public void clearHeaders()
Clear the collection of Headers associated with this Request.
-
clearLocales
public void clearLocales()
Clear the collection of Locales associated with this Request.
-
clearParameters
public void clearParameters()
Clear the collection of parameters associated with this Request.
-
getDecodedRequestURI
public String getDecodedRequestURI() throws CharConversionException
Get the decoded request URI.- Returns:
- the URL decoded request URI
- Throws:
CharConversionException
-
setUserPrincipal
public void setUserPrincipal(Principal principal)
Set the Principal who has been authenticated for this Request. This value is also used to calculate the value to be returned by thegetRemoteUser()method.- Parameters:
principal- The user Principal
-
getAuthType
public String getAuthType()
Return the authentication type used for this Request.
-
getCookies
public org.glassfish.grizzly.http.Cookie[] getCookies()
Return the set of Cookies received with this Request.
-
setCookies
public void setCookies(org.glassfish.grizzly.http.Cookie[] cookies)
Set the set of cookies received with this Request.
-
getDateHeader
public long getDateHeader(String name)
Return the value of the specified date header, if any; otherwise return -1.- Parameters:
name- Name of the requested date header- Throws:
IllegalArgumentException- if the specified header value cannot be converted to a date
-
getDateHeader
public long getDateHeader(org.glassfish.grizzly.http.util.Header header)
Return the value of the specified date header, if any; otherwise return -1.- Parameters:
header- the requested dateHeader- Throws:
IllegalArgumentException- if the specified header value cannot be converted to a date- Since:
- 2.1.2
-
getHeader
public String getHeader(String name)
Return the first value of the specified header, if any; otherwise, returnnull- Parameters:
name- Name of the requested header
-
getHeader
public String getHeader(org.glassfish.grizzly.http.util.Header header)
Return the first value of the specified header, if any; otherwise, returnnull- Parameters:
header- the requestedHeader- Since:
- 2.1.2
-
getHeaders
public Iterable<String> getHeaders(String name)
Return all of the values of the specified header, if any; otherwise, return an empty enumeration.- Parameters:
name- Name of the requested header
-
getHeaders
public Iterable<String> getHeaders(org.glassfish.grizzly.http.util.Header header)
Return all of the values of the specified header, if any; otherwise, return an empty enumeration.- Parameters:
header- the requestedHeader- Since:
- 2.1.2
-
getTrailers
public Map<String,String> getTrailers()
Get the request trailer headers. Values may only be returned in the case of HTTP/1.1 when the request is using thetransfer-encodingchunkedor in HTTP/2 sends a secondHEADERSframe terminating the stream. An emptyMapwill be returned in all other cases. While headers are typical case insensitive, the headers stored in the returnedMapwill be done so in lower-case. This method should typically be called after the application has read the request body. It is safe to invoke this method if there is no body content.- Returns:
- A
Mapof trailers headers, if any were present. - Throws:
IllegalStateException- if neitherReadHandler.onAllDataRead()has been called or an EOF indication has been returned from thegetReader(),getNIOReader(),getInputStream(),getNIOInputStream().- Since:
- 2.4.0
- See Also:
areTrailersAvailable()
-
areTrailersAvailable
public boolean areTrailersAvailable()
- Returns:
trueif trailers are available to be accessed otherwise returnsfalse.- Since:
- 2.4.0
-
getHeaderNames
public Iterable<String> getHeaderNames()
Return the names of all headers received with this request.
-
getIntHeader
public int getIntHeader(String name)
Return the value of the specified header as an integer, or -1 if there is no such header for this request.- Parameters:
name- Name of the requested header- Throws:
IllegalArgumentException- if the specified header value cannot be converted to an integer
-
getIntHeader
public int getIntHeader(org.glassfish.grizzly.http.util.Header header)
Return the value of the specified header as an integer, or -1 if there is no such header for this request.- Parameters:
header- the requestedHeader- Throws:
IllegalArgumentException- if the specified header value cannot be converted to an integer- Since:
- 2.1.2
-
getMethod
public org.glassfish.grizzly.http.Method getMethod()
Return the HTTP request method used in this Request.
-
setMethod
public void setMethod(String method)
Sets the HTTP request method used in this Request.- Parameters:
method- the HTTP request method used in this Request.
-
getQueryString
public String getQueryString()
- Returns:
- the query string associated with this request.
-
setQueryString
public void setQueryString(String queryString)
Sets the query string associated with this request.- Parameters:
queryString- the query string associated with this request.
-
getRemoteUser
public String getRemoteUser()
Return the name of the remote user that has been authenticated for this Request.
-
getRequestedSessionId
public String getRequestedSessionId()
Return the session identifier included in this request, if any.
-
getRequestURI
public String getRequestURI()
Return the request URI for this request.
-
setRequestURI
public void setRequestURI(String uri)
Sets the request URI for this request.- Parameters:
uri- the request URI for this request.
-
getRequestURL
public StringBuilder getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.Because this method returns a
StringBuilder, not aString, you can modify the URL easily, for example, to append query parameters.This method is useful for creating redirect messages and for reporting errors.
- Returns:
- A
StringBufferobject containing the reconstructed URL
-
appendRequestURL
public static StringBuilder appendRequestURL(Request request, StringBuilder buffer)
Appends the reconstructed URL the client used to make the request. The appended URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.Because this method returns a
StringBuilder, not aString, you can modify the URL easily, for example, to append query parameters.This method is useful for creating redirect messages and for reporting errors.
- Returns:
- A
StringBuilderobject containing the appended reconstructed URL
-
appendRequestURL
public static StringBuffer appendRequestURL(Request request, StringBuffer buffer)
Appends the reconstructed URL the client used to make the request. The appended URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.Because this method returns a
StringBuffer, not aString, you can modify the URL easily, for example, to append query parameters.This method is useful for creating redirect messages and for reporting errors.
- Returns:
- A
StringBufferobject containing the appended reconstructed URL
-
getUserPrincipal
public Principal getUserPrincipal()
Return the principal that has been authenticated for this Request.
-
getContext
public org.glassfish.grizzly.filterchain.FilterChainContext getContext()
-
parseCookies
protected void parseCookies()
Parse cookies.
-
getInputBuffer
public org.glassfish.grizzly.http.io.InputBuffer getInputBuffer()
- Returns:
- the
InputBufferassociated with this request, which is the source forgetInputStream(),getReader(),getNIOInputStream(), andgetNIOReader()
-
setRequestParameters
public void setRequestParameters(org.glassfish.grizzly.http.util.Parameters parameters)
This method may be used if some other entity processed request parameters and wishes to expose them via the request. When this method is called, it will mark the internal request parameter state as having been processed.- Parameters:
parameters- the parameters to expose via this request.- Since:
- 2.2
-
getRawCookies
protected org.glassfish.grizzly.http.Cookies getRawCookies()
TODO DOCS
-
parseRequestParameters
protected void parseRequestParameters()
Parse request parameters.
-
getPostBody
public org.glassfish.grizzly.Buffer getPostBody(int len) throws IOExceptionGets the POST body of this request.- Returns:
- The POST body of this request
- Throws:
IOException
-
skipPostBody
protected void skipPostBody(int len) throws IOExceptionSkips the POST body of this request.- Parameters:
len- how much of the POST body to skip.- Throws:
IOException
-
parseLocales
protected void parseLocales()
Parse request locales.
-
parseLocalesHeader
protected void parseLocalesHeader(String value)
Parse accept-language header value.
-
getJrouteId
public String getJrouteId()
Gets the jroute id of this request, which may have been sent as a separateJROUTEcookie or appended to the session identifier encoded in the URI (if cookies have been disabled).- Returns:
- The jroute id of this request, or null if this request does not carry any jroute id
-
getSession
public Session getSession()
Return the session associated with this Request, creating one if necessary.
-
getSession
public Session getSession(boolean create)
Return the session associated with this Request, creating one if necessary and requested.- Parameters:
create- Create a new session if one does not exist
-
changeSessionId
public String changeSessionId()
Change the session id of the current session associated with this request and return the new session id.- Returns:
- the original session id
- Throws:
IllegalStateException- if there is no session associated with the request- Since:
- 2.3
-
doGetSession
protected Session doGetSession(boolean create)
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
- Returns:
trueif the session identifier included in this request came from a cookie.
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
Returntrueif the session identifier included in this request came from the request URI.
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
- Returns:
- true if the session identifier included in this request identifies a valid session.
-
configureSessionCookie
protected void configureSessionCookie(org.glassfish.grizzly.http.Cookie cookie)
Configures the given session cookie.- Parameters:
cookie- The session cookie to be configured
-
parseSessionId
protected void parseSessionId()
Parse session id in URL.
-
setRequestedSessionCookie
public void setRequestedSessionCookie(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a cookie. This is normally called by the HTTP Connector, when it parses the request headers.- Parameters:
flag- The new flag
-
setRequestedSessionId
public void setRequestedSessionId(String id)
Set the requested session ID for this request. This is normally called by the HTTP Connector, when it parses the request headers.- Parameters:
id- The new session id
-
setRequestedSessionURL
public void setRequestedSessionURL(boolean flag)
Set a flag indicating whether or not the requested session ID for this request came in through a URL. This is normally called by the HTTP Connector, when it parses the request headers.- Parameters:
flag- The new flag
-
-