org.glassfish.grizzly.http
Class HttpServerFilter

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.BaseFilter
      extended by org.glassfish.grizzly.http.HttpCodecFilter
          extended by org.glassfish.grizzly.http.HttpServerFilter
All Implemented Interfaces:
Filter, JmxMonitoringAware<HttpProbe>, MonitoringAware<HttpProbe>

public class HttpServerFilter
extends HttpCodecFilter

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 Class Summary
 
Nested classes/interfaces inherited from class org.glassfish.grizzly.http.HttpCodecFilter
HttpCodecFilter.ContentParsingState, HttpCodecFilter.HeaderParsingState
 
Field Summary
static FilterChainEvent RESPONSE_COMPLETE_EVENT
           
 
Fields inherited from class org.glassfish.grizzly.http.HttpCodecFilter
chunkingEnabled, contentEncodings, DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE, maxHeadersSize, monitoringConfig
 
Constructor Summary
HttpServerFilter()
          Constructor, which creates HttpServerFilter instance
HttpServerFilter(boolean chunkingEnabled, int maxHeadersSize, KeepAlive keepAlive, DelayedExecutor executor)
          Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.
HttpServerFilter(boolean chunkingEnabled, int maxHeadersSize, java.lang.String defaultResponseContentType, KeepAlive keepAlive, DelayedExecutor executor)
          Constructor, which creates HttpServerFilter instance, with the specific max header size parameter.
 
Method Summary
protected  HttpContent customizeErrorResponse(HttpResponsePacket response)
           
protected  Buffer encodeHttpPacket(Connection connection, HttpPacket input)
           
 java.lang.String getDefaultResponseContentType()
           
 NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event)
           
 NextAction handleRead(FilterChainContext ctx)
          The method is called, once we have received a Buffer, which has to be transformed into HTTP request packet part.
 boolean isAuthPassthroughEnabled()
           
 boolean isTraceEnabled()
           
protected  void onHttpError(HttpHeader httpHeader, FilterChainContext ctx)
           Callback which is invoked when parsing an HTTP message fails.
 void setAuthPassthroughEnabled(boolean enabled)
           
 void setDefaultResponseContentType(java.lang.String defaultResponseContentType)
           
 void setTraceEnabled(boolean enabled)
           
 
Methods inherited from class org.glassfish.grizzly.http.HttpCodecFilter
addContentEncoding, addTransferEncoding, checkEOL, createJmxManagementObject, decodeHttpPacket, encodeKnownHeaders, encodeMimeHeader, encodeMimeHeaders, findEOL, findSpace, getContentEncodings, getMonitoringConfig, getTransferEncodings, handleRead, handleWrite, indexOf, isSecure, parseHeader, parseHeaderName, parseHeaders, parseHeaderValue, put, put, put, put, removeContentEncoding, removeTransferEncoding, resizeBuffer, skipSpaces
 
Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, getFilterChain, getIndex, handleAccept, handleClose, handleConnect, onAdded, onFilterChainChanged, onRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESPONSE_COMPLETE_EVENT

public static final FilterChainEvent RESPONSE_COMPLETE_EVENT
Constructor Detail

HttpServerFilter

public HttpServerFilter()
Constructor, which creates HttpServerFilter instance


HttpServerFilter

public HttpServerFilter(boolean chunkingEnabled,
                        int maxHeadersSize,
                        KeepAlive keepAlive,
                        DelayedExecutor executor)
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 - DelayedExecutor for handling keep-alive.

HttpServerFilter

public HttpServerFilter(boolean chunkingEnabled,
                        int maxHeadersSize,
                        java.lang.String defaultResponseContentType,
                        KeepAlive keepAlive,
                        DelayedExecutor executor)
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 - DelayedExecutor for handling keep-alive. If null - keep-alive idle connections should be managed outside HttpServerFilter.
Method Detail

handleRead

public NextAction handleRead(FilterChainContext ctx)
                      throws java.io.IOException
The method is called, once we have received a 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.

Specified by:
handleRead in interface Filter
Overrides:
handleRead in class BaseFilter
Parameters:
ctx - Request processing context
Returns:
NextAction
Throws:
java.io.IOException

handleEvent

public NextAction handleEvent(FilterChainContext ctx,
                              FilterChainEvent event)
                       throws java.io.IOException
Specified by:
handleEvent in interface Filter
Overrides:
handleEvent in class BaseFilter
Throws:
java.io.IOException

onHttpError

protected void onHttpError(HttpHeader httpHeader,
                           FilterChainContext ctx)
                    throws java.io.IOException
Description copied from class: HttpCodecFilter

Callback which is invoked when parsing an HTTP message fails. The processing logic has to take care about error handling and following connection closing.

Specified by:
onHttpError in class HttpCodecFilter
Parameters:
httpHeader - HttpHeader, which represents HTTP packet header
ctx - the FilterChainContext processing this request
Throws:
java.io.IOException

encodeHttpPacket

protected Buffer encodeHttpPacket(Connection connection,
                                  HttpPacket input)
Overrides:
encodeHttpPacket in class HttpCodecFilter

customizeErrorResponse

protected HttpContent customizeErrorResponse(HttpResponsePacket response)

isAuthPassthroughEnabled

public boolean isAuthPassthroughEnabled()

setAuthPassthroughEnabled

public void setAuthPassthroughEnabled(boolean enabled)

isTraceEnabled

public boolean isTraceEnabled()

setTraceEnabled

public void setTraceEnabled(boolean enabled)

getDefaultResponseContentType

public java.lang.String getDefaultResponseContentType()

setDefaultResponseContentType

public void setDefaultResponseContentType(java.lang.String defaultResponseContentType)


Copyright © 2011 Oracle Corpration. All Rights Reserved.