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
Nested ClassesModifier and TypeClassDescriptionstatic classHttpResponsePacket message builder. -
Field Summary
FieldsFields inherited from class org.glassfish.grizzly.http.HttpHeader
contentLength, contentType, headers, isChunked, isCommitted, isContentBroken, isExpectContent, isSkipRemainder, parsedProtocol, protocolC, secure, upgrade -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMark this packet as having been acknowledged.static HttpResponsePacket.Builderbuilder(HttpRequestPacket request) ReturnsHttpResponsePacketbuilder.Gets the HTTP status for this response.final StringGets the status reason phrase for this response.final DataChunkGets the status reason phrase for this response asDataChunk(avoid creation of a String object}.final DataChunkGets the custom status reason phrase for this response asDataChunk(avoid creation of a String object}.intGets the status code for this response.booleanfinal booleanReturnstrueif custom status reason phrases are allowed for this response, orfalse otherwise.final booleanbooleanReturns if we need to encode HTML sensitive characters in custom reason phrase.final booleanReturns true, if the current HttpHeader represent HTTP request message, or false otherwise.protected voidreset()Reset the internal state.voidsetAcknowledgement(boolean acknowledgement) Mark this packet as an acknowledgment to a client expectation.final voidsetAllowCustomReasonPhrase(boolean allowCustomReasonPhrase) Sets if the custom status reason phrases are allowed for this response.voidsetContentLanguage(String contentLanguage) Set the value that will be used by theContent-Languageresponse header.voidsetContentLengthLong(long contentLength) Set the content-length of thisHttpPacket.voidsetHtmlEncodingCustomReasonPhrase(boolean isHtmlEncodingCustomReasonPhrase) Sets if we need to encode HTML sensitive characters in custom reason phrase.voidCalled explicitly by user to set the Content-Language and the default encodingvoidsetReasonPhrase(String message) Sets the status reason phrase for this response.voidsetReasonPhrase(org.glassfish.grizzly.Buffer reason) voidsetRequest(HttpRequestPacket request) Associates the request that triggered this response.voidsetStatus(int status) Sets the status code for this response.voidsetStatus(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, setUpgradeMethods inherited from class org.glassfish.grizzly.http.HttpPacket
isHttp
-
Field Details
-
httpStatus
Status code.
-
-
Constructor Details
-
HttpResponsePacket
protected HttpResponsePacket()
-
-
Method Details
-
builder
ReturnsHttpResponsePacketbuilder.- 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()Returnstrueif custom status reason phrases are allowed for this response, orfalse otherwise.- Returns:
trueif 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-trueif 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:
trueif 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-trueif 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:
resetin classHttpHeader
-
isRequest
public final boolean isRequest()Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.- Specified by:
isRequestin classHttpHeader- Returns:
- true, if the current HttpHeader represent HTTP request message, or false otherwise.
-
toString
-
getLocale
- Returns:
- the
Localeof 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-Languageresponse header
-
setContentLanguage
Set the value that will be used by theContent-Languageresponse header. -
setContentLengthLong
public void setContentLengthLong(long contentLength) Description copied from class:HttpHeaderSet the content-length of thisHttpPacket. Applicable only in case of fixed-length HTTP message.- Overrides:
setContentLengthLongin 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
-