org.apache.coyote.http11

Class InternalInputBuffer

public class InternalInputBuffer extends Object implements InputBuffer

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

Author: Remy Maucherat

Nested Class Summary
protected classInternalInputBuffer.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 byte[]buf
Pointer to the current read buffer.
protected intend
Pos of the end of the header in the buffer, which is also the start of the body.
protected InputFilter[]filterLibrary
Filter library.
protected MimeHeadersheaders
Headers of the associated request.
protected InputStreaminputStream
Underlying input stream.
protected InputBufferinputStreamInputBuffer
Underlying input buffer.
protected intlastActiveFilter
Index of the last active filter.
protected intlastValid
Last valid byte.
protected booleanparsingHeader
State.
protected intpos
Position in the buffer.
protected Requestrequest
Associated Coyote request.
protected static StringManagersm
The string manager for this package.
protected booleanswallowInput
Swallow input ?
Constructor Summary
InternalInputBuffer(Request request)
Default constructor.
InternalInputBuffer(Request request, int headerBufferSize)
Alternate constructor.
Method Summary
voidaddActiveFilter(InputFilter filter)
Add an input filter to the filter library.
voidaddFilter(InputFilter filter)
Add an input filter to the filter library.
voidclearFilters()
Clear filters.
intdoRead(ByteChunk chunk, Request req)
Read some bytes.
voidendRequest()
End request (consumes leftover bytes).
protected booleanfill()
Fill the internal buffer using data from the undelying input stream.
InputFilter[]getFilters()
Get filters.
InputStreamgetInputStream()
Get the underlying socket input stream.
voidnextRequest()
End processing of current HTTP request.
booleanparseHeader()
Parse an HTTP header.
voidparseHeaders()
Parse the HTTP headers.
voidparseRequestLine()
Read the request line.
voidrecycle()
Recycle the input buffer.
voidsetInputStream(InputStream inputStream)
Set the underlying socket input stream.
voidsetSwallowInput(boolean swallowInput)
Set the swallow input flag.

Field Detail

activeFilters

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

buf

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

end

protected int end
Pos of the end of the header in the buffer, which is also the start of the body.

filterLibrary

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

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 Detail

InternalInputBuffer

public InternalInputBuffer(Request request)
Default constructor.

InternalInputBuffer

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

Method Detail

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)
Read some bytes.

endRequest

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

Throws: IOException an undelying I/O error occured

fill

protected boolean fill()
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()
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()
Parse an HTTP header.

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

parseHeaders

public void parseHeaders()
Parse the HTTP headers.

parseRequestLine

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

Throws: IOException If an exception occurs during the underlying socket read operations, or if the given buffer is not big enough to accomodate the whole line.

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 © 2000-2011 Apache Software Foundation. All Rights Reserved.