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

public abstract Class HttpHeader

extends HttpPacket
implements MimeHeadersPacket, AttributeStorage
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.attributes.AttributeStorage, org.glassfish.grizzly.http.MimeHeadersPacket
Known Direct Subclasses
org.glassfish.grizzly.http.HttpRequestPacket, org.glassfish.grizzly.http.HttpResponsePacket
Imports
java.util.ArrayList, .Collections, .List, org.glassfish.grizzly.Buffer, .Grizzly, org.glassfish.grizzly.attributes.AttributeHolder, .AttributeStorage, org.glassfish.grizzly.http.util.Constants, .ContentType, .ContentType.SettableContentType, .DataChunk, .Header, .HeaderValue, .HttpUtils, .MimeHeaders, org.glassfish.grizzly.utils.Charsets

HttpPacket, which represents HTTP message header. There are 2 subtypes of this class: HttpRequestPacket and HttpResponsePacket.
Author
Alexey Stashok
See Also
HttpRequestPacket, HttpResponsePacket

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
HttpHeader.Builder<T extends HttpHeader.Builder>

HttpHeader message builder.

Field Summary

Modifier and TypeField and Description
private AttributeHolder
private final AttributeHolder
private static final byte[]
private boolean
chunkingAllowed

Is chunking allowed to be used or not.

private final List<ContentEncoding>
protected long
protected final ContentType.SettableContentType
pack-priv Buffer
protected final MimeHeaders
protected boolean
protected boolean
protected boolean
isContentBroken

true if HTTP message payload is broken due to inappropriate Transfer-Encoding or Content-Encoding settings.

private boolean
protected boolean
private boolean
isIgnoreContentModifiers

true if parser has to ignore "Transfer-Encoding" and "Content-Encoding" headers and act as none of them were specified.

protected boolean
protected Protocol
protected final DataChunk
protected boolean
private final byte[]
private final byte[]
private TransferEncoding
protected final DataChunk

Constructor Summary

AccessConstructor and Description
public
protected
HttpHeader(final MimeHeaders headers)

Method Summary

Modifier and TypeMethod and Description
protected void
public void
addHeader(final String name, final String value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.addHeader.

Add the HTTP mime header.

public void
addHeader(final String name, final HeaderValue value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.addHeader.

Add the HTTP mime header.

public void
addHeader(final Header header, final String value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.addHeader.

Add the HTTP mime header.

public void
addHeader(final Header header, final HeaderValue value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.addHeader.

Add the HTTP mime header.

public boolean
containsHeader(final String name)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.containsHeader.

Returns true, if the mime header with the specific name is present among the HttpHeader mime headers, or false otherwise.

public boolean
containsHeader(final Header header)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.containsHeader.

Returns true, if the mime Header is present among the HttpHeader mime headers, otherwise returns false.

protected void
extractContentEncoding(final DataChunk
container for the content-type value.
value
)

Obtain content-encoding value and mark it as serialized.

protected void
flushSpecialHeaders()

Flush internal fields for special header names to the headers map.

public AttributeHolder
public String
getCharacterEncoding()

Returns: the character encoding of this HTTP message.

protected List<ContentEncoding>
getContentEncodings(final boolean isModifiable)

public List<ContentEncoding>
public long

Returns:

the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
getContentLength
()

Get the content-length of this HttpPacket.

public String
getContentType()

Returns: the content type of this HTTP message.

protected ContentType
public String
getHeader(final String name)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.getHeader.

Get the value, of the specific HTTP mime header.

public String
getHeader(final Header header)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.getHeader.

Get the value, of the specific HTTP mime header.

public MimeHeaders
getHeaders()

Implements org.glassfish.grizzly.http.MimeHeadersPacket.getHeaders.

Get all MimeHeaders, associated with the HttpHeader.

public HttpHeader

Returns:

this HttpHeader object.
getHttpHeader
()

Implements abstract org.glassfish.grizzly.http.HttpPacket.getHttpHeader.

Returns this HttpHeader object.

protected HttpPacketParsing
getParsingState()

Returns: the parsing state of this HTTP header, or null if the message is complete or shouldn't be parsed at all

public abstract ProcessingState
public Protocol

Returns:

Protocol.
getProtocol
()

Get HTTP protocol version.

public DataChunk

Returns:

the HTTP message protocol version as DataChunk (avoiding creation of a String object). The result format is "HTTP/1.x".
getProtocolDC
()

Get the HTTP message protocol version as DataChunk (avoiding creation of a String object).

public String

Returns:

the HTTP message protocol version. The result format is "HTTP/1.x".
getProtocolString
()

Get the HTTP message protocol version.

public byte[]
public TransferEncoding

Returns:

the TransferEncoding, responsible for the parsing/serialization of the HTTP message content
getTransferEncoding
()

Get the TransferEncoding, responsible for the parsing/serialization of the HTTP message content

public final String
getUpgrade()

Returns: the "Upgrade" header value.

public DataChunk
getUpgradeDC()

Returns: the "Upgrade" header value.

private String
private String
private final String
private final String
private final boolean
handleSetSpecialHeaders(final String name, final String value)

private final boolean
handleSetSpecialHeaders(final String name, final HeaderValue value)

private final boolean
handleSetSpecialHeaders(final Header header, final String value)

private final boolean
handleSetSpecialHeaders(final Header header, final HeaderValue value)

public final HttpContent.Builder<T extends HttpContent.Builder>
httpContentBuilder()

Get the HTTP message content builder.

public HttpTrailer.Builder
httpTrailerBuilder()

Get the HTTP message trailer-chunk builder.

public boolean

Returns:

true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.
isChunked
()

Returns true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.

public boolean

Returns:

true if chunking is allowed for this header.
isChunkingAllowed
()

Return true if chunking is allowed for this header.

public boolean

Returns:

true, if this HttpHeader has been already serialized, and only HttpContent messages might be serialized for this HttpPacket.
isCommitted
()

Is this HttpHeader written?

public boolean

Returns:

true, if HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing. Otherwise returns false.
isContentBroken
()

Returns true, if HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing.

protected final boolean
public boolean
isContentTypeSet()

Returns: true if a content type has been set.

public boolean

Returns:

true, if HTTP message, represented by this header still expects additional content basing either on content-length or chunking information. false is returned if content no additional content data is expected.
isExpectContent
()

Returns true, if HTTP message, represented by this header still expects additional content basing either on content-length or chunking information.

public final boolean

Returns:

true.
isHeader
()

Implements abstract org.glassfish.grizzly.http.HttpPacket.isHeader.

Returns true.

public boolean
isIgnoreContentModifiers()

Returns: true if parser has to ignore "Transfer-Encoding" and "Content-Encoding" headers and act as none of them were specified.

public abstract boolean

Returns:

true, if the current HttpHeader represent HTTP request message, or false otherwise.
isRequest
()

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

public boolean
isSecure()

Returns: true if this HTTP message is being transmitted in a secure fashion, otherwise returns false.

public boolean

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 org.glassfish.grizzly.Connection. Otherwise returns false.
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 org.glassfish.grizzly.Connection.

private static boolean
isSpecialHeader(final String name)

private static boolean
isSpecialHeader(final char c)

private static boolean
public boolean
isUpgrade()

Returns: true if this header represents an HTTP upgrade, otherwise false.

protected void
makeContentLengthHeader(final long
default content-length value.
defaultLength
)

Makes sure content-length header is present.

protected void
makeTransferEncodingHeader(final String
default transfer-encoding value.
defaultValue
)

Makes sure transfer-encoding header is present.

protected void
makeUpgradeHeader()

Propagate the "Upgrade" value to headers.

public void
protected void
reset()

Reset the internal state.

public void
setCharacterEncoding(final String
the encoding.
charset
)

Set the character encoding of this HTTP message.

public void
setChunked(boolean
true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.
isChunked
)

Set true, if this HttpPacket content will be transferred in chunking mode, or false if case of fixed-length message.

public void
setChunkingAllowed(boolean
true if chunked transfer-encoding is allowed, otherwise returns false.
chunkingAllowed
)

Indicate whether or not chunking may be used by this header.

public void
setCommitted(final boolean
true, if this HttpHeader has been already serialized, and only HttpContent messages might be serialized for this HttpPacket.
isCommitted
)

Is this HttpHeader written?

public void
setContentBroken(final boolean
true, means that HTTP packet payload was detected as broken due to unexpected error occurred during Transfer-Encoding or Content-Encoding processing.
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 final void
setContentEncodingsSelected(final boolean isContentEncodingsSelected)

public void
setContentLength(final int
the length of this HTTP message.
len
)

Set the length of this HTTP message.

public void
setContentLengthLong(final long
the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
contentLength
)

Set the content-length of this HttpPacket.

private boolean
public void
setContentType(final String
the content type
contentType
)

Sets the content type.

public void
setContentType(final ContentType
the content type
contentType
)

Sets the content type.

public void
setExpectContent(boolean isExpectContent)

public void
setHeader(final String name, final String value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.setHeader.

Set the value, of the specific HTTP mime header.

public void
setHeader(final String name, final HeaderValue value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.setHeader.

Set the value, of the specific HTTP mime header.

public void
setHeader(final Header header, final String value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.setHeader.

Set the value, of the specific HTTP mime header.

public void
setHeader(final Header header, final HeaderValue value)

Implements org.glassfish.grizzly.http.MimeHeadersPacket.setHeader.

Set the value, of the specific HTTP mime header.

pack-priv void
setHeaderBuffer(final Buffer headerBuffer)

public 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.

public void
setProtocol(Protocol protocol)

Set the HTTP message protocol version.

public void
setSecure(boolean
true if secure, otherwise false.
secure
)

Sets the secure status of this HTTP message.

public void
setSkipRemainder(boolean
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 org.glassfish.grizzly.Connection.
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 org.glassfish.grizzly.Connection.

protected void
setTransferEncoding(TransferEncoding
the TransferEncoding, responsible for the parsing/serialization of the HTTP message content.
transferEncoding
)

Set the TransferEncoding, responsible for the parsing/serialization of the HTTP message content.

public final void
setUpgrade(final String upgrade)

Sets the "Upgrade" header value

private boolean
setValueBasedOnHeader(final String name, final String value)

Set internal fields for special header names.

private boolean
setValueBasedOnHeader(final Header header, final String value)

Set internal fields for special header names.

Inherited from org.glassfish.grizzly.http.HttpPacket:
isHttp