org.apache.coyote.http11

## Class InternalNioInputBuffer

- java.lang.Object
- - org.apache.coyote.http11.AbstractInputBuffer<NioChannel>
  - - org.apache.coyote.http11.InternalNioInputBuffer

All Implemented Interfaces:
  InputBuffer

    public class InternalNioInputBuffer
    extends AbstractInputBuffer<NioChannel>

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

Author:
  Remy Maucherat, Filip Hanik

### Nested Class Summary

Nested Classes
`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

### Fields inherited from class org.apache.coyote.http11.AbstractInputBuffer

`activeFilters, buf, end, filterLibrary, headers, HTTP_TOKEN_CHAR, inputStreamInputBuffer, lastActiveFilter, lastValid, parsingHeader, pos, request, sm, swallowInput`

### Constructor Summary

Constructors
Constructor and Description
`InternalNioInputBuffer(Request request, int headerBufferSize)` Alternate constructor.

### Method Summary

Methods
`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()`
`protected void` `init(SocketWrapper<NioChannel> socketWrapper, AbstractEndpoint endpoint)`
`void` `nextRequest()` End processing of current HTTP request.
`boolean` `parseHeaders()` Parse the HTTP headers.
`boolean` `parseRequestLine(boolean useAvailableDataOnly)` Read the request line.
`void` `recycle()` Recycle the input buffer.

### Methods inherited from class org.apache.coyote.http11.AbstractInputBuffer

`addActiveFilter, addFilter, available, doRead, endRequest, getFilters, setSwallowInput`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### InternalNioInputBuffer

    public InternalNioInputBuffer(Request request,
                          int headerBufferSize)

Alternate constructor.

### Method Detail

#### recycle

    public void recycle()

Recycle the input buffer. This should be called when closing the connection.

Overrides:
  `recycle` in class `AbstractInputBuffer<NioChannel>`

#### 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<NioChannel>`

#### 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<NioChannel>`
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<NioChannel>`
Throws:
  `IOException`

#### getParsingRequestLinePhase

    public int getParsingRequestLinePhase()

#### init

    protected void init(SocketWrapper<NioChannel> socketWrapper,
            AbstractEndpoint endpoint)
                 throws IOException

Specified by:
  `init` in class `AbstractInputBuffer<NioChannel>`
Throws:
  `IOException`

#### 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<NioChannel>`
Returns:
  false if at end of stream
Throws:
  `IOException`
  `EOFException`

#### fill

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

Throws:
  `IOException`
  `EOFException`