org.apache.coyote.http11

## Class AbstractInputBuffer<S>

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

- All Implemented Interfaces:
    InputBuffer
  Direct Known Subclasses:
    InternalAprInputBuffer, InternalInputBuffer, InternalNioInputBuffer

      public abstract class AbstractInputBuffer<S>
      extends Object
      implements InputBuffer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected InputFilter[]` | `activeFilters` Active filters (in order).
    `protected byte[]` | `buf` Pointer to the current read buffer.
    `protected int` | `end` Pos of the end of the header in the buffer, which is also the start of the body.
    `protected InputFilter[]` | `filterLibrary` Filter library.
    `protected MimeHeaders` | `headers` Headers of the associated request.
    `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 ?

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractInputBuffer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addActiveFilter(InputFilter filter)` Add an input filter to the filter library.
    `void` | `addFilter(InputFilter filter)` Add an input filter to the filter library.
    `int` | `available()` Available bytes in the buffers (note that due to encoding, this may not correspond).
    `int` | `doRead(ByteChunk chunk, Request req)` Read some bytes.
    `void` | `endRequest()` End request (consumes leftover bytes).
    `protected abstract boolean` | `fill(boolean block)`
    `InputFilter[]` | `getFilters()` Get filters.
    `protected abstract void` | `init(SocketWrapper<S> socketWrapper, AbstractEndpoint<S> endpoint)`
    `void` | `nextRequest()` End processing of current HTTP request.
    `abstract boolean` | `parseHeaders()`
    `abstract boolean` | `parseRequestLine(boolean useAvailableDataOnly)` Implementations are expected to call `Request.setStartTime(long)` as soon as the first byte is read from the request.
    `void` | `recycle()` Recycle the input buffer.
    `void` | `setSwallowInput(boolean swallowInput)` Set the swallow input flag.

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

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

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

      The string manager for this package.

    - #### request

          protected Request request

      Associated Coyote request.

    - #### headers

          protected MimeHeaders headers

      Headers of the associated request.

    - #### parsingHeader

          protected boolean parsingHeader

      State.

    - #### swallowInput

          protected boolean swallowInput

      Swallow input ? (in the case of an expectation)

    - #### buf

          protected byte[] buf

      Pointer to the current read buffer.

    - #### lastValid

          protected int lastValid

      Last valid byte.

    - #### pos

          protected int pos

      Position in the buffer.

    - #### end

          protected int end

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

    - #### inputStreamInputBuffer

          protected InputBuffer inputStreamInputBuffer

      Underlying input buffer.

    - #### filterLibrary

          protected InputFilter[] filterLibrary

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

    - #### activeFilters

          protected InputFilter[] activeFilters

      Active filters (in order).

    - #### lastActiveFilter

          protected int lastActiveFilter

      Index of the last active filter.

  - ### Constructor Detail

    - #### AbstractInputBuffer

          public AbstractInputBuffer()

  - ### Method Detail

    - #### addFilter

          public void addFilter(InputFilter filter)

      Add an input filter to the filter library.

    - #### getFilters

          public InputFilter[] getFilters()

      Get filters.

    - #### addActiveFilter

          public void addActiveFilter(InputFilter filter)

      Add an input filter to the filter library.

    - #### setSwallowInput

          public void setSwallowInput(boolean swallowInput)

      Set the swallow input flag.

    - #### parseRequestLine

          public abstract boolean parseRequestLine(boolean useAvailableDataOnly)
                                            throws IOException

      Implementations are expected to call `Request.setStartTime(long)` as soon as the first byte is read from the request.
      Throws:
        `IOException`

    - #### parseHeaders

          public abstract boolean parseHeaders()
                                        throws IOException

      Throws:
        `IOException`

    - #### fill

          protected abstract boolean fill(boolean block)
                                   throws IOException

      Throws:
        `IOException`

    - #### init

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

      Throws:
        `IOException`

    - #### recycle

          public void recycle()

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

    - #### 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.

    - #### endRequest

          public void endRequest()
                          throws IOException

      End request (consumes leftover bytes).
      Throws:
        `IOException` - an underlying I/O error occurred

    - #### available

          public int available()

      Available bytes in the buffers (note that due to encoding, this may not correspond).

    - #### doRead

          public int doRead(ByteChunk chunk,
                   Request req)
                     throws IOException

      Read some bytes.
      Specified by:
        `doRead` in interface `InputBuffer`
      Throws:
        `IOException`

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