org.apache.coyote.http11
Class Http11Processor

java.lang.Object
  |
  +--org.apache.coyote.http11.Http11Processor
All Implemented Interfaces:
org.apache.coyote.ActionHook, org.apache.coyote.Processor

public class Http11Processor
extends java.lang.Object
implements org.apache.coyote.Processor, org.apache.coyote.ActionHook

Processes HTTP requests.

Author:
Remy Maucherat

Field Summary
protected  org.apache.coyote.Adapter adapter
          Associated adapter.
protected  java.lang.String[] compressableMimeTypes
          List of MIMES which could be gzipped
protected  int compressionLevel
          Allowed compression level.
protected  int compressionMinSize
          Minimum contentsize to make compression.
protected  boolean contentDelimitation
          Content delimitator for the request (if false, the connection will be closed at the end of the request).
protected  boolean disableUploadTimeout
          Flag to disable setting a different time-out on uploads.
protected  boolean error
          Error flag.
protected  char[] hostNameC
          Host name (used to avoid useless B2C conversion on the host name).
protected  boolean http09
          HTTP/0.9 flag.
protected  boolean http11
          HTTP/1.1 flag.
protected  InternalInputBuffer inputBuffer
          Input.
protected  boolean keepAlive
          Keep-alive.
protected static org.apache.commons.logging.Log log
          Logger.
protected  int maxKeepAliveRequests
          Maximum number of Keep-Alive requests to honor.
protected  java.lang.String[] noCompressionUserAgents
          List of user agents to not use gzip with
protected  InternalOutputBuffer outputBuffer
          Output.
protected  java.lang.String remoteAddr
          Remote Address associated with the current connection.
protected  java.lang.String remoteHost
          Remote Host associated with the current connection.
protected  org.apache.coyote.Request request
          Request object.
protected  org.apache.coyote.Response response
          Response object.
protected  java.lang.String[] restrictedUserAgents
          List of restricted user agents.
protected  java.net.Socket socket
          Socket associated with the current connection.
protected  org.apache.tomcat.util.net.SSLSupport sslSupport
          SSL information.
protected  boolean started
          State flag.
protected  org.apache.tomcat.util.threads.ThreadPool threadPool
           
protected  int timeout
          Maximum timeout on uploads.
 
Constructor Summary
Http11Processor()
          Default constructor.
 
Method Summary
 void action(org.apache.coyote.ActionCode actionCode, java.lang.Object param)
          Send an action to the connector.
 void addCompressableMimeType(java.lang.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  void addFilter(java.lang.String className)
          Add input or output filter.
protected  boolean addInputFilter(InputFilter[] inputFilters, java.lang.String encodingName)
          Add an input filter to the current request.
 void addNoCompressionUserAgent(java.lang.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.
 void addRestrictedUserAgent(java.lang.String userAgent)
          Add restricted user-agent (which will downgrade the connector to HTTP/1.0 mode).
private  void addStringArray(java.lang.String[] sArray, java.lang.String value)
          General use method
protected  int findBytes(org.apache.tomcat.util.buf.ByteChunk bc, byte[] b)
          Specialized utility method: find a sequence of lower case bytes inside a ByteChunk.
 java.lang.String[] findCompressableMimeTypes()
          Return the list of restricted user agents.
 java.lang.String[] findNoCompressionUserAgents()
          Return the list of no compression user agents.
 java.lang.String[] findRestrictedUserAgents()
          Return the list of restricted user agents.
 org.apache.coyote.Adapter getAdapter()
          Get the associated adapter.
 java.lang.String getCompression()
          Return compression level.
 boolean getDisableUploadTimeout()
          Get the flag that controls upload time-outs.
 int getMaxKeepAliveRequests()
          Return the number of Keep-Alive requests that we will honor.
 org.apache.coyote.Request getRequest()
          Get the request associated with this processor.
 int getTimeout()
          Get the upload timeout.
protected  void initializeFilters()
          Initialize standard input and output filters.
private  boolean inStringArray(java.lang.String[] sArray, java.lang.String value)
          General use method
private  boolean isCompressable()
           
 void parseHost(org.apache.tomcat.util.buf.MessageBytes valueMB)
          Parse host.
protected  void prepareRequest()
          After reading the request headers, we have to setup the request filters.
protected  void prepareResponse()
          When committing the response, we have to validate the set of headers, as well as setup the response filters.
 void process(java.io.InputStream input, java.io.OutputStream output)
          Process pipelined HTTP requests using the specified input and output streams.
 void setAdapter(org.apache.coyote.Adapter adapter)
          Set the associated adapter.
 void setCompressableMimeType(java.lang.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).
 void setCompression(java.lang.String compression)
          Set compression level.
 void setDisableUploadTimeout(boolean isDisabled)
          Set the flag to control upload time-outs.
 void setMaxKeepAliveRequests(int mkar)
          Set the maximum number of Keep-Alive requests to honor.
 void setNoCompressionUserAgents(java.lang.String[] 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).
 void setRestrictedUserAgents(java.lang.String[] 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).
 void setSocket(java.net.Socket socket)
          Set the socket associated with this HTTP connection.
 void setSSLSupport(org.apache.tomcat.util.net.SSLSupport sslSupport)
          Set the SSL information for this HTTP connection.
 void setThreadPool(org.apache.tomcat.util.threads.ThreadPool threadPool)
           
 void setTimeout(int timeouts)
          Set the upload timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adapter

protected org.apache.coyote.Adapter adapter
Associated adapter.


request

protected org.apache.coyote.Request request
Request object.


response

protected org.apache.coyote.Response response
Response object.


inputBuffer

protected InternalInputBuffer inputBuffer
Input.


outputBuffer

protected InternalOutputBuffer outputBuffer
Output.


started

protected boolean started
State flag.


error

protected boolean error
Error flag.


keepAlive

protected boolean keepAlive
Keep-alive.


http11

protected boolean http11
HTTP/1.1 flag.


http09

protected boolean http09
HTTP/0.9 flag.


contentDelimitation

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


restrictedUserAgents

protected java.lang.String[] restrictedUserAgents
List of restricted user agents.


log

protected static org.apache.commons.logging.Log log
Logger.


maxKeepAliveRequests

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


sslSupport

protected org.apache.tomcat.util.net.SSLSupport sslSupport
SSL information.


socket

protected java.net.Socket socket
Socket associated with the current connection.


remoteAddr

protected java.lang.String remoteAddr
Remote Address associated with the current connection.


remoteHost

protected java.lang.String remoteHost
Remote Host associated with the current connection.


timeout

protected int timeout
Maximum timeout on uploads.


disableUploadTimeout

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


compressionLevel

protected int compressionLevel
Allowed compression level.


compressionMinSize

protected int compressionMinSize
Minimum contentsize to make compression.


noCompressionUserAgents

protected java.lang.String[] noCompressionUserAgents
List of user agents to not use gzip with


compressableMimeTypes

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


hostNameC

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


threadPool

protected org.apache.tomcat.util.threads.ThreadPool threadPool
Constructor Detail

Http11Processor

public Http11Processor()
Default constructor.

Method Detail

getCompression

public java.lang.String getCompression()
Return compression level.


setCompression

public void setCompression(java.lang.String compression)
Set compression level.


setThreadPool

public void setThreadPool(org.apache.tomcat.util.threads.ThreadPool threadPool)

addNoCompressionUserAgent

public void addNoCompressionUserAgent(java.lang.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

setNoCompressionUserAgents

public void setNoCompressionUserAgents(java.lang.String[] 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).


findNoCompressionUserAgents

public java.lang.String[] findNoCompressionUserAgents()
Return the list of no compression user agents.


addCompressableMimeType

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


setCompressableMimeType

public void setCompressableMimeType(java.lang.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).


findCompressableMimeTypes

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


addFilter

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

Parameters:
className - class name of the filter

addStringArray

private void addStringArray(java.lang.String[] sArray,
                            java.lang.String value)
General use method

Parameters:
sArray - the StringArray
value - string

inStringArray

private boolean inStringArray(java.lang.String[] sArray,
                              java.lang.String value)
General use method

Parameters:
sArray - the StringArray
value - string

addRestrictedUserAgent

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

Parameters:
userAgent - user-agent string

setRestrictedUserAgents

public void setRestrictedUserAgents(java.lang.String[] 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).


findRestrictedUserAgents

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


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.


getMaxKeepAliveRequests

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


setSSLSupport

public void setSSLSupport(org.apache.tomcat.util.net.SSLSupport sslSupport)
Set the SSL information for this HTTP connection.


setSocket

public void setSocket(java.net.Socket socket)
               throws java.io.IOException
Set the socket associated with this HTTP connection.

java.io.IOException

setDisableUploadTimeout

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


getDisableUploadTimeout

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


setTimeout

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


getTimeout

public int getTimeout()
Get the upload timeout.


getRequest

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

Returns:

process

public void process(java.io.InputStream input,
                    java.io.OutputStream output)
             throws java.io.IOException
Process pipelined HTTP requests using the specified input and output streams.

Specified by:
process in interface org.apache.coyote.Processor
Parameters:
input - stream from which the HTTP requests will be read
output - stream which will be used to output the HTTP responses
Throws:
java.io.IOException - error during an I/O operation

action

public void action(org.apache.coyote.ActionCode actionCode,
                   java.lang.Object param)
Send an action to the connector.

Specified by:
action in interface org.apache.coyote.ActionHook
Parameters:
actionCode - Type of the action
param - Action parameter

setAdapter

public void setAdapter(org.apache.coyote.Adapter adapter)
Set the associated adapter.

Specified by:
setAdapter in interface org.apache.coyote.Processor
Parameters:
adapter - the new adapter

getAdapter

public org.apache.coyote.Adapter getAdapter()
Get the associated adapter.

Specified by:
getAdapter in interface org.apache.coyote.Processor
Returns:
the associated adapter

prepareRequest

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


parseHost

public void parseHost(org.apache.tomcat.util.buf.MessageBytes valueMB)
Parse host.


isCompressable

private boolean isCompressable()

prepareResponse

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


initializeFilters

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


addInputFilter

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

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

findBytes

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



Copyright (c) 2001 - Apache Software Foundation