java.lang.Object
org.glassfish.grizzly.http.HttpPacket
org.glassfish.grizzly.http.HttpHeader
org.glassfish.grizzly.http.HttpRequestPacket
- All Implemented Interfaces:
org.glassfish.grizzly.attributes.AttributeStorage
,org.glassfish.grizzly.Cacheable
,MimeHeadersPacket
The
HttpHeader
object, which represents HTTP request message.- Author:
- Alexey Stashok
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
HttpRequestPacket message builder. -
Field Summary
Modifier and TypeFieldDescriptionThe attributes associated with this Request, keyed by attribute name.protected final DataChunk
protected final DataChunk
protected int
protected Method
static final String
Prefix for all service/read-only attributes, that once added could not be removed.protected final DataChunk
protected final DataChunk
protected int
protected DataChunk
Fields inherited from class org.glassfish.grizzly.http.HttpHeader
contentLength, contentType, headers, isChunked, isCommitted, isContentBroken, isExpectContent, isSkipRemainder, parsedProtocol, protocolC, secure, upgrade
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionauthType()
static HttpRequestPacket.Builder
builder()
ReturnsHttpRequestPacket
builder.static <E> Note<E>
createNote
(String name) Create a namedNote
associated with this Request.protected void
getAttribute
(String name) org.glassfish.grizzly.Connection
int
Get the HTTP request method.Get the HTTP request method asDataChunk
(avoiding creation of a String object).<E> E
Return theNote
value associated with this Request, ornull
if no such binding exists.Return aSet
containing the String names of all note bindings that exist for this request.Returns the query string that is contained in the request URL after the path.Returns the query string that is contained in the request URL after the path.int
Returns the request URL.Returns the request URL of the HTTP request asRequestURIRef
(avoiding creation of a String object).int
boolean
Returnstrue
if this request is aHEAD
request, otherwise returnsfalse
.final boolean
Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.void
removeAttribute
(String name) Remove the specified request attribute if it exists.<E> E
removeNote
(Note<E> note) Remove theNote
value associated with this request.boolean
protected void
requiresAcknowledgement
(boolean requiresAcknowledgement) Allows consumers of this request to be notified if the user-agent requires acknowledgment of an expectation (i.e., the Expect header).protected void
reset()
Reset the internal state.Return the buffer holding the server name, if any.protected DataChunk
Return the buffer holding the server name, if any.void
setAttribute
(String name, Object value) Set the specified request attribute to the specified value.void
setConnection
(org.glassfish.grizzly.Connection connection) Sets the underlying connection used by the request.void
setLocalHost
(String host) Set the host name of the server servicing this request.void
setLocalPort
(int port) Sets the Internet Protocol (IP) port number of the interface on which the request was received.void
Set the HTTP request method.void
Set the HTTP request method.<E> void
Bind theNote
value to this Request, replacing any existing binding for this name.void
setQueryString
(String query) Set thequery
portion of the request URI.void
setRemotePort
(int port) Sets the Internet Protocol (IP) source port of the client or last proxy that sent the request.void
setRequestURI
(String requestURI) Set the request URL.protected void
setResponse
(HttpResponsePacket response) void
setServerPort
(int serverPort) Sets the Internet Protocol (IP) port specified in theHost
request header.toString()
Methods inherited from class org.glassfish.grizzly.http.HttpHeader
addContentEncoding, addHeader, addHeader, addHeader, addHeader, containsHeader, containsHeader, extractContentEncoding, flushSpecialHeaders, getAttributes, getCharacterEncoding, getContentEncodings, getContentEncodings, getContentLength, getContentType, getContentTypeHolder, getHeader, getHeader, getHeaders, getHttpHeader, getParsingState, getProcessingState, getProtocol, getProtocolDC, getProtocolString, getTempHeaderEncodingBuffer, getTransferEncoding, getUpgrade, getUpgradeDC, httpContentBuilder, httpTrailerBuilder, isChunked, isChunkingAllowed, isCommitted, isContentBroken, isContentEncodingsSelected, isContentTypeSet, isExpectContent, isHeader, isIgnoreContentModifiers, isSecure, isSkipRemainder, isUpgrade, makeContentLengthHeader, makeTransferEncodingHeader, makeUpgradeHeader, recycle, setCharacterEncoding, setChunked, setChunkingAllowed, setCommitted, setContentBroken, setContentEncodingsSelected, setContentLength, setContentLengthLong, setContentType, setContentType, setExpectContent, setHeader, setHeader, setHeader, setHeader, setIgnoreContentModifiers, setProtocol, setSecure, setSkipRemainder, setTransferEncoding, setUpgrade
Methods inherited from class org.glassfish.grizzly.http.HttpPacket
isHttp
-
Field Details
-
READ_ONLY_ATTR_PREFIX
Prefix for all service/read-only attributes, that once added could not be removed. The attributes with this prefix will not be listed in thegetAttributeNames()
result. The prefix was introduced with the intention to avoid collisions with normal user attributes and fail fast when we compare read-only and normal user attributes.- See Also:
-
remotePort
protected int remotePort -
localPort
protected int localPort -
parsedMethod
-
remoteAddressC
-
remoteHostC
-
localNameC
-
localAddressC
-
unparsedHostC
-
attributes
The attributes associated with this Request, keyed by attribute name.
-
-
Constructor Details
-
HttpRequestPacket
protected HttpRequestPacket()
-
-
Method Details
-
builder
ReturnsHttpRequestPacket
builder.- Returns:
HttpRequestPacket.Builder
.
-
setConnection
public void setConnection(org.glassfish.grizzly.Connection connection) Sets the underlying connection used by the request.- Parameters:
connection
-
-
getConnection
public org.glassfish.grizzly.Connection getConnection()- Returns:
- underlying connection used by the request
-
getResponse
-
getProtocolRequestId
- Returns:
- an empty string by default.
-
getMethodDC
Get the HTTP request method asDataChunk
(avoiding creation of a String object). The result format is "GET|POST...".- Returns:
- the HTTP request method as
DataChunk
(avoiding creation of a String object). The result format is "GET|POST...".
-
getMethod
Get the HTTP request method.- Returns:
- the HTTP request method.
-
setMethod
Set the HTTP request method.- Parameters:
method
- the HTTP request method. Format is "GET|POST...".
-
setMethod
Set the HTTP request method.- Parameters:
method
- the HTTP request method. Format is "GET|POST...".
-
getRequestURIRef
Returns the request URL of the HTTP request asRequestURIRef
(avoiding creation of a String object).- Returns:
- the request URL of the HTTP request as
RequestURIRef
(avoiding creation of a String object).
-
getRequestURI
Returns the request URL.- Returns:
- the request URL.
-
setRequestURI
Set the request URL.- Parameters:
requestURI
- the request URL.
-
getQueryStringDC
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. The result is represented asDataChunk
(avoiding creation of a String object).- Returns:
- the query string that is contained in the request URL after the path. This method returns null if the URL
does not have a query string. The result is represented as
DataChunk
(avoiding creation of a String object).
-
getQueryString
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string.- Returns:
- the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string.
-
setQueryString
Set thequery
portion of the request URI.- Parameters:
query
- the query String
-
serverNameRaw
Return the buffer holding the server name, if any. Use isNull() to check if there is no value set. This is the "virtual host", derived from the Host: header.- Returns:
- the buffer holding the server name
-
serverName
Return the buffer holding the server name, if any. Use isNull() to check if there is no value set. This is the "virtual host", derived from the Host: header.- Returns:
- the buffer holding the server name, if any
-
getServerPort
public int getServerPort()- Returns:
- Returns the integer value of the Internet Protocol (IP) port as specified in the
Host
request header.
-
setServerPort
public void setServerPort(int serverPort) Sets the Internet Protocol (IP) port specified in theHost
request header.- Parameters:
serverPort
- the port as specified in theHost
request header
-
remoteAddr
- Returns:
- the
DataChunk
representing the Internet Protocol (IP) address of the client or last proxy that sent the request.
-
getRemoteAddress
- Returns:
- the Internet Protocol (IP) address of the client or last proxy that sent the request.
-
remoteHost
- Returns:
- a
DataChunk
representing the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the host name (to improve performance), this method returns the the IP address.
-
getRemoteHost
- Returns:
- a
String
representing the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the the IP address.
-
requiresAcknowledgement
protected void requiresAcknowledgement(boolean requiresAcknowledgement) Allows consumers of this request to be notified if the user-agent requires acknowledgment of an expectation (i.e., the Expect header).- Parameters:
requiresAcknowledgement
-true
if expectation processing is required.
-
requiresAcknowledgement
public boolean requiresAcknowledgement()- Returns:
true
if this request requires acknowledgement.
-
localName
- Returns:
- a
DataChunk
representing the host name of the Internet Protocol (IP) interface on which the request was received.
-
getLocalName
- Returns:
- a
String
representing the host name of the Internet Protocol (IP) interface on which the request was received.
-
localAddr
- Returns:
- a
DataChunk
representing the Internet Protocol (IP) address of the interface on which the request was received.
-
getLocalAddress
- Returns:
- a
String
representing the Internet Protocol (IP) address of the interface on which the request was received.
-
getRemotePort
public int getRemotePort()- Returns:
- the Internet Protocol (IP) source port of the client or last proxy that sent the request.
-
setRemotePort
public void setRemotePort(int port) Sets the Internet Protocol (IP) source port of the client or last proxy that sent the request.- Parameters:
port
- the source port of the client
-
getLocalPort
public int getLocalPort()- Returns:
- the Internet Protocol (IP) port number of the interface on which the request was received.
-
setLocalPort
public void setLocalPort(int port) Sets the Internet Protocol (IP) port number of the interface on which the request was received.- Parameters:
port
- the port on which the request was received
-
getLocalHost
- Returns:
- the host name of the server servicing this request.
-
setLocalHost
Set the host name of the server servicing this request.- Parameters:
host
- the host name of the server servicing this request.
-
authType
- Returns:
- the authentication type used for this Request.
-
remoteUser
- Returns:
- the name of the remote user that has been authenticated for this Request.
-
createNote
Create a namedNote
associated with this Request. -
getNote
Return theNote
value associated with this Request, ornull
if no such binding exists. UsecreateNote(java.lang.String)
to create a newNote
. -
getNoteNames
Return aSet
containing the String names of all note bindings that exist for this request. UsecreateNote(java.lang.String)
to create a newNote
.- Returns:
- a
Set
containing the String names of all note bindings that exist for this request.
-
removeNote
Remove theNote
value associated with this request. UsecreateNote(java.lang.String)
to create a newNote
. -
setNote
Bind theNote
value to this Request, replacing any existing binding for this name. UsecreateNote(java.lang.String)
to create a newNote
. -
getAttribute
- Parameters:
name
- Name of the request attribute to return- Returns:
- the specified request attribute if it exists; otherwise, return
null
.
-
getAttributeNames
-
setAttribute
Set the specified request attribute to the specified value.- Parameters:
name
- Name of the request attribute to setvalue
- The associated value
-
removeAttribute
Remove the specified request attribute if it exists.- Parameters:
name
- Name of the request attribute to remove
-
isHeadRequest
public boolean isHeadRequest()Returnstrue
if this request is aHEAD
request, otherwise returnsfalse
.- Returns:
true
if this request is aHEAD
request, otherwise returnsfalse
.
-
reset
protected void reset()Reset the internal state.- Overrides:
reset
in classHttpHeader
-
isRequest
public final boolean isRequest()Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.- Specified by:
isRequest
in classHttpHeader
- Returns:
- true, if the current HttpHeader represent HTTP request message, or false otherwise.
-
toString
-
setResponse
-
doParseHostHeader
protected void doParseHostHeader()
-