Apache Tomcat 7.0.4

org.apache.coyote.http11
Class InternalNioInputBuffer

java.lang.Object
  extended by org.apache.coyote.http11.AbstractInputBuffer
      extended by org.apache.coyote.http11.InternalNioInputBuffer
All Implemented Interfaces:
InputBuffer

public class InternalNioInputBuffer
extends AbstractInputBuffer

Implementation of InputBuffer which provides HTTP request header parsing as well as transfer decoding.

Author:
Remy Maucherat, Filip Hanik

Nested Class Summary
static class InternalNioInputBuffer.HeaderParseData
           
protected  class InternalNioInputBuffer.SocketInputBuffer
          This class is an input buffer which will read its data from an input stream.
 
Field Summary
protected  InternalNioInputBuffer.HeaderParseData headerData
           
protected  org.apache.coyote.http11.InternalNioInputBuffer.HeaderParsePosition headerParsePos
           
protected  boolean parsingHeader
          Parsing state - used for non blocking parsing so that when more data arrives, we can pick up where we left off.
protected  boolean parsingRequestLine
           
protected  boolean parsingRequestLineEol
           
protected  int parsingRequestLinePhase
           
protected  int parsingRequestLineQPos
           
protected  int parsingRequestLineStart
           
protected  NioSelectorPool pool
          Selector pool, for blocking reads and blocking writes
protected  NioChannel socket
          Underlying socket.
 
Fields inherited from class org.apache.coyote.http11.AbstractInputBuffer
activeFilters, buf, end, filterLibrary, headers, inputStream, inputStreamInputBuffer, lastActiveFilter, lastValid, pos, request, sm, swallowInput
 
Constructor Summary
InternalNioInputBuffer(Request request, int headerBufferSize)
          Alternate constructor.
 
Method Summary
 int available()
          Available bytes (note that due to encoding, this may not correspond )
protected  boolean fill(boolean block)
          Fill the internal buffer using data from the underlying input stream.
protected  boolean fill(boolean timeout, boolean block)
           
 int getParsingRequestLinePhase()
           
 NioSelectorPool getSelectorPool()
           
 NioChannel getSocket()
          Get the underlying socket input stream.
 boolean isReadable()
          Returns true if there are bytes available from the socket layer
 int nbRead()
          Issues a non blocking read
 void nextRequest()
          End processing of current HTTP request.
 org.apache.coyote.http11.InternalNioInputBuffer.HeaderParseStatus parseHeader()
          Parse an HTTP header.
 boolean parseHeaders()
          Parse the HTTP headers.
 boolean parseRequestLine(boolean useAvailableDataOnly)
          Read the request line.
 void recycle()
          Recycle the input buffer.
 void setSelectorPool(NioSelectorPool pool)
           
 void setSocket(NioChannel socket)
          Set the underlying socket.
 
Methods inherited from class org.apache.coyote.http11.AbstractInputBuffer
addActiveFilter, addFilter, clearFilters, doRead, endRequest, getFilters, getInputStream, setInputStream, setSwallowInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parsingHeader

protected boolean parsingHeader
Parsing state - used for non blocking parsing so that when more data arrives, we can pick up where we left off.


parsingRequestLine

protected boolean parsingRequestLine

parsingRequestLinePhase

protected int parsingRequestLinePhase

parsingRequestLineEol

protected boolean parsingRequestLineEol

parsingRequestLineStart

protected int parsingRequestLineStart

parsingRequestLineQPos

protected int parsingRequestLineQPos

headerParsePos

protected org.apache.coyote.http11.InternalNioInputBuffer.HeaderParsePosition headerParsePos

socket

protected NioChannel socket
Underlying socket.


pool

protected NioSelectorPool pool
Selector pool, for blocking reads and blocking writes


headerData

protected InternalNioInputBuffer.HeaderParseData headerData
Constructor Detail

InternalNioInputBuffer

public InternalNioInputBuffer(Request request,
                              int headerBufferSize)
Alternate constructor.

Method Detail

setSocket

public void setSocket(NioChannel socket)
Set the underlying socket.


getSocket

public NioChannel getSocket()
Get the underlying socket input stream.


setSelectorPool

public void setSelectorPool(NioSelectorPool pool)

getSelectorPool

public NioSelectorPool getSelectorPool()

isReadable

public boolean isReadable()
                   throws IOException
Returns true if there are bytes available from the socket layer

Returns:
boolean
Throws:
IOException

nbRead

public int nbRead()
           throws IOException
Issues a non blocking read

Returns:
int
Throws:
IOException

recycle

public void recycle()
Recycle the input buffer. This should be called when closing the connection.

Overrides:
recycle in class AbstractInputBuffer

nextRequest

public void nextRequest()
End processing of current HTTP request. Note: All bytes of the current request should have been already consumed. This method only resets all the pointers so that we are ready to parse the next HTTP request.

Overrides:
nextRequest in class AbstractInputBuffer

parseRequestLine

public boolean parseRequestLine(boolean useAvailableDataOnly)
                         throws IOException
Read the request line. This function is meant to be used during the HTTP request header parsing. Do NOT attempt to read the request body using it.

Specified by:
parseRequestLine in class AbstractInputBuffer
Returns:
true if data is properly fed; false if no data is available immediately and thread should be freed
Throws:
IOException - If an exception occurs during the underlying socket read operations, or if the given buffer is not big enough to accommodate the whole line.

parseHeaders

public boolean parseHeaders()
                     throws IOException
Parse the HTTP headers.

Specified by:
parseHeaders in class AbstractInputBuffer
Throws:
IOException

parseHeader

public org.apache.coyote.http11.InternalNioInputBuffer.HeaderParseStatus parseHeader()
                                                                              throws IOException
Parse an HTTP header.

Returns:
false after reading a blank line (which indicates that the HTTP header parsing is done
Throws:
IOException

available

public int available()
Available bytes (note that due to encoding, this may not correspond )


fill

protected boolean fill(boolean block)
                throws IOException,
                       EOFException
Fill the internal buffer using data from the underlying input stream.

Specified by:
fill in class AbstractInputBuffer
Returns:
false if at end of stream
Throws:
IOException
EOFException

fill

protected boolean fill(boolean timeout,
                       boolean block)
                throws IOException,
                       EOFException
Throws:
IOException
EOFException

getParsingRequestLinePhase

public int getParsingRequestLinePhase()

Apache Tomcat 7.0.4

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.