public abstract class HttpHeader extends HttpPacket implements MimeHeadersPacket, 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 String |
characterEncoding |
protected boolean |
charsetSet
Has the charset been explicitly set.
|
protected long |
contentLength |
protected String |
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 String |
quotedCharsetValue |
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,
String 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.
|
AttributeHolder |
getAttributes()
Get associated
AttributeHolder . |
String |
getCharacterEncoding() |
List<ContentEncoding> |
getContentEncodings() |
protected List<ContentEncoding> |
getContentEncodings(boolean isModifiable) |
long |
getContentLength()
Get the content-length of this
HttpPacket . |
String |
getContentType() |
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.
|
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() |
protected String |
handleGetSpecialHeader(Header header) |
protected String |
handleGetSpecialHeader(String name) |
protected boolean |
handleSetSpecialHeaders(Header header,
String value) |
protected boolean |
handleSetSpecialHeaders(String name,
String value) |
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.
|
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 . |
protected static boolean |
isSpecialHeader(String name) |
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() |
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(String type)
Sets the content type.
|
void |
setExpectContent(boolean isExpectContent) |
void |
setHeader(Header header,
String 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 |
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) |
isHttp
protected boolean isCommitted
protected MimeHeaders headers
protected final DataChunk protocolC
protected Protocol parsedProtocol
protected boolean isChunked
protected long contentLength
protected String characterEncoding
protected String quotedCharsetValue
protected boolean charsetSet
protected String contentType
protected boolean isExpectContent
protected boolean isSkipRemainder
protected boolean isContentBroken
protected boolean secure
protected final DataChunk upgrade
public HttpHeader()
protected HttpHeader(MimeHeaders headers)
public AttributeHolder getAttributes()
AttributeHolder
.
Implementation may return null if AttributeHolder
wasn't
initialized yet.getAttributes
in interface AttributeStorage
AttributeHolder
.
Implementation may return null if AttributeHolder
wasn't
initialized yet.public abstract boolean isRequest()
public final boolean isHeader()
isHeader
in class HttpPacket
public HttpHeader getHttpHeader()
getHttpHeader
in class HttpPacket
public abstract ProcessingState getProcessingState()
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.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 String getUpgrade()
public DataChunk getUpgradeDC()
public void setUpgrade(String upgrade)
protected void makeUpgradeHeader()
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 type)
type
- the content typepublic MimeHeaders getHeaders()
MimeHeaders
, associated with the HttpHeader.getHeaders
in interface MimeHeadersPacket
MimeHeaders
, associated with the HttpHeader.public String getHeader(String name)
getHeader
in interface MimeHeadersPacket
name
- the mime header name.public String getHeader(Header header)
getHeader
in interface MimeHeadersPacket
header
- the mime Header
public void setHeader(String name, String value)
setHeader
in interface MimeHeadersPacket
name
- the mime header name.value
- the mime header value.public void setHeader(Header header, String value)
setHeader
in interface MimeHeadersPacket
header
- the mime Header
.value
- the mime header value.public void addHeader(String name, String value)
addHeader
in interface MimeHeadersPacket
name
- the mime header name.value
- the mime header value.public void addHeader(Header header, String value)
addHeader
in interface MimeHeadersPacket
header
- the mime Header
.value
- the mime header value.public boolean containsHeader(String name)
containsHeader
in interface MimeHeadersPacket
name
- the mime header name.public boolean containsHeader(Header header)
Header
is present
among the HttpHeader mime headers, otherwise returns false.containsHeader
in interface MimeHeadersPacket
header
- the mime Header
.Header
is present
among the HttpHeader mime headers, otherwise returns false.public 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
- Protocol
public 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()
protected final boolean handleSetSpecialHeaders(Header header, String value)
protected static boolean isSpecialHeader(String name)
public byte[] getTempHeaderEncodingBuffer()
protected void flushSpecialHeaders()
Copyright © 2014 Oracle Corporation. All rights reserved.