- All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter,org.glassfish.grizzly.monitoring.MonitoringAware<HttpProbe>
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.glassfish.grizzly.http.HttpCodecFilter
HttpCodecFilter.ContentParsingState, HttpCodecFilter.HeaderParsingState -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final org.glassfish.grizzly.filterchain.FilterChainEventFields inherited from class org.glassfish.grizzly.http.HttpCodecFilter
chunkingEnabled, CLOSE_BYTES, contentEncodings, DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE, KEEPALIVE_BYTES, maxHeadersSize, maxPayloadRemainderToSkip, monitoringConfig, preserveHeaderCase -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Next major release will include builders for filters requiring configuration.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.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.HttpServerFilter(boolean chunkingEnabled, int maxHeadersSize, KeepAlive keepAlive, org.glassfish.grizzly.utils.DelayedExecutor executor) Deprecated.Next major release will include builders for filters requiring configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpContentcustomizeErrorResponse(HttpResponsePacket response) protected org.glassfish.grizzly.BufferencodeHttpPacket(org.glassfish.grizzly.filterchain.FilterChainContext ctx, HttpPacket input) org.glassfish.grizzly.filterchain.NextActionhandleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) org.glassfish.grizzly.filterchain.NextActionhandleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event) org.glassfish.grizzly.filterchain.NextActionhandleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) The method is called, once we have received aBuffer, which has to be transformed into HTTP request packet part.booleanThe flag, which enables/disables payload support for HTTP methods, for which HTTP spec doesn't clearly state whether they support payload.protected voidonHttpContentEncoded(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 voidonHttpContentError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) Callback which is invoked when parsing an HTTP message payload fails.protected voidonHttpContentParsed(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked as request/response body content has been processed by thisFilter.protected voidonHttpHeaderError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) Callback which is invoked when parsing an HTTP message header fails.protected booleanonHttpHeaderParsed(HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Callback invoked when the HTTP message header parsing is complete.protected voidonHttpHeadersEncoded(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 voidonHttpHeadersParsed(HttpHeader httpHeader, MimeHeaders headers, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when HTTP headers portion comes forHttpHeadermessage.protected final booleanonHttpPacketParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Callback method, called whenHttpPacketparsing has been completed.protected voidonInitialLineEncoded(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 voidonInitialLineParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when either the request line or status line has been parsed.voidsetAllowPayloadForUndefinedHttpMethods(boolean allowPayloadForUndefinedHttpMethods) The flag, which enables/disables payload support for HTTP methods, for which HTTP spec doesn't clearly state whether they support payload.final voidsetDefaultResponseContentType(String contentType) Methods inherited from class org.glassfish.grizzly.http.HttpCodecFilter
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, statusDropsConnectionMethods inherited from class org.glassfish.grizzly.http.HttpBaseFilter
bindMethods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleAccept, handleConnect, onAdded, onFilterChainChanged, onRemoved, toString
-
Field Details
-
HTTP_SERVER_REQUEST_ATTR_NAME
-
RESPONSE_COMPLETE_EVENT
public static final org.glassfish.grizzly.filterchain.FilterChainEvent RESPONSE_COMPLETE_EVENT
-
-
Constructor Details
-
HttpServerFilter
Deprecated.Next major release will include builders for filters requiring configuration. Constructors will be hidden.Constructor, which creates HttpServerFilter instance -
HttpServerFilter
@Deprecated public 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.Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.- Parameters:
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-DelayedExecutorfor handling keep-alive.
-
HttpServerFilter
@Deprecated public 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.Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.- Parameters:
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-DelayedExecutorfor handling keep-alive. If null - keep-alive idle connections should be managed outside HttpServerFilter.
-
HttpServerFilter
@Deprecated public 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.Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.- Parameters:
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-DelayedExecutorfor 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.- Since:
- 2.2.11
-
-
Method Details
-
getDefaultResponseContentType
-
setDefaultResponseContentType
-
isAllowPayloadForUndefinedHttpMethods
public boolean isAllowPayloadForUndefinedHttpMethods()The flag, which enables/disables payload support for HTTP methods, for which HTTP spec doesn't clearly state whether they support payload. Known "undefined" methods are: GET, HEAD, DELETE.- Returns:
- true if "undefined" methods support payload, or false otherwise
- Since:
- 2.3.12
-
setAllowPayloadForUndefinedHttpMethods
public 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. Known "undefined" methods are: GET, HEAD, DELETE.- Parameters:
allowPayloadForUndefinedHttpMethods- true if "undefined" methods support payload, or false otherwise- Since:
- 2.3.12
-
handleRead
public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException The method is called, once we have received aBuffer, which has to be transformed into HTTP request packet part. Filter getsBuffer, which represents a part or complete HTTP request message. As the result of "read" transformation - we will getHttpContentmessage, which will represent HTTP request packet content (might be zero length content) and reference to aHttpHeader, which contains HTTP request message header.- Specified by:
handleReadin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleReadin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- Request processing context- Returns:
NextAction- Throws:
IOException
-
onHttpHeaderParsed
protected boolean onHttpHeaderParsed(HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterCallback invoked when the HTTP message header parsing is complete.- Specified by:
onHttpHeaderParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents parsed HTTP packet headerbuffer-Bufferthe header was parsed fromctx- processing context.- Returns:
trueif an error has occurred while processing the header portion of the HTTP request, otherwise returnsfalse.
-
onHttpPacketParsed
protected final boolean onHttpPacketParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterCallback method, called whenHttpPacketparsing has been completed.- Specified by:
onHttpPacketParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents parsed HTTP packet headerctx- processing context.- Returns:
trueif an error has occurred while processing the header portion of the HTTP request, otherwise returnsfalse.s
-
onInitialLineParsed
protected void onInitialLineParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterInvoked when either the request line or status line has been parsed.
- Specified by:
onInitialLineParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.
-
onHttpHeadersParsed
protected void onHttpHeadersParsed(HttpHeader httpHeader, MimeHeaders headers, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterInvoked when HTTP headers portion comes for
HttpHeadermessage. Depending on the transfer encoding being used by the current request, this method may be invoked multiple times.- Specified by:
onHttpHeadersParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerheaders- the headers portion, that has been parsedctx- processing context.
-
onHttpContentParsed
protected void onHttpContentParsed(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterInvoked as request/response body content has been processed by this
Filter.- Specified by:
onHttpContentParsedin classHttpCodecFilter- Parameters:
content- request/response body contentctx- processing context.
-
onHttpHeaderError
protected void onHttpHeaderError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException Description copied from class: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.
- Specified by:
onHttpHeaderErrorin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- theFilterChainContextprocessing this requestt- the cause of the error- Throws:
IOException
-
onHttpContentError
protected void onHttpContentError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException Description copied from class: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.
- Specified by:
onHttpContentErrorin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- theFilterChainContextprocessing this requestt- the cause of the error- Throws:
IOException
-
encodeHttpPacket
protected org.glassfish.grizzly.Buffer encodeHttpPacket(org.glassfish.grizzly.filterchain.FilterChainContext ctx, HttpPacket input) - Overrides:
encodeHttpPacketin classHttpCodecFilter
-
onInitialLineEncoded
protected void onInitialLineEncoded(HttpHeader header, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterInvoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.
- Specified by:
onInitialLineEncodedin classHttpCodecFilter- Parameters:
header-HttpHeader, which represents HTTP packet headerctx- processing context.
-
onHttpHeadersEncoded
protected void onHttpHeadersEncoded(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterInvoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.
- Specified by:
onHttpHeadersEncodedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.
-
onHttpContentEncoded
protected void onHttpContentEncoded(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Description copied from class:HttpCodecFilterInvoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.
- Specified by:
onHttpContentEncodedin classHttpCodecFilter- Parameters:
content-HttpContent, which represents HTTP packet headerctx- processing context.
-
handleEvent
public org.glassfish.grizzly.filterchain.NextAction handleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event) throws IOException - Specified by:
handleEventin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleEventin classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
handleClose
public org.glassfish.grizzly.filterchain.NextAction handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException - Specified by:
handleClosein interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleClosein classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
customizeErrorResponse
-