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

## Class DefaultHttpResponseFactory

- java.lang.Object
- - org.apache.hc.core5.http.impl.nio.DefaultHttpResponseFactory

- All Implemented Interfaces:
    HttpResponseFactory<HttpResponse>

      @Contract(threading=IMMUTABLE_CONDITIONAL)
      public class DefaultHttpResponseFactory
      extends Object
      implements HttpResponseFactory<HttpResponse>

  Default factory for creating `HttpResponse` objects.
  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DefaultHttpResponseFactory` | `INSTANCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultHttpResponseFactory()` Creates a new response factory with the default catalog.
    `DefaultHttpResponseFactory(ReasonPhraseCatalog catalog)` Creates a new response factory with the given catalog.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpResponse` | `newHttpResponse(int status)` Creates a new response with the given code.
    `HttpResponse` | `newHttpResponse(int status, String reasonPhrase)` Creates response message with the given code and reason phrase.

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

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

- - ### Field Detail

    - #### INSTANCE

          public static final DefaultHttpResponseFactory INSTANCE

  - ### Constructor Detail

    - #### DefaultHttpResponseFactory

          public DefaultHttpResponseFactory(ReasonPhraseCatalog catalog)

      Creates a new response factory with the given catalog.
      Parameters:
        `catalog` - the catalog of reason phrases

    - #### DefaultHttpResponseFactory

          public DefaultHttpResponseFactory()

      Creates a new response factory with the default catalog. The default catalog is `EnglishReasonPhraseCatalog`.

  - ### Method Detail

    - #### newHttpResponse

          public HttpResponse newHttpResponse(int status,
                                              String reasonPhrase)

      Description copied from interface: `HttpResponseFactory`
      Creates response message with the given code and reason phrase.
      Specified by:
        `newHttpResponse` in interface `HttpResponseFactory<HttpResponse>`
      Parameters:
        `status` - the status code
        `reasonPhrase` - the reason phrase
      Returns:
        response message

    - #### newHttpResponse

          public HttpResponse newHttpResponse(int status)

      Description copied from interface: `HttpResponseFactory`
      Creates a new response with the given code.
      Specified by:
        `newHttpResponse` in interface `HttpResponseFactory<HttpResponse>`
      Parameters:
        `status` - the status code
      Returns:
        response message

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