Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http

public abstract Class HttpResponsePacket

extends HttpHeader
Class Inheritance
Known Direct Subclasses
org.glassfish.grizzly.http.HttpResponsePacketImpl, org.glassfish.grizzly.http.HttpClientFilter.ClientHttpResponseImpl
Imports
java.util.Locale, org.glassfish.grizzly.Buffer, org.glassfish.grizzly.http.util.DataChunk, .HttpStatus, .MimeHeaders

The HttpHeader object, which represents HTTP response message.
Author
Alexey Stashok
See Also
HttpHeader, HttpRequestPacket

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
HttpResponsePacket.Builder

HttpResponsePacket message builder.

Field Summary

Modifier and TypeField and Description
private boolean
allowCustomReasonPhrase

Do we allow custom reason phrase.

private String
contentLanguage

The value of the Content-Language response header.

protected HttpStatus
httpStatus

Status code.

private HttpStatus
interimStatus

Status of the informational (1xx) interim response (e.g. HttpStatus#EARLY_HINTS_103 or HttpStatus#CONINTUE_100) that is pending serialization.

private boolean
isHtmlEncodingCustomReasonPhrase

Do we need to encode HTML sensitive characters in custom reason phrase.

private Locale
locale

The Locale of the entity body being sent by this response.

private final DataChunk
reasonPhraseC

Status message.

private HttpRequestPacket
request

The request that triggered this response.

Inherited from org.glassfish.grizzly.http.HttpHeader:
contentLengthcontentTypeheaderBufferheadersisChunkedisCommittedisContentBrokenisExpectContentisSkipRemainderparsedProtocolprotocolCsecureupgrade

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static HttpResponsePacket.Builder

Returns:

Builder.
builder
(final HttpRequestPacket request)

Returns HttpResponsePacket builder.

public String
getContentLanguage()

Returns: the value that will be used by the Content-Language response header

public HttpStatus

Returns:

the HTTP status for this response.
getHttpStatus
()

Gets the HTTP status for this response.

public HttpStatus
getInterimStatus()

Returns: the status of the interim response pending serialization, or null if none is pending.

public Locale
getLocale()

Returns: the Locale of this response.

public final String

Returns:

the status reason phrase for this response.
getReasonPhrase
()

Gets the status reason phrase for this response.

public final DataChunk

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 as DataChunk (avoid creation of a String object}.

public final DataChunk

Returns:

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

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

public HttpRequestPacket
getRequest()

Returns: the request that triggered this response

public int

Returns:

the status code for this response.
getStatus
()

Gets the status code for this response.

public void
interimResponseSent()

Mark the pending interim response as having been serialized.

public final boolean

Returns:

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

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

public final boolean
public boolean
isHtmlEncodingCustomReasonPhrase()

Returns if we need to encode HTML sensitive characters in custom reason phrase.

public boolean
isInterimResponse()

Returns: true if an informational (1xx) interim response is pending serialization for this packet.

public final boolean
isRequest()

Implements abstract org.glassfish.grizzly.http.HttpHeader.isRequest.

Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.

protected void
reset()

Overrides org.glassfish.grizzly.http.HttpHeader.reset.

Reset the internal state.

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

Sets if the custom status reason phrases are allowed for this response.

public void
setContentLanguage(final String contentLanguage)

Set the value that will be used by the Content-Language response header.

public void
setContentLengthLong(long contentLength)

Overrides org.glassfish.grizzly.http.HttpHeader.setContentLengthLong.

Set the content-length of this HttpPacket.

public void
setHtmlEncodingCustomReasonPhrase(boolean isHtmlEncodingCustomReasonPhrase)

Sets if we need to encode HTML sensitive characters in custom reason phrase.

public void
setInterimStatus(final HttpStatus
the 1xx status of the interim response to serialize.
interimStatus
)

Request the serialization of an informational (1xx) interim response, such as HttpStatus#EARLY_HINTS_103, using the headers currently set on this packet.

public void
setLocale(final Locale locale)

Called explicitly by user to set the Content-Language and the default encoding

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

Sets the status reason phrase for this response.

public void
setReasonPhrase(final Buffer reason)

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

Associates the request that triggered this response.

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

Sets the status code for this response.

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

Sets the status code for this response.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.glassfish.grizzly.http.HttpHeader:
addContentEncodingaddHeaderaddHeaderaddHeaderaddHeadercontainsHeadercontainsHeaderextractContentEncodingflushSpecialHeadersgetAttributesgetCharacterEncodinggetContentEncodingsgetContentEncodingsgetContentLengthgetContentTypegetContentTypeHoldergetHeadergetHeadergetHeadersgetHttpHeadergetParsingStategetProcessingStategetProtocolgetProtocolDCgetProtocolStringgetTempHeaderEncodingBuffergetTransferEncodinggetUpgradegetUpgradeDChttpContentBuilderhttpTrailerBuilderisChunkedisChunkingAllowedisCommittedisContentBrokenisContentEncodingsSelectedisContentTypeSetisExpectContentisHeaderisIgnoreContentModifiersisSecureisSkipRemainderisUpgrademakeContentLengthHeadermakeTransferEncodingHeadermakeUpgradeHeaderrecyclesetCharacterEncodingsetChunkedsetChunkingAllowedsetCommittedsetContentBrokensetContentEncodingsSelectedsetContentLengthsetContentTypesetContentTypesetExpectContentsetHeadersetHeadersetHeadersetHeadersetHeaderBuffersetIgnoreContentModifierssetProtocolsetSecuresetSkipRemaindersetTransferEncodingsetUpgrade

Field Detail

allowCustomReasonPhraseback to summary
private boolean allowCustomReasonPhrase

Do we allow custom reason phrase.

contentLanguageback to summary
private String contentLanguage

The value of the Content-Language response header.

httpStatusback to summary
protected HttpStatus httpStatus

Status code.

interimStatusback to summary
private HttpStatus interimStatus

Status of the informational (1xx) interim response (e.g. HttpStatus#EARLY_HINTS_103 or HttpStatus#CONINTUE_100) that is pending serialization. Held separately from httpStatus so that serializing an interim response does not disturb the status of the final response. Non-null only between the moment an interim response is requested and the moment it has been serialized.

isHtmlEncodingCustomReasonPhraseback to summary
private boolean isHtmlEncodingCustomReasonPhrase

Do we need to encode HTML sensitive characters in custom reason phrase.

localeback to summary
private Locale locale

The Locale of the entity body being sent by this response.

reasonPhraseCback to summary
private final DataChunk reasonPhraseC

Status message.

requestback to summary
private HttpRequestPacket request

The request that triggered this response.

Constructor Detail

HttpResponsePacketback to summary
protected HttpResponsePacket()

Method Detail

builderback to summary
public static HttpResponsePacket.Builder builder(final HttpRequestPacket request)

Returns HttpResponsePacket builder.

Returns:HttpResponsePacket.Builder

Builder.

getContentLanguageback to summary
public String getContentLanguage()
Returns:String

the value that will be used by the Content-Language response header

getHttpStatusback to summary
public HttpStatus getHttpStatus()

Gets the HTTP status for this response.

Returns:HttpStatus

the HTTP status for this response.

getInterimStatusback to summary
public HttpStatus getInterimStatus()
Returns:HttpStatus

the status of the interim response pending serialization, or null if none is pending.

getLocaleback to summary
public Locale getLocale()
Returns:Locale

the Locale of this response.

getReasonPhraseback to summary
public final String getReasonPhrase()

Gets the status reason phrase for this response.

Returns:String

the status reason phrase for this response.

getReasonPhraseDCback to summary
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:DataChunk

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

getReasonPhraseRawDCback to summary
public final DataChunk getReasonPhraseRawDC()

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

Returns:DataChunk

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

getRequestback to summary
public HttpRequestPacket getRequest()
Returns:HttpRequestPacket

the request that triggered this response

getStatusback to summary
public int getStatus()

Gets the status code for this response.

Returns:int

the status code for this response.

interimResponseSentback to summary
public void interimResponseSent()

Mark the pending interim response as having been serialized. If the interim status was 100 Continue, the associated request's expectation flag is also cleared so that subsequent processing no longer treats the request as awaiting acknowledgement.

isAllowCustomReasonPhraseback to summary
public final boolean isAllowCustomReasonPhrase()

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

Returns:boolean

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

isCustomReasonPhraseSetback to summary
public final boolean isCustomReasonPhraseSet()
isHtmlEncodingCustomReasonPhraseback to summary
public boolean isHtmlEncodingCustomReasonPhrase()

Returns if we need to encode HTML sensitive characters in custom reason phrase.

isInterimResponseback to summary
public boolean isInterimResponse()
Returns:boolean

true if an informational (1xx) interim response is pending serialization for this packet.

isRequestback to summary
public final boolean isRequest()

Implements abstract org.glassfish.grizzly.http.HttpHeader.isRequest.

Doc from org.glassfish.grizzly.http.HttpHeader.isRequest.

Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.

Annotations
@Override
resetback to summary
protected void reset()

Overrides org.glassfish.grizzly.http.HttpHeader.reset.

Doc from org.glassfish.grizzly.http.HttpHeader.reset.

Reset the internal state.

Annotations
@Override
setAllowCustomReasonPhraseback to summary
public final void setAllowCustomReasonPhrase(final boolean allowCustomReasonPhrase)

Sets if the custom status reason phrases are allowed for this response.

Parameters
allowCustomReasonPhrase:boolean

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

setContentLanguageback to summary
public void setContentLanguage(final String contentLanguage)

Set the value that will be used by the Content-Language response header.

setContentLengthLongback to summary
public void setContentLengthLong(long contentLength)

Overrides org.glassfish.grizzly.http.HttpHeader.setContentLengthLong.

Doc from org.glassfish.grizzly.http.HttpHeader.setContentLengthLong.

Set the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.

Annotations
@Override
setHtmlEncodingCustomReasonPhraseback to summary
public void setHtmlEncodingCustomReasonPhrase(boolean isHtmlEncodingCustomReasonPhrase)

Sets if we need to encode HTML sensitive characters in custom reason phrase.

setInterimStatusback to summary
public void setInterimStatus(final HttpStatus interimStatus)

Request the serialization of an informational (1xx) interim response, such as HttpStatus#EARLY_HINTS_103, using the headers currently set on this packet. This does not affect the status, headers or committed state of the final response.

Parameters
interimStatus:HttpStatus

the 1xx status of the interim response to serialize.

setLocaleback to summary
public void setLocale(final Locale locale)

Called explicitly by user to set the Content-Language and the default encoding

setReasonPhraseback to summary
public void setReasonPhrase(final String message)

Sets the status reason phrase for this response.

Parameters
message:String

the status reason phrase for this response.

setReasonPhraseback to summary
public void setReasonPhrase(final Buffer reason)
setRequestback to summary
public void setRequest(final HttpRequestPacket request)

Associates the request that triggered this response.

Parameters
request:HttpRequestPacket

the request that triggered this response

setStatusback to summary
public void setStatus(final int status)

Sets the status code for this response.

Parameters
status:int

the status code for this response.

setStatusback to summary
public void setStatus(final HttpStatus status)

Sets the status code for this response.

Parameters
status:HttpStatus

the status for this response.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
org.glassfish.grizzly.http back to summary

public Class HttpResponsePacket.Builder

extends HttpHeader.Builder<HttpResponsePacket.Builder>
Class Inheritance

HttpResponsePacket message builder.

Field Summary

Modifier and TypeField and Description
protected String
protected HttpRequestPacket
protected Integer
Inherited from org.glassfish.grizzly.http.HttpHeader.Builder:
chunkedcontentLengthcontentTypemimeHeadersprotocolprotocolStringupgrade

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final HttpResponsePacket

Returns:

HttpResponsePacket
build
()

Overrides org.glassfish.grizzly.http.HttpHeader.Builder.build.

Build the HttpResponsePacket message.

protected HttpHeader
public HttpResponsePacket.Builder
reasonPhrase(final String
the status reason phrase for this response.
reasonPhrase
)

Sets the status reason phrase for this response.

public HttpResponsePacket.Builder
requestPacket(final HttpRequestPacket requestPacket)

public void
public HttpResponsePacket.Builder
status(final int
the status code for this response.
status
)

Sets the status code for this response.

Inherited from org.glassfish.grizzly.http.HttpHeader.Builder:
chunkedcontentLengthcontentTypeheaderheadermaxNumHeadersprotocolprotocolremoveHeaderremoveHeaderupgrade

Field Detail

reasonPhraseback to summary
protected String reasonPhrase
requestPacketback to summary
protected HttpRequestPacket requestPacket
statusback to summary
protected Integer status

Constructor Detail

Builderback to summary
public Builder()

Method Detail

buildback to summary
public final HttpResponsePacket build()

Overrides org.glassfish.grizzly.http.HttpHeader.Builder.build.

Build the HttpResponsePacket message.

Returns:HttpResponsePacket

HttpResponsePacket

Annotations
@Override
createback to summary
protected HttpHeader create()

Implements abstract org.glassfish.grizzly.http.HttpHeader.Builder.create.

Annotations
@Override
reasonPhraseback to summary
public HttpResponsePacket.Builder reasonPhrase(final String reasonPhrase)

Sets the status reason phrase for this response.

Parameters
reasonPhrase:String

the status reason phrase for this response.

requestPacketback to summary
public HttpResponsePacket.Builder requestPacket(final HttpRequestPacket requestPacket)
resetback to summary
public void reset()

Overrides org.glassfish.grizzly.http.HttpHeader.Builder.reset.

Annotations
@Override
statusback to summary
public HttpResponsePacket.Builder status(final int status)

Sets the status code for this response.

Parameters
status:int

the status code for this response.