org.glassfish.grizzly.http
Class HttpRequestPacket

java.lang.Object
  extended by org.glassfish.grizzly.http.HttpPacket
      extended by org.glassfish.grizzly.http.HttpHeader
          extended by org.glassfish.grizzly.http.HttpRequestPacket
All Implemented Interfaces:
AttributeStorage, Cacheable, MimeHeadersPacket

public abstract class HttpRequestPacket
extends HttpHeader

The HttpHeader object, which represents HTTP request message.

Author:
Alexey Stashok
See Also:
HttpHeader, HttpResponsePacket

Nested Class Summary
static class HttpRequestPacket.Builder
          HttpRequestPacket message builder.
 
Field Summary
protected  java.util.Map<java.lang.String,java.lang.Object> attributes
          The attributes associated with this Request, keyed by attribute name.
protected  Method parsedMethod
           
 
Fields inherited from class org.glassfish.grizzly.http.HttpHeader
characterEncoding, charsetSet, contentLength, contentType, contentTypeParsed, headers, isChunked, isCommitted, isExpectContent, isSkipRemainder, parsedProtocol, protocolC, quotedCharsetValue, secure, upgrade
 
Constructor Summary
protected HttpRequestPacket()
           
 
Method Summary
 DataChunk authType()
          Return the authentication type used for this Request.
static HttpRequestPacket.Builder builder()
          Returns HttpRequestPacket builder.
static
<E> Note<E>
createNote(java.lang.String name)
          Create a named Note associated with this Request.
 java.lang.Object getAttribute(java.lang.String name)
          Return the specified request attribute if it exists; otherwise, return null.
 java.util.Set<java.lang.String> getAttributeNames()
          Return the names of all request attributes for this Request, or an empty Set if there are none.
 Connection getConnection()
           
 java.lang.String getLocalAddress()
           
 java.lang.String getLocalHost()
           
 java.lang.String getLocalName()
           
 int getLocalPort()
           
 Method getMethod()
          Get the HTTP request method.
 DataChunk getMethodDC()
          Get the HTTP request method as DataChunk (avoiding creation of a String object).
<E> E
getNote(Note<E> note)
          Return the Note value associated with this Request, or null if no such binding exists.
 java.util.Set<java.lang.String> getNoteNames()
          Return a Set containing the String names of all note bindings that exist for this request.
 java.lang.String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 DataChunk getQueryStringDC()
          Returns the query string that is contained in the request URL after the path.
 java.lang.String getRemoteAddress()
           
 java.lang.String getRemoteHost()
           
 int getRemotePort()
           
 java.lang.String getRequestURI()
          Returns the request URL.
 RequestURIRef getRequestURIRef()
          Returns the request URL of the HTTP request as RequestURIRef (avoiding creation of a String object).
 HttpResponsePacket getResponse()
           
 int getServerPort()
           
 boolean isHeadRequest()
          Returns true if this request is a HEAD request, otherwise returns false.
 boolean isRequest()
          Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.
 DataChunk localAddr()
           
 DataChunk localName()
           
 DataChunk remoteAddr()
           
 DataChunk remoteHost()
           
 DataChunk remoteUser()
          Return the name of the remote user that has been authenticated for this Request.
 void removeAttribute(java.lang.String name)
          Remove the specified request attribute if it exists.
<E> E
removeNote(Note<E> note)
          Remove the Note value associated with this request.
 boolean 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).
protected  void reset()
          Reset the internal state.
 DataChunk serverName()
          Return the buffer holding the server name, if any.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set the specified request attribute to the specified value.
 void setConnection(Connection connection)
           
 void setLocalHost(java.lang.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 setMethod(Method method)
          Set the HTTP request method.
 void setMethod(java.lang.String method)
          Set the HTTP request method.
<E> void
setNote(Note<E> note, E value)
          Bind the Note value to this Request, replacing any existing binding for this name.
 void setQueryString(java.lang.String query)
          Set the query 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(java.lang.String requestURI)
          Set the request URL.
protected  void setResponse(HttpResponsePacket response)
           
 void setServerPort(int serverPort)
          Sets the Internet Protocol (IP) port specified in the Host request header.
 java.lang.String toString()
          
 
Methods inherited from class org.glassfish.grizzly.http.HttpHeader
addContentEncoding, addHeader, addHeader, containsHeader, containsHeader, extractContentEncoding, getAttributes, getCharacterEncoding, getContentEncodings, getContentEncodings, getContentLength, getContentType, getDefaultContentType, getHeader, getHeader, getHeaders, getProcessingState, getProtocol, getProtocolDC, getProtocolString, getTransferEncoding, getUpgrade, getUpgradeDC, httpContentBuilder, httpTrailerBuilder, isChunked, isCommitted, isContentTypeSet, isExpectContent, isHeader, isSecure, isSkipRemainder, makeContentLengthHeader, makeTransferEncodingHeader, makeUpgradeHeader, recycle, serializeContentType, setCharacterEncoding, setChunked, setCommitted, setContentLength, setContentLengthLong, setContentType, setDefaultContentType, setExpectContent, setHeader, setHeader, setProtocol, setSecure, setSkipRemainder, setTransferEncoding, setUpgrade
 
Methods inherited from class org.glassfish.grizzly.http.HttpPacket
isHttp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parsedMethod

protected Method parsedMethod

attributes

protected final java.util.Map<java.lang.String,java.lang.Object> attributes
The attributes associated with this Request, keyed by attribute name.

Constructor Detail

HttpRequestPacket

protected HttpRequestPacket()
Method Detail

builder

public static HttpRequestPacket.Builder builder()
Returns HttpRequestPacket builder.

Returns:
HttpRequestPacket.Builder.

setConnection

public void setConnection(Connection connection)

getConnection

public Connection getConnection()

getResponse

public HttpResponsePacket getResponse()

getMethodDC

public DataChunk getMethodDC()
Get the HTTP request method as DataChunk (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

public Method getMethod()
Get the HTTP request method.

Returns:
the HTTP request method.

setMethod

public void setMethod(java.lang.String method)
Set the HTTP request method.

Parameters:
method - the HTTP request method. Format is "GET|POST...".

setMethod

public void setMethod(Method method)
Set the HTTP request method.

Parameters:
method - the HTTP request method. Format is "GET|POST...".

getRequestURIRef

public RequestURIRef getRequestURIRef()
Returns the request URL of the HTTP request as RequestURIRef (avoiding creation of a String object).

Returns:
the request URL of the HTTP request as RequestURIRef (avoiding creation of a String object).

getRequestURI

public java.lang.String getRequestURI()
Returns the request URL.

Returns:
the request URL.

setRequestURI

public void setRequestURI(java.lang.String requestURI)
Set the request URL.

Parameters:
requestURI - the request URL.

getQueryStringDC

public DataChunk 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 as DataChunk (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

public java.lang.String 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

public void setQueryString(java.lang.String query)
Set the query portion of the request URI.

Parameters:
query - the query String

serverName

public DataChunk 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.


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 the Host request header.

Parameters:
serverPort - the port as specified in the Host request header

remoteAddr

public DataChunk remoteAddr()
Returns:
the DataChunk representing the Internet Protocol (IP) address of the client or last proxy that sent the request.

getRemoteAddress

public java.lang.String getRemoteAddress()
Returns:
the Internet Protocol (IP) address of the client or last proxy that sent the request.

remoteHost

public DataChunk 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

public java.lang.String 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

public DataChunk localName()
Returns:
a DataChunk representing the host name of the Internet Protocol (IP) interface on which the request was received.

getLocalName

public java.lang.String getLocalName()
Returns:
a String representing the host name of the Internet Protocol (IP) interface on which the request was received.

localAddr

public DataChunk localAddr()
Returns:
a DataChunk representing the Internet Protocol (IP) address of the interface on which the request was received.

getLocalAddress

public java.lang.String 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

public java.lang.String getLocalHost()
Returns:
the host name of the server servicing this request.

setLocalHost

public void setLocalHost(java.lang.String host)
Set the host name of the server servicing this request.

Parameters:
host - the host name of the server servicing this request.

authType

public DataChunk authType()
Return the authentication type used for this Request.


remoteUser

public DataChunk remoteUser()
Return the name of the remote user that has been authenticated for this Request.


createNote

public static <E> Note<E> createNote(java.lang.String name)
Create a named Note associated with this Request.

Type Parameters:
E - the Note type.
Parameters:
name - the Note name.
Returns:
the Note.

getNote

public <E> E getNote(Note<E> note)
Return the Note value associated with this Request, or null if no such binding exists. Use createNote(java.lang.String) to create a new Note.

Parameters:
note - Note value to be returned

getNoteNames

public java.util.Set<java.lang.String> getNoteNames()
Return a Set containing the String names of all note bindings that exist for this request. Use createNote(java.lang.String) to create a new Note.

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

removeNote

public <E> E removeNote(Note<E> note)
Remove the Note value associated with this request. Use createNote(java.lang.String) to create a new Note.

Parameters:
note - Note value to be removed

setNote

public <E> void setNote(Note<E> note,
                        E value)
Bind the Note value to this Request, replacing any existing binding for this name. Use createNote(java.lang.String) to create a new Note.

Parameters:
note - Note to which the object should be bound
value - the Note value be bound to the specified Note.

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Return the specified request attribute if it exists; otherwise, return null.

Parameters:
name - Name of the request attribute to return

getAttributeNames

public java.util.Set<java.lang.String> getAttributeNames()
Return the names of all request attributes for this Request, or an empty Set if there are none.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set the specified request attribute to the specified value.

Parameters:
name - Name of the request attribute to set
value - The associated value

removeAttribute

public void removeAttribute(java.lang.String name)
Remove the specified request attribute if it exists.

Parameters:
name - Name of the request attribute to remove

isHeadRequest

public boolean isHeadRequest()
Returns true if this request is a HEAD request, otherwise returns false.

Returns:
true if this request is a HEAD request, otherwise returns false.

reset

protected void reset()
Reset the internal state.

Overrides:
reset in class HttpHeader

isRequest

public final boolean isRequest()
Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.

Specified by:
isRequest in class HttpHeader
Returns:
true, if the current HttpHeader represent HTTP request message, or false otherwise.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

setResponse

protected void setResponse(HttpResponsePacket response)


Copyright © 2011 Oracle Corpration. All Rights Reserved.