org.apache.coyote.http11

Class Http11NioProcessor

public class Http11NioProcessor extends Object implements ActionHook

Processes HTTP requests.

Author: Remy Maucherat Filip Hanik

Field Summary
protected Adapteradapter
Associated adapter.
protected booleancomet
Comet used.
protected booleancometClose
Closed flag, a Comet async thread can signal for this Nio processor to be closed and recycled instead of waiting for a timeout.
protected String[]compressableMimeTypes
List of MIMES which could be gzipped
protected intcompressionLevel
Allowed compression level.
protected intcompressionMinSize
Minimum contentsize to make compression.
protected booleancontentDelimitation
Content delimitator for the request (if false, the connection will be closed at the end of the request).
protected booleandisableUploadTimeout
Flag to disable setting a different time-out on uploads.
protected NioEndpointendpoint
Associated endpoint.
protected booleanerror
Error flag.
protected booleanexpectation
Is there an expectation ?
protected char[]hostNameC
Host name (used to avoid useless B2C conversion on the host name).
protected booleanhttp09
HTTP/0.9 flag.
protected booleanhttp11
HTTP/1.1 flag.
protected InternalNioInputBufferinputBuffer
Input.
protected booleankeepAlive
Keep-alive.
protected StringlocalAddr
The local Host address.
protected StringlocalName
Local Host associated with the current connection.
protected intlocalPort
Local port to which the socket is connected
protected static Loglog
Logger.
protected intmaxKeepAliveRequests
Maximum number of Keep-Alive requests to honor.
protected intmaxSavePostSize
Max save post size.
protected Pattern[]noCompressionUserAgents
List of user agents to not use gzip with
protected InternalNioOutputBufferoutputBuffer
Output.
protected StringremoteAddr
Remote Address associated with the current connection.
protected StringremoteHost
Remote Host associated with the current connection.
protected intremotePort
Remote port to which the socket is connected
protected Requestrequest
Request object.
protected Responseresponse
Response object.
protected Pattern[]restrictedUserAgents
List of restricted user agents.
protected NioEndpoint.SendfileDatasendfileData
Sendfile data.
protected Stringserver
Allow a customized the server header for the tin-foil hat folks.
protected static StringManagersm
The string manager for this package.
protected NioChannelsocket
Socket associated with the current connection.
protected intsocketBuffer
Socket buffering.
protected booleanssl
SSL enabled ?
protected SSLSupportsslSupport
SSL information.
protected inttimeout
Maximum timeout on uploads.
Constructor Summary
Http11NioProcessor(int rxBufSize, int txBufSize, int maxHttpHeaderSize, NioEndpoint endpoint)
Method Summary
voidaction(ActionCode actionCode, Object param)
Send an action to the connector.
voidaddCompressableMimeType(String mimeType)
Add a mime-type which will be compressable The mime-type String will be exactly matched in the response mime-type header .
protected voidaddFilter(String className)
Add input or output filter.
protected booleanaddInputFilter(InputFilter[] inputFilters, String encodingName)
Add an input filter to the current request.
voidaddNoCompressionUserAgent(String userAgent)
Add user-agent for which gzip compression didn't works The user agent String given will be exactly matched to the user-agent header submitted by the client.
voidaddRestrictedUserAgent(String userAgent)
Add restricted user-agent (which will downgrade the connector to HTTP/1.0 mode).
voidendRequest()
NioEndpoint.Handler.SocketStateevent(SocketStatus status)
Process pipelined HTTP requests using the specified input and output streams.
protected intfindBytes(ByteChunk bc, byte[] b)
Specialized utility method: find a sequence of lower case bytes inside a ByteChunk.
String[]findCompressableMimeTypes()
Return the list of restricted user agents.
String[]findRestrictedUserAgents()
Return the list of restricted user agents.
AdaptergetAdapter()
Get the associated adapter.
StringgetCompression()
Return compression level.
booleangetDisableUploadTimeout()
Get the flag that controls upload time-outs.
intgetMaxKeepAliveRequests()
Return the number of Keep-Alive requests that we will honor.
intgetMaxSavePostSize()
Return the maximum size of a POST which will be buffered in SSL mode.
RequestgetRequest()
Get the request associated with this processor.
StringgetServer()
Get the server header name.
intgetSocketBuffer()
Get the socket buffer flag.
SSLSupportgetSslSupport()
intgetTimeout()
Get the upload timeout.
protected voidinitializeFilters()
Initialize standard input and output filters.
voidparseHost(MessageBytes valueMB)
Parse host.
protected voidprepareRequest()
After reading the request headers, we have to setup the request filters.
protected voidprepareResponse()
When committing the response, we have to validate the set of headers, as well as setup the response filters.
NioEndpoint.Handler.SocketStateprocess(NioChannel socket)
Process pipelined HTTP requests using the specified input and output streams.
voidrecycle()
voidsetAdapter(Adapter adapter)
Set the associated adapter.
voidsetCompressableMimeTypes(String[] compressableMimeTypes)
Set compressable mime-type list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).
voidsetCompressableMimeTypes(String compressableMimeTypes)
Set compressable mime-type list List contains users agents separated by ',' : ie: "text/html,text/xml,text/plain"
voidsetCompression(String compression)
Set compression level.
voidsetCompressionMinSize(int compressionMinSize)
Set Minimum size to trigger compression.
voidsetDisableUploadTimeout(boolean isDisabled)
Set the flag to control upload time-outs.
voidsetMaxKeepAliveRequests(int mkar)
Set the maximum number of Keep-Alive requests to honor.
voidsetMaxSavePostSize(int msps)
Set the maximum size of a POST which will be buffered in SSL mode.
voidsetNoCompressionUserAgents(Pattern[] noCompressionUserAgents)
Set no compression user agent list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).
voidsetNoCompressionUserAgents(String noCompressionUserAgents)
Set no compression user agent list.
voidsetRestrictedUserAgents(Pattern[] restrictedUserAgents)
Set restricted user agent list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).
voidsetRestrictedUserAgents(String restrictedUserAgents)
Set restricted user agent list (which will downgrade the connector to HTTP/1.0 mode).
voidsetServer(String server)
Set the server header name.
voidsetSocketBuffer(int socketBuffer)
Set the socket buffer flag.
voidsetSslSupport(SSLSupport sslSupport)
voidsetTimeout(int timeouts)
Set the upload timeout.
protected booleanstatusDropsConnection(int status)
Determine if we must drop the connection because of the HTTP status code.

Field Detail

adapter

protected Adapter adapter
Associated adapter.

comet

protected boolean comet
Comet used.

cometClose

protected boolean cometClose
Closed flag, a Comet async thread can signal for this Nio processor to be closed and recycled instead of waiting for a timeout. Closed by HttpServletResponse.getWriter().close()

compressableMimeTypes

protected String[] compressableMimeTypes
List of MIMES which could be gzipped

compressionLevel

protected int compressionLevel
Allowed compression level.

compressionMinSize

protected int compressionMinSize
Minimum contentsize to make compression.

contentDelimitation

protected boolean contentDelimitation
Content delimitator for the request (if false, the connection will be closed at the end of the request).

disableUploadTimeout

protected boolean disableUploadTimeout
Flag to disable setting a different time-out on uploads.

endpoint

protected NioEndpoint endpoint
Associated endpoint.

error

protected boolean error
Error flag.

expectation

protected boolean expectation
Is there an expectation ?

hostNameC

protected char[] hostNameC
Host name (used to avoid useless B2C conversion on the host name).

http09

protected boolean http09
HTTP/0.9 flag.

http11

protected boolean http11
HTTP/1.1 flag.

inputBuffer

protected InternalNioInputBuffer inputBuffer
Input.

keepAlive

protected boolean keepAlive
Keep-alive.

localAddr

protected String localAddr
The local Host address.

localName

protected String localName
Local Host associated with the current connection.

localPort

protected int localPort
Local port to which the socket is connected

log

protected static Log log
Logger.

maxKeepAliveRequests

protected int maxKeepAliveRequests
Maximum number of Keep-Alive requests to honor.

maxSavePostSize

protected int maxSavePostSize
Max save post size.

noCompressionUserAgents

protected Pattern[] noCompressionUserAgents
List of user agents to not use gzip with

outputBuffer

protected InternalNioOutputBuffer outputBuffer
Output.

remoteAddr

protected String remoteAddr
Remote Address associated with the current connection.

remoteHost

protected String remoteHost
Remote Host associated with the current connection.

remotePort

protected int remotePort
Remote port to which the socket is connected

request

protected Request request
Request object.

response

protected Response response
Response object.

restrictedUserAgents

protected Pattern[] restrictedUserAgents
List of restricted user agents.

sendfileData

protected NioEndpoint.SendfileData sendfileData
Sendfile data.

server

protected String server
Allow a customized the server header for the tin-foil hat folks.

sm

protected static StringManager sm
The string manager for this package.

socket

protected NioChannel socket
Socket associated with the current connection.

socketBuffer

protected int socketBuffer
Socket buffering.

ssl

protected boolean ssl
SSL enabled ?

sslSupport

protected SSLSupport sslSupport
SSL information.

timeout

protected int timeout
Maximum timeout on uploads. 5 minutes as in Apache HTTPD server.

Constructor Detail

Http11NioProcessor

public Http11NioProcessor(int rxBufSize, int txBufSize, int maxHttpHeaderSize, NioEndpoint endpoint)

Method Detail

action

public void action(ActionCode actionCode, Object param)
Send an action to the connector.

Parameters: actionCode Type of the action param Action parameter

addCompressableMimeType

public void addCompressableMimeType(String mimeType)
Add a mime-type which will be compressable The mime-type String will be exactly matched in the response mime-type header .

Parameters: mimeType mime-type string

addFilter

protected void addFilter(String className)
Add input or output filter.

Parameters: className class name of the filter

addInputFilter

protected boolean addInputFilter(InputFilter[] inputFilters, String encodingName)
Add an input filter to the current request.

Returns: false if the encoding was not found (which would mean it is unsupported)

addNoCompressionUserAgent

public void addNoCompressionUserAgent(String userAgent)
Add user-agent for which gzip compression didn't works The user agent String given will be exactly matched to the user-agent header submitted by the client.

Parameters: userAgent user-agent string

addRestrictedUserAgent

public void addRestrictedUserAgent(String userAgent)
Add restricted user-agent (which will downgrade the connector to HTTP/1.0 mode). The user agent String given will be matched via regexp to the user-agent header submitted by the client.

Parameters: userAgent user-agent string

endRequest

public void endRequest()

event

public NioEndpoint.Handler.SocketState event(SocketStatus status)
Process pipelined HTTP requests using the specified input and output streams.

Throws: IOException error during an I/O operation

findBytes

protected int findBytes(ByteChunk bc, byte[] b)
Specialized utility method: find a sequence of lower case bytes inside a ByteChunk.

findCompressableMimeTypes

public String[] findCompressableMimeTypes()
Return the list of restricted user agents.

findRestrictedUserAgents

public String[] findRestrictedUserAgents()
Return the list of restricted user agents.

getAdapter

public Adapter getAdapter()
Get the associated adapter.

Returns: the associated adapter

getCompression

public String getCompression()
Return compression level.

getDisableUploadTimeout

public boolean getDisableUploadTimeout()
Get the flag that controls upload time-outs.

getMaxKeepAliveRequests

public int getMaxKeepAliveRequests()
Return the number of Keep-Alive requests that we will honor.

getMaxSavePostSize

public int getMaxSavePostSize()
Return the maximum size of a POST which will be buffered in SSL mode.

getRequest

public Request getRequest()
Get the request associated with this processor.

Returns: The request

getServer

public String getServer()
Get the server header name.

getSocketBuffer

public int getSocketBuffer()
Get the socket buffer flag.

getSslSupport

public SSLSupport getSslSupport()

getTimeout

public int getTimeout()
Get the upload timeout.

initializeFilters

protected void initializeFilters()
Initialize standard input and output filters.

parseHost

public void parseHost(MessageBytes valueMB)
Parse host.

prepareRequest

protected void prepareRequest()
After reading the request headers, we have to setup the request filters.

prepareResponse

protected void prepareResponse()
When committing the response, we have to validate the set of headers, as well as setup the response filters.

process

public NioEndpoint.Handler.SocketState process(NioChannel socket)
Process pipelined HTTP requests using the specified input and output streams.

Throws: IOException error during an I/O operation

recycle

public void recycle()

setAdapter

public void setAdapter(Adapter adapter)
Set the associated adapter.

Parameters: adapter the new adapter

setCompressableMimeTypes

public void setCompressableMimeTypes(String[] compressableMimeTypes)
Set compressable mime-type list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).

setCompressableMimeTypes

public void setCompressableMimeTypes(String compressableMimeTypes)
Set compressable mime-type list List contains users agents separated by ',' : ie: "text/html,text/xml,text/plain"

setCompression

public void setCompression(String compression)
Set compression level.

setCompressionMinSize

public void setCompressionMinSize(int compressionMinSize)
Set Minimum size to trigger compression.

setDisableUploadTimeout

public void setDisableUploadTimeout(boolean isDisabled)
Set the flag to control upload time-outs.

setMaxKeepAliveRequests

public void setMaxKeepAliveRequests(int mkar)
Set the maximum number of Keep-Alive requests to honor. This is to safeguard from DoS attacks. Setting to a negative value disables the check.

setMaxSavePostSize

public void setMaxSavePostSize(int msps)
Set the maximum size of a POST which will be buffered in SSL mode.

setNoCompressionUserAgents

public void setNoCompressionUserAgents(Pattern[] noCompressionUserAgents)
Set no compression user agent list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).

setNoCompressionUserAgents

public void setNoCompressionUserAgents(String noCompressionUserAgents)
Set no compression user agent list. List contains users agents separated by ',' : ie: "gorilla,desesplorer,tigrus"

setRestrictedUserAgents

public void setRestrictedUserAgents(Pattern[] restrictedUserAgents)
Set restricted user agent list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).

setRestrictedUserAgents

public void setRestrictedUserAgents(String restrictedUserAgents)
Set restricted user agent list (which will downgrade the connector to HTTP/1.0 mode). List contains users agents separated by ',' : ie: "gorilla,desesplorer,tigrus"

setServer

public void setServer(String server)
Set the server header name.

setSocketBuffer

public void setSocketBuffer(int socketBuffer)
Set the socket buffer flag.

setSslSupport

public void setSslSupport(SSLSupport sslSupport)

setTimeout

public void setTimeout(int timeouts)
Set the upload timeout.

statusDropsConnection

protected boolean statusDropsConnection(int status)
Determine if we must drop the connection because of the HTTP status code. Use the same list of codes as Apache/httpd.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.