org.eclipse.jetty.http

## Class HttpParser

- java.lang.Object
- - org.eclipse.jetty.http.HttpParser

- All Implemented Interfaces:
    Parser

      public class HttpParser
      extends Object
      implements Parser

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `HttpParser.EventHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `_chunkLength`
    `protected int` | `_chunkPosition`
    `protected long` | `_contentLength`
    `protected long` | `_contentPosition`
    `protected View` | `_contentView`
    `protected byte` | `_eol`
    `protected int` | `_length`
    `protected int` | `_state`
    `static int` | `STATE_CHUNK`
    `static int` | `STATE_CHUNK_PARAMS`
    `static int` | `STATE_CHUNK_SIZE`
    `static int` | `STATE_CHUNKED_CONTENT`
    `static int` | `STATE_CONTENT`
    `static int` | `STATE_END`
    `static int` | `STATE_END0`
    `static int` | `STATE_END1`
    `static int` | `STATE_EOF_CONTENT`
    `static int` | `STATE_FIELD0`
    `static int` | `STATE_FIELD2`
    `static int` | `STATE_HEADER`
    `static int` | `STATE_HEADER_IN_NAME`
    `static int` | `STATE_HEADER_IN_VALUE`
    `static int` | `STATE_HEADER_NAME`
    `static int` | `STATE_HEADER_VALUE`
    `static int` | `STATE_SEEKING_EOF`
    `static int` | `STATE_SPACE1`
    `static int` | `STATE_SPACE2`
    `static int` | `STATE_START`
    `static int` | `STATE_STATUS`
    `static int` | `STATE_URI`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpParser(Buffer buffer, HttpParser.EventHandler handler)` Constructor.
    `HttpParser(Buffers buffers, EndPoint endp, HttpParser.EventHandler handler)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()`
    `Buffer` | `blockForContent(long maxIdleTime)`
    `protected int` | `fill()` fill the buffers from the endpoint
    `Buffer` | `getBodyBuffer()`
    `long` | `getContentLength()`
    `long` | `getContentRead()`
    `Buffer` | `getHeaderBuffer()`
    `int` | `getState()`
    `boolean` | `inContentState()`
    `boolean` | `inHeaderState()`
    `boolean` | `isChunking()`
    `boolean` | `isComplete()`
    `boolean` | `isIdle()`
    `boolean` | `isMoreInBuffer()`
    `boolean` | `isPersistent()`
    `boolean` | `isState(int state)`
    `void` | `parse()` Parse until `END` state.
    `boolean` | `parseAvailable()` Parse until END state.
    `int` | `parseNext()` Parse until next Event.
    `void` | `reset()`
    `void` | `returnBuffers()`
    `void` | `setForceContentBuffer(boolean force)`
    `void` | `setHeadResponse(boolean head)` Set if a HEAD response is expected
    `void` | `setPersistent(boolean persistent)`
    `void` | `setState(int state)`
    `String` | `toString()`
    `String` | `toString(Buffer buf)`

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

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

- - ### Field Detail

    - #### STATE_START

          public static final int STATE_START

      See Also:
        Constant Field Values

    - #### STATE_FIELD0

          public static final int STATE_FIELD0

      See Also:
        Constant Field Values

    - #### STATE_SPACE1

          public static final int STATE_SPACE1

      See Also:
        Constant Field Values

    - #### STATE_STATUS

          public static final int STATE_STATUS

      See Also:
        Constant Field Values

    - #### STATE_URI

          public static final int STATE_URI

      See Also:
        Constant Field Values

    - #### STATE_SPACE2

          public static final int STATE_SPACE2

      See Also:
        Constant Field Values

    - #### STATE_END0

          public static final int STATE_END0

      See Also:
        Constant Field Values

    - #### STATE_END1

          public static final int STATE_END1

      See Also:
        Constant Field Values

    - #### STATE_FIELD2

          public static final int STATE_FIELD2

      See Also:
        Constant Field Values

    - #### STATE_HEADER

          public static final int STATE_HEADER

      See Also:
        Constant Field Values

    - #### STATE_HEADER_NAME

          public static final int STATE_HEADER_NAME

      See Also:
        Constant Field Values

    - #### STATE_HEADER_IN_NAME

          public static final int STATE_HEADER_IN_NAME

      See Also:
        Constant Field Values

    - #### STATE_HEADER_VALUE

          public static final int STATE_HEADER_VALUE

      See Also:
        Constant Field Values

    - #### STATE_HEADER_IN_VALUE

          public static final int STATE_HEADER_IN_VALUE

      See Also:
        Constant Field Values

    - #### STATE_END

          public static final int STATE_END

      See Also:
        Constant Field Values

    - #### STATE_EOF_CONTENT

          public static final int STATE_EOF_CONTENT

      See Also:
        Constant Field Values

    - #### STATE_CONTENT

          public static final int STATE_CONTENT

      See Also:
        Constant Field Values

    - #### STATE_CHUNKED_CONTENT

          public static final int STATE_CHUNKED_CONTENT

      See Also:
        Constant Field Values

    - #### STATE_CHUNK_SIZE

          public static final int STATE_CHUNK_SIZE

      See Also:
        Constant Field Values

    - #### STATE_CHUNK_PARAMS

          public static final int STATE_CHUNK_PARAMS

      See Also:
        Constant Field Values

    - #### STATE_CHUNK

          public static final int STATE_CHUNK

      See Also:
        Constant Field Values

    - #### STATE_SEEKING_EOF

          public static final int STATE_SEEKING_EOF

      See Also:
        Constant Field Values

    - #### _contentView

          protected final View _contentView

    - #### _state

          protected int _state

    - #### _eol

          protected byte _eol

    - #### _length

          protected int _length

    - #### _contentLength

          protected long _contentLength

    - #### _contentPosition

          protected long _contentPosition

    - #### _chunkLength

          protected int _chunkLength

    - #### _chunkPosition

          protected int _chunkPosition

  - ### Constructor Detail

    - #### HttpParser

          public HttpParser(Buffer buffer,
                    HttpParser.EventHandler handler)

      Constructor.

    - #### HttpParser

          public HttpParser(Buffers buffers,
                    EndPoint endp,
                    HttpParser.EventHandler handler)

      Constructor.
      Parameters:
        `buffers` - the buffers to use
        `endp` - the endpoint
        `handler` - the even handler

  - ### Method Detail

    - #### getContentLength

          public long getContentLength()

    - #### getContentRead

          public long getContentRead()

    - #### setHeadResponse

          public void setHeadResponse(boolean head)

      Set if a HEAD response is expected
      Parameters:
        `head` -

    - #### getState

          public int getState()

    - #### inContentState

          public boolean inContentState()

    - #### inHeaderState

          public boolean inHeaderState()

    - #### isChunking

          public boolean isChunking()

    - #### isIdle

          public boolean isIdle()

      Specified by:
        `isIdle` in interface `Parser`

    - #### isComplete

          public boolean isComplete()

      Specified by:
        `isComplete` in interface `Parser`

    - #### isMoreInBuffer

          public boolean isMoreInBuffer()
                                 throws IOException

      Specified by:
        `isMoreInBuffer` in interface `Parser`
      Throws:
        `IOException`

    - #### isState

          public boolean isState(int state)

    - #### isPersistent

          public boolean isPersistent()

      Specified by:
        `isPersistent` in interface `Parser`

    - #### setPersistent

          public void setPersistent(boolean persistent)

      Specified by:
        `setPersistent` in interface `Parser`

    - #### parse

          public void parse()
                     throws IOException

      Parse until `END` state. If the parser is already in the END state, then it is `reset` and re-parsed.
      Throws:
        `IllegalStateException` - If the buffers have already been partially parsed.
        `IOException`

    - #### parseAvailable

          public boolean parseAvailable()
                                 throws IOException

      Parse until END state. This method will parse any remaining content in the current buffer as long as there is no unconsumed content. It does not care about the `current state` of the parser.
      Specified by:
        `parseAvailable` in interface `Parser`
      Returns:
        True if progress made
      Throws:
        `IOException`
      See Also:
        `parse()`, `parseNext()`

    - #### parseNext

          public int parseNext()
                        throws IOException

      Parse until next Event.
      Returns:
        an indication of progress <0 EOF, 0 no progress, >0 progress.
      Throws:
        `IOException`

    - #### fill

          protected int fill()
                      throws IOException

      fill the buffers from the endpoint
      Throws:
        `IOException`

    - #### reset

          public void reset()

      Specified by:
        `reset` in interface `Parser`

    - #### returnBuffers

          public void returnBuffers()

      Specified by:
        `returnBuffers` in interface `Parser`

    - #### setState

          public void setState(int state)

    - #### toString

          public String toString(Buffer buf)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getHeaderBuffer

          public Buffer getHeaderBuffer()

    - #### getBodyBuffer

          public Buffer getBodyBuffer()

    - #### setForceContentBuffer

          public void setForceContentBuffer(boolean force)

      Parameters:
        `force` - True if a new buffer will be forced to be used for content and the header buffer will not be used.

    - #### blockForContent

          public Buffer blockForContent(long maxIdleTime)
                                 throws IOException

      Throws:
        `IOException`

    - #### available

          public int available()
                        throws IOException

      Throws:
        `IOException`

Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.