org.glassfish.grizzly.http
Class HttpResponsePacket

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

public abstract class HttpResponsePacket
extends HttpHeader

The HttpHeader object, which represents HTTP response message.

Author:
Alexey Stashok
See Also:
HttpHeader, HttpRequestPacket

Nested Class Summary
static class HttpResponsePacket.Builder
          HttpResponsePacket message builder.
 
Field Summary
static int NON_PARSED_STATUS
           
protected  int parsedStatusInt
          Status code.
protected  BufferChunk statusBC
           
 
Fields inherited from class org.glassfish.grizzly.http.HttpHeader
charEncoding, charEncodingParsed, contentLength, contentType, contentTypeParsed, headers, isChunked, isCommitted, isExpectContent, isSkipRemainder, parsedProtocol, protocolBC, secure, upgrade
 
Constructor Summary
protected HttpResponsePacket()
           
 
Method Summary
 void acknowledged()
          Mark this packet as having been acknowledged.
 void addHeader(String name, String value)
          Add the HTTP mime header.
static HttpResponsePacket.Builder builder(HttpRequestPacket request)
          Returns HttpResponsePacket builder.
 String getContentLanguage()
           
 Locale getLocale()
           
 String getReasonPhrase()
          Gets the status reason phrase for this response.
 BufferChunk getReasonPhraseBC(boolean useDefault)
          Gets the status reason phrase for this response as BufferChunk (avoid creation of a String object}.
 HttpRequestPacket getRequest()
           
 int getStatus()
          Gets the status code for this response.
 BufferChunk getStatusBC()
          Gets the status code for this response as BufferChunk (avoid the status code parsing}.
 boolean isAcknowledgement()
           
 boolean isRequest()
          Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.
protected  void reset()
          Reset the internal state.
 void setAcknowledgement(boolean acknowledgement)
          Mark this packet as an acknowledgement to a client expectation.
 void setContentLanguage(String contentLanguage)
          Set the value that will be used by the Content-Language response header.
 void setHeader(String name, String value)
          Set the value, of the specific HTTP mime header.
 void setLocale(Locale locale)
          Called explicitly by user to set the Content-Language and the default encoding
 void setReasonPhrase(String message)
          Sets the status reason phrase for this response.
 void setRequest(HttpRequestPacket request)
          Associates the request that triggered this response.
 void setStatus(int status)
          Sets the status code for this response.
 String toString()
          
 
Methods inherited from class org.glassfish.grizzly.http.HttpHeader
addContentEncoding, containsHeader, extractContentEncoding, extractContentType, getAttributes, getCharacterEncoding, getContentEncodings, getContentEncodings, getContentLength, getContentType, getHeader, getHeaders, getProcessingState, getProtocol, getProtocolBC, getProtocolString, getTransferEncoding, getUpgrade, getUpgradeBC, httpContentBuilder, httpTrailerBuilder, isChunked, isCommitted, isExpectContent, isHeader, isSecure, isSkipRemainder, makeContentLengthHeader, makeTransferEncodingHeader, makeUpgradeHeader, recycle, setCharacterEncoding, setChunked, setCommitted, setContentLength, setContentLength, setContentType, setExpectContent, setProtocol, setSecure, setSkipRemainder, setTransferEncoding, setUpgrade
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NON_PARSED_STATUS

public static final int NON_PARSED_STATUS
See Also:
Constant Field Values

parsedStatusInt

protected int parsedStatusInt
Status code.


statusBC

protected final BufferChunk statusBC
Constructor Detail

HttpResponsePacket

protected HttpResponsePacket()
Method Detail

builder

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

Returns:
HttpResponsePacket.Builder.

getStatusBC

public BufferChunk getStatusBC()
Gets the status code for this response as BufferChunk (avoid the status code parsing}.

Returns:
the status code for this response as BufferChunk (avoid the status code parsing}.

getStatus

public int getStatus()
Gets the status code for this response.

Returns:
the status code for this response.

setStatus

public void setStatus(int status)
Sets the status code for this response.

Parameters:
status - the status code for this response.

getReasonPhraseBC

public BufferChunk getReasonPhraseBC(boolean useDefault)
Gets the status reason phrase for this response as BufferChunk (avoid creation of a String object}.

Parameters:
useDefault - if true and no reason phase has been explicitly set, the default as defined by RFC 2616 will be returned.
Returns:
the status reason phrase for this response as BufferChunk (avoid creation of a String object}.

getReasonPhrase

public String getReasonPhrase()
Gets the status reason phrase for this response.

Returns:
the status reason phrase for this response.

setReasonPhrase

public void setReasonPhrase(String message)
Sets the status reason phrase for this response.

Parameters:
message - the status reason phrase for this response.

getRequest

public HttpRequestPacket getRequest()
Returns:
the request that triggered this response

isAcknowledgement

public boolean isAcknowledgement()
Returns:
true if this response packet is intended as an acknowledgement to an expectation from a client request.

setAcknowledgement

public void setAcknowledgement(boolean acknowledgement)
Mark this packet as an acknowledgement to a client expectation.

Parameters:
acknowledgement - true if this packet is an acknowledgement to a client expectation.

acknowledged

public void acknowledged()
Mark this packet as having been acknowledged.


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 String toString()

Overrides:
toString in class Object

setHeader

public void setHeader(String name,
                      String value)
Description copied from class: HttpHeader
Set the value, of the specific HTTP mime header.

Specified by:
setHeader in interface MimeHeadersPacket
Overrides:
setHeader in class HttpHeader
Parameters:
name - the mime header name.
value - the mime header value.

addHeader

public void addHeader(String name,
                      String value)
Description copied from class: HttpHeader
Add the HTTP mime header.

Specified by:
addHeader in interface MimeHeadersPacket
Overrides:
addHeader in class HttpHeader
Parameters:
name - the mime header name.
value - the mime header value.

getLocale

public Locale getLocale()
Returns:
the Locale of this response.

setLocale

public void setLocale(Locale locale)
Called explicitly by user to set the Content-Language and the default encoding


getContentLanguage

public String getContentLanguage()
Returns:
the value that will be used by the Content-Language response header

setContentLanguage

public void setContentLanguage(String contentLanguage)
Set the value that will be used by the Content-Language response header.


setRequest

public void setRequest(HttpRequestPacket request)
Associates the request that triggered this response.

Parameters:
request - the request that triggered this response


Copyright © 2010 Oracle Corpration. All Rights Reserved.