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

## Class DefaultHttpRequestParser<T extends HttpRequest>

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

- All Implemented Interfaces:
    NHttpMessageParser<T>

      public class DefaultHttpRequestParser<T extends HttpRequest>
      extends AbstractMessageParser<T>

  Default `NHttpMessageParser` implementation for `HttpRequest`s.
  Since:
    4.1

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultHttpRequestParser(HttpRequestFactory<T> requestFactory)`
    `DefaultHttpRequestParser(HttpRequestFactory<T> requestFactory, Http1Config http1Config)`
    `DefaultHttpRequestParser(HttpRequestFactory<T> requestFactory, LineParser parser, Http1Config http1Config)` Creates an instance of DefaultHttpRequestParser.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected 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.

    - ### Methods inherited from class org.apache.hc.core5.http.impl.nio.AbstractMessageParser

      `reset`

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

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

- - ### Constructor Detail

    - #### DefaultHttpRequestParser

          public DefaultHttpRequestParser(HttpRequestFactory<T> requestFactory,
                                          LineParser parser,
                                          Http1Config http1Config)

      Creates an instance of DefaultHttpRequestParser.
      Parameters:
        `requestFactory` - the request factory.
        `parser` - the line parser. If `null` `LazyLineParser.INSTANCE` will be used.
        `http1Config` - Message http1Config. If `null` `Http1Config.DEFAULT` will be used.
      Since:
        4.3

    - #### DefaultHttpRequestParser

          public DefaultHttpRequestParser(HttpRequestFactory<T> requestFactory,
                                          Http1Config http1Config)

      Since:
        4.3

    - #### DefaultHttpRequestParser

          public DefaultHttpRequestParser(HttpRequestFactory<T> requestFactory)

      Since:
        4.3

  - ### Method Detail

    - #### 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 HttpRequest>`
      Overrides:
        `parse` in class `AbstractMessageParser<T extends HttpRequest>`
      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.

    - #### createMessage

          protected T createMessage(CharArrayBuffer buffer)
                             throws HttpException

      Description copied from class: `AbstractMessageParser`
      Creates `HttpMessage` instance based on the content of the input buffer containing the first line of the incoming HTTP message.
      Specified by:
        `createMessage` in class `AbstractMessageParser<T extends HttpRequest>`
      Parameters:
        `buffer` - the line buffer.
      Returns:
        HTTP message.
      Throws:
        `HttpException` - in case of HTTP protocol violation

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