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

public Class HttpServerFilter

extends HttpCodecFilter
Class Inheritance
Static Imports
org.glassfish.grizzly.http.util.HttpCodecUtils.findEOL, .HttpCodecUtils.findSpace, .HttpCodecUtils.put, .HttpCodecUtils.skipSpaces, .HttpCodecUtils.toCheckedByteArray

Server side HttpCodecFilter implementation, which is responsible for decoding HttpRequestPacket and encoding HttpResponsePacket messages. This Filter is usually used, when we build an asynchronous HTTP server connection.
Author
Alexey Stashok
See Also
HttpCodecFilter, HttpClientFilter

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final boolean
private boolean
private String
private byte[]
private byte[]
public static final String
private final Attribute<HttpServerFilter.ServerHttpRequestImpl>
private final KeepAlive
private final Attribute<HttpServerFilter.KeepAliveContext>
private final DelayedExecutor.DelayQueue<HttpServerFilter.KeepAliveContext>
private final int
private final int
public static final FilterChainEvent
Inherited from org.glassfish.grizzly.http.HttpCodecFilter:
chunkingEnabledCLOSE_BYTESCOLON_BYTEScontentEncodingsCRLF_BYTESDEFAULT_MAX_HTTP_PACKET_HEADER_SIZEKEEPALIVE_BYTESmaxHeadersSizemaxPayloadRemainderToSkipmonitoringConfigPRESERVE_HEADER_CASEpreserveHeaderCaseSTRICT_HEADER_NAME_VALIDATION_RFC_9110STRICT_HEADER_VALUE_VALIDATION_RFC_9110

Constructor Summary

AccessConstructor and Description
public
HttpServerFilter()
Deprecated Next major release will include builders for filters requiring configuration. Constructors will be hidden.

Constructor, which creates HttpServerFilter instance

public
HttpServerFilter(boolean
flag indicating whether or not chunking should be allowed or not.
chunkingEnabled
,
int
the maximum size of an inbound HTTP message header.
maxHeadersSize
,
KeepAlive
keep-alive configuration for this filter instance.
keepAlive
,
DelayedExecutor
DelayedExecutor for handling keep-alive.
executor
)
Deprecated Next major release will include builders for filters requiring configuration. Constructors will be hidden.

Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.

public
HttpServerFilter(boolean
flag indicating whether or not chunking should be allowed or not.
chunkingEnabled
,
int
the maximum size of an inbound HTTP message header.
maxHeadersSize
,
String
the content type that the response should use if no content had been specified at the time the response is committed.
defaultResponseContentType
,
KeepAlive
keep-alive configuration for this filter instance.
keepAlive
,
DelayedExecutor
DelayedExecutor for handling keep-alive. If null - keep-alive idle connections should be managed outside HttpServerFilter.
executor
)
Deprecated Next major release will include builders for filters requiring configuration. Constructors will be hidden.

Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.

public
HttpServerFilter(boolean
flag indicating whether or not chunking should be allowed or not.
chunkingEnabled
,
int
the maximum size of an inbound HTTP message header.
maxHeadersSize
,
String
the content type that the response should use if no content had been specified at the time the response is committed.
defaultResponseContentType
,
KeepAlive
keep-alive configuration for this filter instance.
keepAlive
,
DelayedExecutor
DelayedExecutor for handling keep-alive. If null - keep-alive idle connections should be managed outside HttpServerFilter.
executor
,
int
maximum number of request headers allowed for a single request.
maxRequestHeaders
,
int
maximum number of response headers allowed for a single response.
maxResponseHeaders
)
Deprecated Next major release will include builders for filters requiring configuration. Constructors will be hidden.

Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.

public
HttpServerFilter(boolean
flag indicating whether or not chunking should be allowed or not.
chunkingEnabled
,
int
the maximum size of an inbound HTTP message header.
maxHeadersSize
,
String
the content type that the response should use if no content had been specified at the time the response is committed.
defaultResponseContentType
,
KeepAlive
keep-alive configuration for this filter instance.
keepAlive
,
DelayedExecutor
DelayedExecutor for handling keep-alive. If null - keep-alive idle connections should be managed outside HttpServerFilter.
executor
,
int
maximum number of request headers allowed for a single request.
maxRequestHeaders
,
int
maximum number of response headers allowed for a single response.
maxResponseHeaders
,
final Properties
the properties to be used by the filter.
props
)
Deprecated Next major release will include builders for filters requiring configuration. Constructors will be hidden.

Constructor, which creates HttpServerFilter instance, with the specific max header size and properties parameter.

Method Summary

Modifier and TypeMethod and Description
private boolean
checkContentLengthRemainder(final HttpRequestPacket httpRequest)

Returns: false if the request payload size is specified by the content-length header and according to the request parsing state the remaining payload size is larger than getMaxPayloadRemainderToSkip().

private boolean
private void
protected HttpContent
pack-priv final boolean
decodeInitialLineFromBuffer(final FilterChainContext ctx, final HttpPacketParsing httpPacket, final HttpCodecFilter.HeaderParsingState parsingState, final Buffer input)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBuffer.

Method is responsible for parsing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

pack-priv final boolean
decodeInitialLineFromBytes(final FilterChainContext ctx, final HttpPacketParsing httpPacket, final HttpCodecFilter.HeaderParsingState parsingState, final byte[] input, final int end)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBytes.

Method is responsible for parsing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

protected Buffer
pack-priv Buffer
encodeInitialLine(HttpPacket httpPacket, Buffer output, MemoryManager<E extends Buffer> memoryManager)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.encodeInitialLine.

Method is responsible for serializing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

pack-priv Buffer
encodeInitialLine(HttpPacket httpPacket, HttpStatus status, Buffer output, MemoryManager<E extends Buffer> memoryManager)

Overrides org.glassfish.grizzly.http.HttpCodecFilter.encodeInitialLine.

Variant of encodeInitialLine(HttpPacket, Buffer, MemoryManager) that overrides the status used in the status line, for serializing interim (1xx) responses whose status differs from the final response status.

private Buffer
encodeInitialLine(HttpResponsePacket httpResponse, HttpStatus status, Buffer output, MemoryManager<E extends Buffer> memoryManager)

public String
public NextAction
handleClose(final FilterChainContext ctx)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleClose.

Implements org.glassfish.grizzly.filterchain.Filter.handleClose.

Execute a unit of processing work to be performed, when connection has been closed.

public NextAction
public NextAction

Returns:

NextAction
handleRead
(final FilterChainContext
Request processing context
ctx
)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

The method is called, once we have received a Buffer, which has to be transformed into HTTP request packet part.

public boolean

Returns:

true if "undefined" methods support payload, or false otherwise
isAllowPayloadForUndefinedHttpMethods
()

The flag, which enables/disables payload support for HTTP methods, for which HTTP spec doesn't clearly state whether they support payload.

protected void
onHttpContentEncoded(HttpContent content, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentEncoded.

Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.

protected void
onHttpContentError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentError.

Callback which is invoked when parsing an HTTP message payload fails.

protected void
onHttpContentParsed(HttpContent content, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentParsed.

Invoked as request/response body content has been processed by this org.glassfish.grizzly.filterchain.Filter.

protected void
onHttpHeaderError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderError.

Callback which is invoked when parsing an HTTP message header fails.

protected boolean
onHttpHeaderParsed(final HttpHeader httpHeader, final Buffer buffer, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderParsed.

Callback invoked when the HTTP message header parsing is complete.

protected void
onHttpHeadersEncoded(HttpHeader httpHeader, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersEncoded.

Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.

protected void
onHttpHeadersParsed(final HttpHeader httpHeader, final MimeHeaders headers, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersParsed.

Invoked when HTTP headers portion comes for HttpHeader message.

protected final boolean
onHttpPacketParsed(final HttpHeader httpHeader, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpPacketParsed.

Callback method, called when HttpPacket parsing has been completed.

protected void
onInitialLineEncoded(HttpHeader header, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineEncoded.

Invoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.

protected void
onInitialLineParsed(final HttpHeader httpHeader, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineParsed.

Invoked when either the request line or status line has been parsed.

private static boolean
parseRequestURI(final HttpServerFilter.ServerHttpRequestImpl httpRequest, final HttpCodecFilter.HeaderParsingState state, final byte[] input, final int end)

private static boolean
private void
prepareRequest(final HttpServerFilter.ServerHttpRequestImpl request, final boolean hasReadyContent, final FilterChainContext ctx)

private HttpContent

Returns:

encoded HttpContent, if content encoders have been applied, or null, if HttpContent wasn't changed.
prepareResponse
(final FilterChainContext ctx, final HttpRequestPacket request, final HttpResponsePacket response, final HttpContent httpContent)

Prepare Http response

private void
processResponseComplete(final FilterChainContext ctx, final HttpRequestPacket httpRequest, final boolean isStayAlive)

private void
private void
public void
setAllowPayloadForUndefinedHttpMethods(boolean
true if "undefined" methods support payload, or false otherwise
allowPayloadForUndefinedHttpMethods
)

The flag, which enables/disables payload support for HTTP methods, for which HTTP spec doesn't clearly state whether they support payload.

public final void
Inherited from org.glassfish.grizzly.http.HttpCodecFilter:
addContentEncodingaddTransferEncodingcreateJmxManagementObjectdecodeContentdecodeHttpPacketdecodeHttpPacketFromBufferdecodeHttpPacketFromBytesencodeContentencodeHttpPacketencodeKnownHeadersencodeMimeHeaderencodeMimeHeadersencodeMimeHeadersgetContentEncodingsgetMaxPayloadRemainderToSkipgetMonitoringConfiggetTransferEncodingshandleReadhandleWriteisChunkingEnabledisPreserveHeaderCaseisRemoveHandledContentEncodingHeadersisSecureonIncomingUpgradeonOutgoingUpgradeparseHeaderFromBufferparseHeaderFromBytesparseHeaderNameparseHeaderNameparseHeadersFromBufferparseHeadersFromBytesparseHeaderValueparseHeaderValueremoveContentEncodingremoveTransferEncodingsetContentEncodingsOnParsingsetContentEncodingsOnSerializingsetMaxPayloadRemainderToSkipsetPreserveHeaderCasesetRemoveHandledContentEncodingHeaderssetTransferEncodingOnParsingsetTransferEncodingOnSerializingstatusDropsConnection