Package org.glassfish.grizzly.http
Class HttpResponsePacket
- 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
public abstract class HttpResponsePacket extends HttpHeader
TheHttpHeaderobject, which represents HTTP response message.- Author:
- Alexey Stashok
- See Also:
HttpHeader,HttpRequestPacket
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpResponsePacket.BuilderHttpResponsePacket message builder.
-
Field Summary
Fields Modifier and Type Field Description protected HttpStatushttpStatusStatus code.-
Fields inherited from class org.glassfish.grizzly.http.HttpHeader
contentLength, contentType, headers, isChunked, isCommitted, isContentBroken, isExpectContent, isSkipRemainder, parsedProtocol, protocolC, secure, upgrade
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpResponsePacket()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacknowledged()Mark this packet as having been acknowledged.static HttpResponsePacket.Builderbuilder(HttpRequestPacket request)ReturnsHttpResponsePacketbuilder.StringgetContentLanguage()HttpStatusgetHttpStatus()Gets the HTTP status for this response.LocalegetLocale()StringgetReasonPhrase()Gets the status reason phrase for this response.DataChunkgetReasonPhraseDC()Gets the status reason phrase for this response asDataChunk(avoid creation of a String object}.DataChunkgetReasonPhraseRawDC()Gets the custom status reason phrase for this response asDataChunk(avoid creation of a String object}.HttpRequestPacketgetRequest()intgetStatus()Gets the status code for this response.booleanisAcknowledgement()booleanisAllowCustomReasonPhrase()Returnstrueif custom status reason phrases are allowed for this response, orfalse otherwise.booleanisCustomReasonPhraseSet()booleanisHtmlEncodingCustomReasonPhrase()Returns if we need to encode HTML sensitive characters in custom reason phrase.booleanisRequest()Returns 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.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.voidsetLocale(Locale locale)Called 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.StringtoString()-
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 Detail
-
httpStatus
protected HttpStatus httpStatus
Status code.
-
-
Method Detail
-
builder
public static HttpResponsePacket.Builder builder(HttpRequestPacket request)
ReturnsHttpResponsePacketbuilder.- 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()
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
public final DataChunk 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
public final DataChunk 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
public final 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.
-
setReasonPhrase
public void setReasonPhrase(org.glassfish.grizzly.Buffer reason)
-
isCustomReasonPhraseSet
public final boolean isCustomReasonPhraseSet()
-
getRequest
public HttpRequestPacket 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.
-
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-Languageresponse header
-
setContentLanguage
public void setContentLanguage(String contentLanguage)
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
public void setRequest(HttpRequestPacket request)
Associates the request that triggered this response.- Parameters:
request- the request that triggered this response
-
-