public class HttpServerFilter extends HttpCodecFilter
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.HttpCodecFilter,
HttpClientFilterHttpCodecFilter.ContentParsingState, HttpCodecFilter.HeaderParsingState| Modifier and Type | Field and Description |
|---|---|
static String |
HTTP_SERVER_REQUEST_ATTR_NAME |
static org.glassfish.grizzly.filterchain.FilterChainEvent |
RESPONSE_COMPLETE_EVENT |
static String |
SERVER_CONNECTION_ATTRIBUTE |
chunkingEnabled, CLOSE_BYTES, contentEncodings, DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE, KEEPALIVE_BYTES, maxHeadersSize, maxPayloadRemainderToSkip, monitoringConfig, preserveHeaderCase| Constructor and Description |
|---|
HttpServerFilter()
Deprecated.
Next major release will include builders for filters requiring configuration. Constructors will be hidden.
|
HttpServerFilter(boolean chunkingEnabled,
int maxHeadersSize,
KeepAlive keepAlive,
org.glassfish.grizzly.utils.DelayedExecutor executor)
Deprecated.
Next major release will include builders for filters requiring configuration. Constructors will be hidden.
|
HttpServerFilter(boolean chunkingEnabled,
int maxHeadersSize,
String defaultResponseContentType,
KeepAlive keepAlive,
org.glassfish.grizzly.utils.DelayedExecutor executor)
Deprecated.
Next major release will include builders for filters requiring configuration. Constructors will be hidden.
|
HttpServerFilter(boolean chunkingEnabled,
int maxHeadersSize,
String defaultResponseContentType,
KeepAlive keepAlive,
org.glassfish.grizzly.utils.DelayedExecutor executor,
int maxRequestHeaders,
int maxResponseHeaders)
Deprecated.
Next major release will include builders for filters requiring configuration. Constructors will be hidden.
|
| Modifier and Type | Method and Description |
|---|---|
protected HttpContent |
customizeErrorResponse(HttpResponsePacket response) |
protected org.glassfish.grizzly.Buffer |
encodeHttpPacket(org.glassfish.grizzly.filterchain.FilterChainContext ctx,
HttpPacket input) |
String |
getDefaultResponseContentType() |
org.glassfish.grizzly.filterchain.NextAction |
handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) |
org.glassfish.grizzly.filterchain.NextAction |
handleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx,
org.glassfish.grizzly.filterchain.FilterChainEvent event) |
org.glassfish.grizzly.filterchain.NextAction |
handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
The method is called, once we have received a
Buffer,
which has to be transformed into HTTP request packet part. |
boolean |
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,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Invoked when a HTTP body chunk has been encoded in preparation to being
transmitted to the user-agent.
|
protected void |
onHttpContentError(HttpHeader httpHeader,
org.glassfish.grizzly.filterchain.FilterChainContext ctx,
Throwable t)
Callback which is invoked when parsing an HTTP message payload fails.
|
protected void |
onHttpContentParsed(HttpContent content,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Invoked as request/response body content has been processed by this
Filter. |
protected void |
onHttpHeaderError(HttpHeader httpHeader,
org.glassfish.grizzly.filterchain.FilterChainContext ctx,
Throwable t)
Callback which is invoked when parsing an HTTP message header fails.
|
protected boolean |
onHttpHeaderParsed(HttpHeader httpHeader,
org.glassfish.grizzly.Buffer buffer,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Callback invoked when the HTTP message header parsing is complete.
|
protected void |
onHttpHeadersEncoded(HttpHeader httpHeader,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Invoked when HTTP headers have been encoded in preparation to being
transmitted to the user-agent.
|
protected void |
onHttpHeadersParsed(HttpHeader httpHeader,
MimeHeaders headers,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Invoked when HTTP headers portion comes for
HttpHeader message. |
protected boolean |
onHttpPacketParsed(HttpHeader httpHeader,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Callback method, called when
HttpPacket parsing has been completed. |
protected void |
onInitialLineEncoded(HttpHeader header,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Invoked when the initial response line has been encoded in preparation
to being transmitted to the user-agent.
|
protected void |
onInitialLineParsed(HttpHeader httpHeader,
org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Invoked when either the request line or status line has been parsed.
|
void |
setAllowPayloadForUndefinedHttpMethods(boolean allowPayloadForUndefinedHttpMethods)
The flag, which enables/disables payload support for HTTP methods,
for which HTTP spec doesn't clearly state whether they support payload.
|
void |
setDefaultResponseContentType(String contentType) |
addContentEncoding, addTransferEncoding, createJmxManagementObject, decodeHttpPacket, decodeHttpPacketFromBuffer, decodeHttpPacketFromBytes, encodeHttpPacket, encodeKnownHeaders, encodeMimeHeader, encodeMimeHeaders, getContentEncodings, getMaxPayloadRemainderToSkip, getMonitoringConfig, getTransferEncodings, handleRead, handleWrite, isChunkingEnabled, isPreserveHeaderCase, isRemoveHandledContentEncodingHeaders, isSecure, onIncomingUpgrade, onOutgoingUpgrade, parseHeaderFromBuffer, parseHeaderFromBytes, parseHeaderName, parseHeaderName, parseHeadersFromBuffer, parseHeadersFromBytes, parseHeaderValue, parseHeaderValue, removeContentEncoding, removeTransferEncoding, setMaxPayloadRemainderToSkip, setPreserveHeaderCase, setRemoveHandledContentEncodingHeaders, statusDropsConnectionbindpublic static final String HTTP_SERVER_REQUEST_ATTR_NAME
public static final org.glassfish.grizzly.filterchain.FilterChainEvent RESPONSE_COMPLETE_EVENT
public static final String SERVER_CONNECTION_ATTRIBUTE
@Deprecated public HttpServerFilter()
@Deprecated public HttpServerFilter(boolean chunkingEnabled, int maxHeadersSize, KeepAlive keepAlive, org.glassfish.grizzly.utils.DelayedExecutor executor)
chunkingEnabled - flag indicating whether or not chunking should
be allowed or not.maxHeadersSize - the maximum size of an inbound HTTP message header.keepAlive - keep-alive configuration for this filter instance.executor - DelayedExecutor for handling keep-alive.@Deprecated public HttpServerFilter(boolean chunkingEnabled, int maxHeadersSize, String defaultResponseContentType, KeepAlive keepAlive, org.glassfish.grizzly.utils.DelayedExecutor executor)
chunkingEnabled - flag indicating whether or not chunking should
be allowed or not.maxHeadersSize - the maximum size of an inbound HTTP message header.defaultResponseContentType - the content type that the response should
use if no content had been specified at the time the response is committed.keepAlive - keep-alive configuration for this filter instance.executor - DelayedExecutor for handling keep-alive. If null -
keep-alive idle connections should be managed outside HttpServerFilter.@Deprecated public HttpServerFilter(boolean chunkingEnabled, int maxHeadersSize, String defaultResponseContentType, KeepAlive keepAlive, org.glassfish.grizzly.utils.DelayedExecutor executor, int maxRequestHeaders, int maxResponseHeaders)
chunkingEnabled - flag indicating whether or not chunking should
be allowed or not.maxHeadersSize - the maximum size of an inbound HTTP message header.defaultResponseContentType - the content type that the response should
use if no content had been specified at the time the response is committed.keepAlive - keep-alive configuration for this filter instance.executor - DelayedExecutor for handling keep-alive. If null -
keep-alive idle connections should be managed outside HttpServerFilter.maxRequestHeaders - maximum number of request headers allowed for a single request.maxResponseHeaders - maximum number of response headers allowed for a single response.public String getDefaultResponseContentType()
public final void setDefaultResponseContentType(String contentType)
public boolean isAllowPayloadForUndefinedHttpMethods()
public void setAllowPayloadForUndefinedHttpMethods(boolean allowPayloadForUndefinedHttpMethods)
allowPayloadForUndefinedHttpMethods - true if "undefined" methods support payload, or false otherwisepublic org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
throws IOException
Buffer,
which has to be transformed into HTTP request packet part.
Filter gets Buffer, which represents a part or complete HTTP
request message. As the result of "read" transformation - we will get
HttpContent message, which will represent HTTP request packet
content (might be zero length content) and reference
to a HttpHeader, which contains HTTP request message header.handleRead in interface org.glassfish.grizzly.filterchain.FilterhandleRead in class org.glassfish.grizzly.filterchain.BaseFilterctx - Request processing contextNextActionIOExceptionprotected boolean onHttpHeaderParsed(HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilteronHttpHeaderParsed in class HttpCodecFilterhttpHeader - HttpHeader, which represents parsed HTTP packet headerbuffer - Buffer the header was parsed fromctx - processing context.true if an error has occurred while processing
the header portion of the HTTP request, otherwise returns
false.protected final boolean onHttpPacketParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilterHttpPacket parsing has been completed.onHttpPacketParsed in class HttpCodecFilterhttpHeader - HttpHeader, which represents parsed HTTP packet headerctx - processing context.true if an error has occurred while processing
the header portion of the HTTP request, otherwise returns
false.sprotected void onInitialLineParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilterInvoked when either the request line or status line has been parsed.
onInitialLineParsed in class HttpCodecFilterhttpHeader - HttpHeader, which represents HTTP packet headerctx - processing context.protected void onHttpHeadersParsed(HttpHeader httpHeader, MimeHeaders headers, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilter
Invoked when HTTP headers portion comes for HttpHeader message.
Depending on the transfer encoding being used by the current request, this method may be
invoked multiple times.
onHttpHeadersParsed in class HttpCodecFilterhttpHeader - HttpHeader, which represents HTTP packet headerheaders - the headers portion, that has been parsedctx - processing context.protected void onHttpContentParsed(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilter
Invoked as request/response body content has been processed by this
Filter.
onHttpContentParsed in class HttpCodecFiltercontent - request/response body contentctx - processing context.protected void onHttpHeaderError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException
HttpCodecFilterCallback which is invoked when parsing an HTTP message header fails. The processing logic has to take care about error handling and following connection closing.
onHttpHeaderError in class HttpCodecFilterhttpHeader - HttpHeader, which represents HTTP packet headerctx - the FilterChainContext processing this requestt - the cause of the errorIOExceptionprotected void onHttpContentError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException
HttpCodecFilterCallback which is invoked when parsing an HTTP message payload fails. The processing logic has to take care about error handling and following connection closing.
onHttpContentError in class HttpCodecFilterhttpHeader - HttpHeader, which represents HTTP packet headerctx - the FilterChainContext processing this requestt - the cause of the errorIOExceptionprotected org.glassfish.grizzly.Buffer encodeHttpPacket(org.glassfish.grizzly.filterchain.FilterChainContext ctx,
HttpPacket input)
encodeHttpPacket in class HttpCodecFilterprotected void onInitialLineEncoded(HttpHeader header, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilterInvoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.
onInitialLineEncoded in class HttpCodecFilterheader - HttpHeader, which represents HTTP packet headerctx - processing context.protected void onHttpHeadersEncoded(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilterInvoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.
onHttpHeadersEncoded in class HttpCodecFilterhttpHeader - HttpHeader, which represents HTTP packet headerctx - processing context.protected void onHttpContentEncoded(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
HttpCodecFilterInvoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.
onHttpContentEncoded in class HttpCodecFiltercontent - HttpContent, which represents HTTP packet headerctx - processing context.public org.glassfish.grizzly.filterchain.NextAction handleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx,
org.glassfish.grizzly.filterchain.FilterChainEvent event)
throws IOException
handleEvent in interface org.glassfish.grizzly.filterchain.FilterhandleEvent in class org.glassfish.grizzly.filterchain.BaseFilterIOExceptionpublic org.glassfish.grizzly.filterchain.NextAction handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
throws IOException
handleClose in interface org.glassfish.grizzly.filterchain.FilterhandleClose in class org.glassfish.grizzly.filterchain.BaseFilterIOExceptionprotected HttpContent customizeErrorResponse(HttpResponsePacket response)
Copyright © 2021 Oracle Corporation. All Rights Reserved.