org.apache.hc.core5.http.impl.io

## Class DefaultHttpRequestParser

- java.lang.Object
- - org.apache.hc.core5.http.impl.io.AbstractMessageParser<ClassicHttpRequest>
  - - org.apache.hc.core5.http.impl.io.DefaultHttpRequestParser

- All Implemented Interfaces:
    HttpMessageParser<ClassicHttpRequest>

      public class DefaultHttpRequestParser
      extends AbstractMessageParser<ClassicHttpRequest>

  HTTP request parser that obtain its input from an instance of `SessionInputBuffer`.
  Since:
    4.2

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultHttpRequestParser()`
    `DefaultHttpRequestParser(Http1Config http1Config)`
    `DefaultHttpRequestParser(LineParser lineParser, HttpRequestFactory<ClassicHttpRequest> requestFactory, Http1Config http1Config)` Creates new instance of DefaultHttpRequestParser.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ClassicHttpRequest` | `createMessage(CharArrayBuffer buffer)` Subclasses must override this method to generate an instance of `HttpMessage` based on the initial input from the session buffer.
    `ClassicHttpRequest` | `parse(SessionInputBuffer buffer, InputStream inputStream)` Generates an instance of `MessageHeaders` from the given input stream..

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

      `createConnectionClosedException, parseHeaders, parseHeaders`

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

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

- - ### Constructor Detail

    - #### DefaultHttpRequestParser

          public DefaultHttpRequestParser(LineParser lineParser,
                                          HttpRequestFactory<ClassicHttpRequest> requestFactory,
                                          Http1Config http1Config)

      Creates new instance of DefaultHttpRequestParser.
      Parameters:
        `lineParser` - the line parser. If `null` `LazyLineParser.INSTANCE` will be used.
        `requestFactory` - the response factory. If `null` `DefaultClassicHttpRequestFactory.INSTANCE` will be used.
        `http1Config` - the message http1Config. If `null` `Http1Config.DEFAULT` will be used.
      Since:
        4.3

    - #### DefaultHttpRequestParser

          public DefaultHttpRequestParser(Http1Config http1Config)

      Since:
        4.3

    - #### DefaultHttpRequestParser

          public DefaultHttpRequestParser()

      Since:
        4.3

  - ### Method Detail

    - #### parse

          public ClassicHttpRequest parse(SessionInputBuffer buffer,
                                          InputStream inputStream)
                                   throws IOException,
                                          HttpException

      Description copied from interface: `HttpMessageParser`
      Generates an instance of `MessageHeaders` from the given input stream..
      Specified by:
        `parse` in interface `HttpMessageParser<ClassicHttpRequest>`
      Overrides:
        `parse` in class `AbstractMessageParser<ClassicHttpRequest>`
      Parameters:
        `buffer` - Session input buffer
        `inputStream` - Input stream
      Returns:
        HTTP message head or `null` if the input stream has been closed by the opposite endpoint.
      Throws:
        `IOException` - in case of an I/O error
        `HttpException` - in case of HTTP protocol violation

    - #### createMessage

          protected ClassicHttpRequest createMessage(CharArrayBuffer buffer)
                                              throws IOException,
                                                     HttpException

      Description copied from class: `AbstractMessageParser`
      Subclasses must override this method to generate an instance of `HttpMessage` based on the initial input from the session buffer.

      Usually this method is expected to read just the very first line or the very first valid from the data stream and based on the input generate an appropriate instance of `HttpMessage`.

      Specified by:
        `createMessage` in class `AbstractMessageParser<ClassicHttpRequest>`
      Parameters:
        `buffer` - the session input buffer.
      Returns:
        HTTP message based on the input from the session buffer.
      Throws:
        `IOException` - in case of an I/O error.
        `HttpException` - in case of HTTP protocol violation.

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