public abstract class HttpHeader extends HttpPacket implements MimeHeadersPacket, org.glassfish.grizzly.attributes.AttributeStorage
HttpPacket, which represents HTTP message header. There are 2 subtypes of this class:
HttpRequestPacket and HttpResponsePacket.HttpRequestPacket,
HttpResponsePacket| Modifier and Type | Class and Description |
|---|---|
static class |
HttpHeader.Builder<T extends HttpHeader.Builder>
HttpHeader message builder.
|
| Modifier and Type | Field and Description |
|---|---|
protected long |
contentLength |
protected ContentType.SettableContentType |
contentType |
protected MimeHeaders |
headers |
protected boolean |
isChunked |
protected boolean |
isCommitted |
protected boolean |
isContentBroken
true if HTTP message payload is broken due to inappropriate Transfer-Encoding or Content-Encoding settings.
|
protected boolean |
isExpectContent |
protected boolean |
isSkipRemainder |
protected Protocol |
parsedProtocol |
protected DataChunk |
protocolC |
protected boolean |
secure |
protected DataChunk |
upgrade |
| Modifier | Constructor and Description |
|---|---|
|
HttpHeader() |
protected |
HttpHeader(MimeHeaders headers) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addContentEncoding(ContentEncoding contentEncoding) |
void |
addHeader(Header header,
HeaderValue value)
Add the HTTP mime header.
|
void |
addHeader(Header header,
String value)
Add the HTTP mime header.
|
void |
addHeader(String name,
HeaderValue value)
Add the HTTP mime header.
|
void |
addHeader(String name,
String value)
Add the HTTP mime header.
|
boolean |
containsHeader(Header header)
Returns true, if the mime
Header is present among the HttpHeader mime headers, otherwise
returns false. |
boolean |
containsHeader(String name)
Returns true, if the mime header with the specific name is present among the HttpHeader mime
headers, or false otherwise.
|
protected void |
extractContentEncoding(DataChunk value)
Obtain content-encoding value and mark it as serialized.
|
protected void |
flushSpecialHeaders()
Flush internal fields for special header names to the headers map.
|
org.glassfish.grizzly.attributes.AttributeHolder |
getAttributes() |
String |
getCharacterEncoding() |
List<ContentEncoding> |
getContentEncodings() |
protected List<ContentEncoding> |
getContentEncodings(boolean isModifiable) |
long |
getContentLength()
Get the content-length of this
HttpPacket. |
String |
getContentType() |
protected ContentType |
getContentTypeHolder() |
String |
getHeader(Header header)
Get the value, of the specific HTTP mime header.
|
String |
getHeader(String name)
Get the value, of the specific HTTP mime header.
|
MimeHeaders |
getHeaders()
Get all
MimeHeaders, associated with the HttpHeader. |
HttpHeader |
getHttpHeader()
Returns this HttpHeader object.
|
protected HttpPacketParsing |
getParsingState() |
abstract ProcessingState |
getProcessingState() |
Protocol |
getProtocol()
Get HTTP protocol version.
|
DataChunk |
getProtocolDC()
Get the HTTP message protocol version as
DataChunk (avoiding creation of a String object). |
String |
getProtocolString()
Get the HTTP message protocol version.
|
byte[] |
getTempHeaderEncodingBuffer() |
TransferEncoding |
getTransferEncoding()
Get the
TransferEncoding, responsible for the parsing/serialization of the HTTP message content |
String |
getUpgrade() |
DataChunk |
getUpgradeDC() |
HttpContent.Builder |
httpContentBuilder()
Get the HTTP message content builder.
|
HttpTrailer.Builder |
httpTrailerBuilder()
Get the HTTP message trailer-chunk builder.
|
boolean |
isChunked()
Returns true, if this
HttpPacket content will be transferred in chunking mode, or false if
case of fixed-length message. |
boolean |
isChunkingAllowed()
Return
true if chunking is allowed for this header. |
boolean |
isCommitted()
Is this HttpHeader written? true, if this HttpHeader has been already serialized, and only
HttpContent messages might be serialized for this HttpPacket. |
boolean |
isContentBroken()
Returns true, if HTTP packet payload was detected as broken due to unexpected error occurred during
Transfer-Encoding or Content-Encoding processing.
|
protected boolean |
isContentEncodingsSelected() |
boolean |
isContentTypeSet() |
boolean |
isExpectContent()
Returns true, if HTTP message, represented by this header still expects additional content basing either on
content-length or chunking information.
|
boolean |
isHeader()
Returns true.
|
boolean |
isIgnoreContentModifiers() |
abstract boolean |
isRequest()
Returns true, if the current HttpHeader represent HTTP request message, or false
otherwise.
|
boolean |
isSecure() |
boolean |
isSkipRemainder()
Returns true, if either application or HTTP core part is not interested in parsing the rest of this HTTP
message content and waits for the next HTTP message to come on this
Connection. |
boolean |
isUpgrade() |
protected void |
makeContentLengthHeader(long defaultLength)
Makes sure content-length header is present.
|
protected void |
makeTransferEncodingHeader(String defaultValue)
Makes sure transfer-encoding header is present.
|
protected void |
makeUpgradeHeader()
Propagate the "Upgrade" value to headers.
|
void |
recycle() |
protected void |
reset()
Reset the internal state.
|
void |
setCharacterEncoding(String charset)
Set the character encoding of this HTTP message.
|
void |
setChunked(boolean isChunked)
Set true, if this
HttpPacket content will be transferred in chunking mode, or false if case
of fixed-length message. |
void |
setChunkingAllowed(boolean chunkingAllowed)
Indicate whether or not chunking may be used by this header.
|
void |
setCommitted(boolean isCommitted)
Is this HttpHeader written? true, if this HttpHeader has been already serialized, and only
HttpContent messages might be serialized for this HttpPacket. |
void |
setContentBroken(boolean isBroken)
Set flag, which is set to true, means that HTTP packet payload was detected as broken due to unexpected
error occurred during Transfer-Encoding or Content-Encoding processing.
|
protected void |
setContentEncodingsSelected(boolean isContentEncodingsSelected) |
void |
setContentLength(int len)
Set the length of this HTTP message.
|
void |
setContentLengthLong(long contentLength)
Set the content-length of this
HttpPacket. |
void |
setContentType(ContentType contentType)
Sets the content type.
|
void |
setContentType(String contentType)
Sets the content type.
|
void |
setExpectContent(boolean isExpectContent) |
void |
setHeader(Header header,
HeaderValue value)
Set the value, of the specific HTTP mime header.
|
void |
setHeader(Header header,
String value)
Set the value, of the specific HTTP mime header.
|
void |
setHeader(String name,
HeaderValue value)
Set the value, of the specific HTTP mime header.
|
void |
setHeader(String name,
String value)
Set the value, of the specific HTTP mime header.
|
void |
setIgnoreContentModifiers(boolean isIgnoreContentModifiers)
Set true if parser has to ignore "Transfer-Encoding" and "Content-Encoding" headers and act as none of them
were specified.
|
void |
setProtocol(Protocol protocol)
Set the HTTP message protocol version.
|
void |
setSecure(boolean secure)
Sets the secure status of this HTTP message.
|
void |
setSkipRemainder(boolean isSkipRemainder)
Set flag, which is set to true, means that we're not interested in parsing the rest of this HTTP message
content and wait for the next HTTP message to come on this
Connection. |
protected void |
setTransferEncoding(TransferEncoding transferEncoding)
Set the
TransferEncoding, responsible for the parsing/serialization of the HTTP message content. |
void |
setUpgrade(String upgrade)
Sets the "Upgrade" header value
|
isHttpprotected boolean isCommitted
protected final MimeHeaders headers
protected final DataChunk protocolC
protected Protocol parsedProtocol
protected boolean isChunked
protected long contentLength
protected final ContentType.SettableContentType contentType
protected boolean isExpectContent
protected boolean isSkipRemainder
protected boolean isContentBroken
protected boolean secure
protected final DataChunk upgrade
public HttpHeader()
protected HttpHeader(MimeHeaders headers)
public org.glassfish.grizzly.attributes.AttributeHolder getAttributes()
getAttributes in interface org.glassfish.grizzly.attributes.AttributeStoragepublic abstract boolean isRequest()
public final boolean isHeader()
isHeader in class HttpPacketpublic HttpHeader getHttpHeader()
getHttpHeader in class HttpPacketpublic abstract ProcessingState getProcessingState()
protected HttpPacketParsing getParsingState()
protected void addContentEncoding(ContentEncoding contentEncoding)
protected List<ContentEncoding> getContentEncodings(boolean isModifiable)
public List<ContentEncoding> getContentEncodings()
protected final boolean isContentEncodingsSelected()
protected final void setContentEncodingsSelected(boolean isContentEncodingsSelected)
public TransferEncoding getTransferEncoding()
TransferEncoding, responsible for the parsing/serialization of the HTTP message contentTransferEncoding, responsible for the parsing/serialization of the HTTP message contentprotected void setTransferEncoding(TransferEncoding transferEncoding)
TransferEncoding, responsible for the parsing/serialization of the HTTP message content.transferEncoding - the TransferEncoding, responsible for the parsing/serialization of the HTTP message
content.public boolean isChunked()
HttpPacket content will be transferred in chunking mode, or false if
case of fixed-length message.HttpPacket content will be transferred in chunking mode, or false if
case of fixed-length message.public void setChunked(boolean isChunked)
HttpPacket content will be transferred in chunking mode, or false if case
of fixed-length message.
NOTE: If the protocol version of this header is 1.0 or older, chunking will be disabled regardless of the value
passed.isChunked - true, if this HttpPacket content will be transferred in chunking mode, or
false if case of fixed-length message.public boolean isExpectContent()
public void setExpectContent(boolean isExpectContent)
public boolean isSkipRemainder()
Connection.
Otherwise returns false.Connection.
Otherwise returns false.public void setSkipRemainder(boolean isSkipRemainder)
Connection.isSkipRemainder - true means that we're not interested in parsing the rest of this HTTP message content
and wait for the next HTTP message to come on this Connection.public boolean isContentBroken()
public void setContentBroken(boolean isBroken)
isBroken - true, means that HTTP packet payload was detected as broken due to unexpected error occurred
during Transfer-Encoding or Content-Encoding processing.public final String getUpgrade()
public DataChunk getUpgradeDC()
public final void setUpgrade(String upgrade)
upgrade - public boolean isUpgrade()
true if this header represents an HTTP upgrade, otherwise false.protected void makeUpgradeHeader()
public boolean isIgnoreContentModifiers()
public void setIgnoreContentModifiers(boolean isIgnoreContentModifiers)
isIgnoreContentModifiers - protected void makeContentLengthHeader(long defaultLength)
defaultLength - default content-length value.public long getContentLength()
HttpPacket. Applicable only in case of fixed-length HTTP message.HttpPacket. Applicable only in case of fixed-length HTTP message.public void setContentLength(int len)
len - the length of this HTTP message.public void setContentLengthLong(long contentLength)
HttpPacket. Applicable only in case of fixed-length HTTP message.contentLength - the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP
message.public boolean isCommitted()
HttpContent messages might be serialized for this HttpPacket.HttpContent messages
might be serialized for this HttpPacket.public void setCommitted(boolean isCommitted)
HttpContent messages might be serialized for this HttpPacket.isCommitted - true, if this HttpHeader has been already serialized, and only
HttpContent messages might be serialized for this HttpPacket.protected void makeTransferEncodingHeader(String defaultValue)
defaultValue - default transfer-encoding value.protected void extractContentEncoding(DataChunk value)
value - container for the content-type value.public String getCharacterEncoding()
public void setCharacterEncoding(String charset)
charset - the encoding.public boolean isChunkingAllowed()
true if chunking is allowed for this header.true if chunking is allowed for this header.public void setChunkingAllowed(boolean chunkingAllowed)
chunkingAllowed - true if chunked transfer-encoding is allowed, otherwise returns
false.public boolean isContentTypeSet()
true if a content type has been set.public String getContentType()
public void setContentType(String contentType)
contentType - the content typepublic void setContentType(ContentType contentType)
contentType - the content typeprotected ContentType getContentTypeHolder()
ContentType holderpublic MimeHeaders getHeaders()
MimeHeaders, associated with the HttpHeader.getHeaders in interface MimeHeadersPacketMimeHeaders, associated with the HttpHeaderpublic String getHeader(String name)
getHeader in interface MimeHeadersPacketname - the mime header namepublic String getHeader(Header header)
getHeader in interface MimeHeadersPacketheader - the mime Headerpublic void setHeader(String name, String value)
setHeader in interface MimeHeadersPacketname - the mime header namevalue - the mime header valuepublic void setHeader(String name, HeaderValue value)
setHeader in interface MimeHeadersPacketname - the mime header namevalue - the mime header valuepublic void setHeader(Header header, String value)
setHeader in interface MimeHeadersPacketheader - the mime Headervalue - the mime header valuepublic void setHeader(Header header, HeaderValue value)
setHeader in interface MimeHeadersPacketheader - the mime Headervalue - the mime header valuepublic void addHeader(String name, String value)
addHeader in interface MimeHeadersPacketname - the mime header namevalue - the mime header valuepublic void addHeader(String name, HeaderValue value)
addHeader in interface MimeHeadersPacketname - the mime header namevalue - the mime header valuepublic void addHeader(Header header, String value)
addHeader in interface MimeHeadersPacketheader - the mime Headervalue - the mime header valuepublic void addHeader(Header header, HeaderValue value)
addHeader in interface MimeHeadersPacketheader - the mime Headervalue - the mime header valuepublic boolean containsHeader(String name)
containsHeader in interface MimeHeadersPacketname - the mime header namepublic boolean containsHeader(Header header)
Header is present among the HttpHeader mime headers, otherwise
returns false.containsHeader in interface MimeHeadersPacketheader - the mime HeaderHeader is present among the HttpHeader mime headers, otherwise
returns falsepublic DataChunk getProtocolDC()
DataChunk (avoiding creation of a String object). The result format
is "HTTP/1.x".DataChunk (avoiding creation of a String object). The result
format is "HTTP/1.x".public String getProtocolString()
public void setProtocol(Protocol protocol)
protocol - Protocolpublic boolean isSecure()
true if this HTTP message is being transmitted in a secure fashion, otherwise returns
false.public void setSecure(boolean secure)
secure - true if secure, otherwise false.public final HttpContent.Builder httpContentBuilder()
HttpContent.Builder.public HttpTrailer.Builder httpTrailerBuilder()
HttpTrailer.Builder.protected void reset()
public void recycle()
recycle in interface org.glassfish.grizzly.Cacheablepublic byte[] getTempHeaderEncodingBuffer()
protected void flushSpecialHeaders()
Copyright © 2017–2021 Oracle Corporation. All rights reserved.