org.apache.hc.core5.http.impl.nio

## Class AbstractMessageParser<T extends HttpMessage>

- java.lang.Object
- - org.apache.hc.core5.http.impl.nio.AbstractMessageParser<T>

- Type Parameters:
    `T` - The type of `HttpMessage`.
  All Implemented Interfaces:
    NHttpMessageParser<T>
  Direct Known Subclasses:
    DefaultHttpRequestParser, DefaultHttpResponseParser

      public abstract class AbstractMessageParser<T extends HttpMessage>
      extends Object
      implements NHttpMessageParser<T>

  Abstract `NHttpMessageParser` that serves as a base for all message parser implementations.
  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractMessageParser(Http1Config http1Config, LineParser lineParser)`
    `AbstractMessageParser(LineParser lineParser, Http1Config messageConstraints)` Deprecated. Use `AbstractMessageParser(Http1Config, LineParser)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract T` | `createMessage(CharArrayBuffer buffer)` Creates `HttpMessage` instance based on the content of the input buffer containing the first line of the incoming HTTP message.
    `T` | `parse(SessionInputBuffer sessionBuffer, boolean endOfStream)` Attempts to parse a complete message head from the content of the internal buffer.
    `void` | `reset()` Resets the parser.

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

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

- - ### Constructor Detail

    - #### AbstractMessageParser

          public AbstractMessageParser(Http1Config http1Config,
                                       LineParser lineParser)

      Since:
        5.3

    - #### AbstractMessageParser

          @Deprecated
          public AbstractMessageParser(LineParser lineParser,
                                                   Http1Config messageConstraints)

      Deprecated. Use `AbstractMessageParser(Http1Config, LineParser)`

  - ### Method Detail

    - #### reset

          public void reset()

      Description copied from interface: `NHttpMessageParser`
      Resets the parser. The parser will be ready to start parsing another HTTP message.
      Specified by:
        `reset` in interface `NHttpMessageParser<T extends HttpMessage>`

    - #### createMessage

          protected abstract T createMessage(CharArrayBuffer buffer)
                                      throws HttpException

      Creates `HttpMessage` instance based on the content of the input buffer containing the first line of the incoming HTTP message.
      Parameters:
        `buffer` - the line buffer.
      Returns:
        HTTP message.
      Throws:
        `HttpException` - in case of HTTP protocol violation

    - #### parse

          public T parse(SessionInputBuffer sessionBuffer,
                         boolean endOfStream)
                  throws IOException,
                         HttpException

      Description copied from interface: `NHttpMessageParser`
      Attempts to parse a complete message head from the content of the internal buffer. If the message in the input buffer is incomplete this method will return `null`.
      Specified by:
        `parse` in interface `NHttpMessageParser<T extends HttpMessage>`
      Parameters:
        `sessionBuffer` - session input buffer.
        `endOfStream` - end of stream flag
      Returns:
        HTTP message head, if available, `null` otherwise.
      Throws:
        `IOException` - in case of an I/O error.
        `HttpException` - in case the HTTP message is malformed or violates the HTTP protocol.

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.