AbstractInputBuffer (Apache Tomcat 7.0.104 API Documentation)

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 byte` | `chr`
    `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 HttpParser` | `httpParser`
    `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 byte` | `prevChr`
    `protected boolean` | `rejectIllegalHeaderName` Do HTTP headers with illegal names and/or values cause the request to be rejected?
    `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()`
    `protected String` | `parseInvalid(int startPos, byte[] buffer)`
    `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.

    - #### rejectIllegalHeaderName

          protected boolean rejectIllegalHeaderName

      Do HTTP headers with illegal names and/or values cause the request to be rejected? Note that the field name is not quite right but cannot be easily changed without breaking binary compatibility.

    - #### httpParser

          protected HttpParser httpParser

    - #### prevChr

          protected byte prevChr

    - #### chr

          protected byte chr

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

    - #### parseInvalid

          protected String parseInvalid(int startPos,
                            byte[] buffer)

    - #### 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`
      Parameters:
        `chunk` - The buffer to read data into.
        `req` - The associated request
      Returns:
        The number of bytes that have been added to the buffer or -1 for end of stream
      Throws:
        `IOException` - If an I/O error occurs reading from the input stream

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