org.apache.coyote.http11

Class InternalInputBuffer

Implemented Interfaces:
InputBuffer

public class InternalInputBuffer
extends java.lang.Object
implements InputBuffer

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

Author:
Remy Maucherat

Nested Class Summary

protected class
InternalInputBuffer.InputStreamInputBuffer
This class is an input buffer which will read its data from an input stream.

Field Summary

protected InputFilter[]
activeFilters
Active filters (in order).
protected char[]
ascbuf
Pointer to the US-ASCII header buffer.
protected byte[]
bodyBuffer
HTTP body buffer.
protected byte[]
buf
Pointer to the current read buffer.
protected InputFilter[]
filterLibrary
Filter library.
protected char[]
headerBuffer
US-ASCII header buffer.
protected byte[]
headerBuffer1
HTTP header buffer no 1.
protected byte[]
headerBuffer2
HTTP header buffer no 2.
protected MimeHeaders
headers
Headers of the associated request.
protected InputStream
inputStream
Underlying input stream.
protected InputBuffer
inputStreamInputBuffer
Underlying input buffer.
protected int
lastActiveFilter
Index of the last active filter.
protected int
lastValid
Last valid byte.
protected boolean
parsingHeader
State.
protected int
pos
Position in the buffer.
protected Request
request
Associated Coyote request.
protected static StringManager
sm
The string manager for this package.
protected boolean
swallowInput
Swallow input ? (in the case of an expectation)

Constructor Summary

InternalInputBuffer(Request request)
Default constructor.
InternalInputBuffer(Request request, int headerBufferSize)
Alternate constructor.

Method Summary

void
addActiveFilter(InputFilter filter)
Add an input filter to the filter library.
void
addFilter(InputFilter filter)
Add an input filter to the filter library.
void
clearFilters()
Clear filters.
int
doRead(ByteChunk chunk, Request req)
Read some bytes.
void
endRequest()
End request (consumes leftover bytes).
protected boolean
fill()
Fill the internal buffer using data from the undelying input stream.
InputFilter[]
getFilters()
Get filters.
InputStream
getInputStream()
Get the underlying socket input stream.
void
nextRequest()
End processing of current HTTP request.
boolean
parseHeader()
Parse an HTTP header.
void
parseHeaders()
Parse the HTTP headers.
void
parseRequestLine()
Read the request line.
void
recycle()
Recycle the input buffer.
void
setInputStream(InputStream inputStream)
Set the underlying socket input stream.
void
setSwallowInput(boolean swallowInput)
Set the swallow input flag.

Field Details

activeFilters

protected InputFilter[] activeFilters
Active filters (in order).


ascbuf

protected char[] ascbuf
Pointer to the US-ASCII header buffer.


bodyBuffer

protected byte[] bodyBuffer
HTTP body buffer.


buf

protected byte[] buf
Pointer to the current read buffer.


filterLibrary

protected InputFilter[] filterLibrary
Filter library. Note: Filter[0] is always the "chunked" filter.


headerBuffer

protected char[] headerBuffer
US-ASCII header buffer.


headerBuffer1

protected byte[] headerBuffer1
HTTP header buffer no 1.


headerBuffer2

protected byte[] headerBuffer2
HTTP header buffer no 2.


headers

protected MimeHeaders headers
Headers of the associated request.


inputStream

protected InputStream inputStream
Underlying input stream.


inputStreamInputBuffer

protected InputBuffer inputStreamInputBuffer
Underlying input buffer.


lastActiveFilter

protected int lastActiveFilter
Index of the last active filter.


lastValid

protected int lastValid
Last valid byte.


parsingHeader

protected boolean parsingHeader
State.


pos

protected int pos
Position in the buffer.


request

protected Request request
Associated Coyote request.


sm

protected static StringManager sm
The string manager for this package.


swallowInput

protected boolean swallowInput
Swallow input ? (in the case of an expectation)

Constructor Details

InternalInputBuffer

public InternalInputBuffer(Request request)
Default constructor.


InternalInputBuffer

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

Method Details

addActiveFilter

public void addActiveFilter(InputFilter filter)
Add an input filter to the filter library.


addFilter

public void addFilter(InputFilter filter)
Add an input filter to the filter library.


clearFilters

public void clearFilters()
Clear filters.


doRead

public int doRead(ByteChunk chunk,
                  Request req)
            throws IOException
Read some bytes.
Specified by:
doRead in interface InputBuffer


endRequest

public void endRequest()
            throws IOException
End request (consumes leftover bytes).


fill

protected boolean fill()
            throws IOException
Fill the internal buffer using data from the undelying input stream.

Returns:
false if at end of stream


getFilters

public InputFilter[] getFilters()
Get filters.


getInputStream

public InputStream getInputStream()
Get the underlying socket input stream.


nextRequest

public void nextRequest()
            throws IOException
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.


parseHeader

public boolean parseHeader()
            throws IOException
Parse an HTTP header.

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


parseHeaders

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


parseRequestLine

public void parseRequestLine()
            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.


recycle

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


setInputStream

public void setInputStream(InputStream inputStream)
Set the underlying socket input stream.


setSwallowInput

public void setSwallowInput(boolean swallowInput)
Set the swallow input flag.


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.