org.glassfish.grizzly.http
Class HttpResponsePacket

java.lang.Object
  extended by org.glassfish.grizzly.http.HttpPacket
      extended by org.glassfish.grizzly.http.HttpHeader
          extended by org.glassfish.grizzly.http.HttpResponsePacket
All Implemented Interfaces:
AttributeStorage, Cacheable, 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
protected  HttpStatus httpStatus
          Status code.
 
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 HttpResponsePacket()
           
 
Method Summary
 void acknowledged()
          Mark this packet as having been acknowledged.
 void addHeader(java.lang.String name, java.lang.String value)
          Add the HTTP mime header.
static HttpResponsePacket.Builder builder(HttpRequestPacket request)
          Returns HttpResponsePacket builder.
 java.lang.String getContentLanguage()
           
 HttpStatus getHttpStatus()
          Gets the HTTP status for this response.
 java.util.Locale getLocale()
           
 java.lang.String getReasonPhrase()
          Gets the status reason phrase for this response.
 DataChunk getReasonPhraseDC()
          Gets the status reason phrase for this response as DataChunk (avoid creation of a String object}.
 DataChunk getReasonPhraseRawDC()
          Gets the custom status reason phrase for this response as DataChunk (avoid creation of a String object}.
 HttpRequestPacket getRequest()
           
 int getStatus()
          Gets the status code for this response.
 boolean isAcknowledgement()
           
 boolean isAllowCustomReasonPhrase()
          Returns true if custom status reason phrases are allowed for this response, or false otherwise.
 boolean isChunkingAllowed()
          Return true if chunking is allowed for this response.
 boolean isCustomReasonPhraseSet()
           
 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 acknowledgment to a client expectation.
 void setAllowCustomReasonPhrase(boolean allowCustomReasonPhrase)
          Sets if the custom status reason phrases are allowed for this response.
 void setChunkingAllowed(boolean chunkingAllowed)
          Indicate whether or not chunking may be used by this response.
 void setContentLanguage(java.lang.String contentLanguage)
          Set the value that will be used by the Content-Language response header.
 void setHeader(Header header, java.lang.String value)
          Set the value, of the specific HTTP mime header.
 void setHeader(java.lang.String name, java.lang.String value)
          Set the value, of the specific HTTP mime header.
 void setLocale(java.util.Locale locale)
          Called explicitly by user to set the Content-Language and the default encoding
 void setReasonPhrase(Buffer reason)
           
 void setReasonPhrase(java.lang.String message)
          Sets the status reason phrase for this response.
 void setRequest(HttpRequestPacket request)
          Associates the request that triggered this response.
 void setStatus(HttpStatus status)
          Sets the status code for this response.
 void setStatus(int status)
          Sets the status code for this response.
 java.lang.String toString()
          
 
Methods inherited from class org.glassfish.grizzly.http.HttpHeader
addContentEncoding, 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, isContentEncodingsSelected, isContentTypeSet, isExpectContent, isHeader, isSecure, isSkipRemainder, makeContentLengthHeader, makeTransferEncodingHeader, makeUpgradeHeader, recycle, serializeContentType, setCharacterEncoding, setChunked, setCommitted, setContentEncodingsSelected, setContentLength, setContentLengthLong, setContentType, setDefaultContentType, setExpectContent, 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

httpStatus

protected HttpStatus httpStatus
Status code.

Constructor Detail

HttpResponsePacket

protected HttpResponsePacket()
Method Detail

builder

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

Returns:
HttpResponsePacket.Builder.

getStatus

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

Returns:
the status code for this response.

getHttpStatus

public HttpStatus getHttpStatus()
Gets the HTTP status for this response.

Returns:
the HTTP status for this response.

setStatus

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

Parameters:
status - the status code for this response.

setStatus

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

Parameters:
status - the status for this response.

isAllowCustomReasonPhrase

public final boolean isAllowCustomReasonPhrase()
Returns true if custom status reason phrases are allowed for this response, or false otherwise.

Returns:
true if custom status reason phrases are allowed for this response, or false otherwise.

setAllowCustomReasonPhrase

public final void setAllowCustomReasonPhrase(boolean allowCustomReasonPhrase)
Sets if the custom status reason phrases are allowed for this response.

Parameters:
allowCustomReasonPhrase - true if custom status reason phrases are allowed for this response, or false otherwise.

getReasonPhraseRawDC

public final DataChunk getReasonPhraseRawDC()
Gets the custom status reason phrase for this response as DataChunk (avoid creation of a String object}.

Returns:
the status reason phrase for this response as DataChunk (avoid creation of a String object}.

getReasonPhraseDC

public final DataChunk getReasonPhraseDC()
Gets the status reason phrase for this response as DataChunk (avoid creation of a String object}. This implementation takes into consideration the isAllowCustomReasonPhrase() property - if the custom reason phrase is allowed and it's value is not null - then the returned result will be equal to getReasonPhraseRawDC(), otherwise if custom reason phrase is disallowed or its value is null - the default reason phrase for the HTTP response getStatus() will be returned.

Returns:
the status reason phrase for this response as DataChunk (avoid creation of a String object}.

getReasonPhrase

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

Returns:
the status reason phrase for this response.

setReasonPhrase

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

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

setReasonPhrase

public void setReasonPhrase(Buffer reason)

isCustomReasonPhraseSet

public final boolean isCustomReasonPhraseSet()

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 acknowledgment to an expectation from a client request.

setAcknowledgement

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

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

isChunkingAllowed

public boolean isChunkingAllowed()
Return true if chunking is allowed for this response.

Returns:
true if chunking is allowed for this response.
Since:
2.1.2

setChunkingAllowed

public void setChunkingAllowed(boolean chunkingAllowed)
Indicate whether or not chunking may be used by this response.

Parameters:
chunkingAllowed - true if chunked transfer-encoding is allowed, otherwise returns false.
Since:
2.1.2

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

Overrides:
toString in class java.lang.Object

setHeader

public void setHeader(java.lang.String name,
                      java.lang.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.

setHeader

public void setHeader(Header header,
                      java.lang.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:
header - the mime Header.
value - the mime header value.

addHeader

public void addHeader(java.lang.String name,
                      java.lang.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 java.util.Locale getLocale()
Returns:
the Locale of this response.

setLocale

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


getContentLanguage

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

setContentLanguage

public void setContentLanguage(java.lang.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 © 2011 Oracle Corpration. All Rights Reserved.