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

## Class DefaultHttpResponseParser

- java.lang.Object
- - org.apache.hc.core5.http.impl.io.AbstractMessageParser<ClassicHttpResponse>
  - - org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser

- All Implemented Interfaces:
    HttpMessageParser<ClassicHttpResponse>

      public class DefaultHttpResponseParser
      extends AbstractMessageParser<ClassicHttpResponse>

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultHttpResponseParser()`
    `DefaultHttpResponseParser(Http1Config http1Config)`
    `DefaultHttpResponseParser(LineParser lineParser, HttpResponseFactory<ClassicHttpResponse> responseFactory, Http1Config http1Config)` Creates new instance of DefaultHttpResponseParser.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected IOException` | `createConnectionClosedException()` Subclasses must override this method to generate an appropriate exception in case of unexpected connection termination by the peer endpoint.
    `protected ClassicHttpResponse` | `createMessage(CharArrayBuffer buffer)` Subclasses must override this method to generate an instance of `HttpMessage` based on the initial input from the session buffer.

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

      `parse, parseHeaders, parseHeaders`

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

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

- - ### Constructor Detail

    - #### DefaultHttpResponseParser

          public DefaultHttpResponseParser(LineParser lineParser,
                                   HttpResponseFactory<ClassicHttpResponse> responseFactory,
                                   Http1Config http1Config)

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

    - #### DefaultHttpResponseParser

          public DefaultHttpResponseParser(Http1Config http1Config)

      Since:
        4.3

    - #### DefaultHttpResponseParser

          public DefaultHttpResponseParser()

      Since:
        4.3

  - ### Method Detail

    - #### createConnectionClosedException

          protected IOException createConnectionClosedException()

      Description copied from class: `AbstractMessageParser`
      Subclasses must override this method to generate an appropriate exception in case of unexpected connection termination by the peer endpoint.
      Specified by:
        `createConnectionClosedException` in class `AbstractMessageParser<ClassicHttpResponse>`

    - #### createMessage

          protected ClassicHttpResponse 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<ClassicHttpResponse>`
      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.