java.lang.Object
org.glassfish.grizzly.http.HttpPacket
org.glassfish.grizzly.http.HttpHeader
org.glassfish.grizzly.http.HttpResponsePacket
- All Implemented Interfaces:
org.glassfish.grizzly.attributes.AttributeStorage
,org.glassfish.grizzly.Cacheable
,MimeHeadersPacket
The
HttpHeader
object, which represents HTTP response message.- Author:
- Alexey Stashok
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
HttpResponsePacket message builder. -
Field Summary
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 TypeMethodDescriptionvoid
Mark this packet as having been acknowledged.static HttpResponsePacket.Builder
builder
(HttpRequestPacket request) ReturnsHttpResponsePacket
builder.Gets the HTTP status for this response.final String
Gets the status reason phrase for this response.final DataChunk
Gets the status reason phrase for this response asDataChunk
(avoid creation of a String object}.final DataChunk
Gets the custom status reason phrase for this response asDataChunk
(avoid creation of a String object}.int
Gets the status code for this response.boolean
final boolean
Returnstrue
if custom status reason phrases are allowed for this response, orfalse otherwise.
final boolean
boolean
Returns if we need to encode HTML sensitive characters in custom reason phrase.final boolean
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.final void
setAllowCustomReasonPhrase
(boolean allowCustomReasonPhrase) Sets if the custom status reason phrases are allowed for this response.void
setContentLanguage
(String contentLanguage) Set the value that will be used by theContent-Language
response header.void
setContentLengthLong
(long contentLength) Set the content-length of thisHttpPacket
.void
setHtmlEncodingCustomReasonPhrase
(boolean isHtmlEncodingCustomReasonPhrase) Sets if we need to encode HTML sensitive characters in custom reason phrase.void
Called explicitly by user to set the Content-Language and the default encodingvoid
setReasonPhrase
(String message) Sets the status reason phrase for this response.void
setReasonPhrase
(org.glassfish.grizzly.Buffer reason) void
setRequest
(HttpRequestPacket request) Associates the request that triggered this response.void
setStatus
(int status) Sets the status code for this response.void
setStatus
(HttpStatus status) Sets the status code for this response.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, 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
-
httpStatus
Status code.
-
-
Constructor Details
-
HttpResponsePacket
protected HttpResponsePacket()
-
-
Method Details
-
builder
ReturnsHttpResponsePacket
builder.- Returns:
HttpResponsePacket.Builder
.
-
getStatus
public int getStatus()Gets the status code for this response.- Returns:
- the status code for this response.
-
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
Sets the status code for this response.- Parameters:
status
- the status for this response.
-
isAllowCustomReasonPhrase
public final boolean isAllowCustomReasonPhrase()Returnstrue
if custom status reason phrases are allowed for this response, orfalse otherwise.
- Returns:
true
if custom status reason phrases are allowed for this response, orfalse 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, orfalse otherwise.
-
isHtmlEncodingCustomReasonPhrase
public boolean isHtmlEncodingCustomReasonPhrase()Returns if we need to encode HTML sensitive characters in custom reason phrase. -
setHtmlEncodingCustomReasonPhrase
public void setHtmlEncodingCustomReasonPhrase(boolean isHtmlEncodingCustomReasonPhrase) Sets if we need to encode HTML sensitive characters in custom reason phrase. -
getReasonPhraseRawDC
Gets the custom status reason phrase for this response asDataChunk
(avoid creation of a String object}.- Returns:
- the status reason phrase for this response as
DataChunk
(avoid creation of a String object}.
-
getReasonPhraseDC
Gets the status reason phrase for this response asDataChunk
(avoid creation of a String object}. This implementation takes into consideration theisAllowCustomReasonPhrase()
property - if the custom reason phrase is allowed and it's value is not null - then the returned result will be equal togetReasonPhraseRawDC()
, otherwise if custom reason phrase is disallowed or its value is null - the default reason phrase for the HTTP responsegetStatus()
will be returned.- Returns:
- the status reason phrase for this response as
DataChunk
(avoid creation of a String object}.
-
getReasonPhrase
Gets the status reason phrase for this response.- Returns:
- the status reason phrase for this response.
-
setReasonPhrase
Sets the status reason phrase for this response.- Parameters:
message
- the status reason phrase for this response.
-
setReasonPhrase
public void setReasonPhrase(org.glassfish.grizzly.Buffer reason) -
isCustomReasonPhraseSet
public final boolean isCustomReasonPhraseSet() -
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.
-
acknowledged
public void acknowledged()Mark this packet as having been acknowledged. -
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
-
getLocale
- Returns:
- the
Locale
of this response.
-
setLocale
Called explicitly by user to set the Content-Language and the default encoding -
getContentLanguage
- Returns:
- the value that will be used by the
Content-Language
response header
-
setContentLanguage
Set the value that will be used by theContent-Language
response header. -
setContentLengthLong
public void setContentLengthLong(long contentLength) Description copied from class:HttpHeader
Set the content-length of thisHttpPacket
. Applicable only in case of fixed-length HTTP message.- Overrides:
setContentLengthLong
in classHttpHeader
- Parameters:
contentLength
- the content-length of thisHttpPacket
. Applicable only in case of fixed-length HTTP message.
-
setRequest
Associates the request that triggered this response.- Parameters:
request
- the request that triggered this response
-