org.apache.hc.core5.http.protocol

## Class ResponseContent

- java.lang.Object
- - org.apache.hc.core5.http.protocol.ResponseContent

- All Implemented Interfaces:
    HttpResponseInterceptor
  Direct Known Subclasses:
    H2ResponseContent

      @Contract(threading=IMMUTABLE)
      public class ResponseContent
      extends Object
      implements HttpResponseInterceptor

  ResponseContent is the most important interceptor for outgoing responses. It is responsible for delimiting content length by adding `Content-Length` or `Transfer-Content` headers based on the properties of the enclosed entity and the protocol version. This interceptor is required for correct functioning of server side protocol processors.
  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResponseContent()` Default constructor.
    `ResponseContent(boolean overwrite)` Constructor that can be used to fine-tune behavior of this interceptor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `process(HttpResponse response, EntityDetails entity, HttpContext context)` Processes the response (possibly updating or inserting) Content-Length and Transfer-Encoding headers.

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

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

- - ### Constructor Detail

    - #### ResponseContent

          public ResponseContent()

      Default constructor. The `Content-Length` or `Transfer-Encoding` will cause the interceptor to throw `ProtocolException` if already present in the response message.

    - #### ResponseContent

          public ResponseContent(boolean overwrite)

      Constructor that can be used to fine-tune behavior of this interceptor.
      Parameters:
        `overwrite` - If set to `true` the `Content-Length` and `Transfer-Encoding` headers will be created or updated if already present. If set to `false` the `Content-Length` and `Transfer-Encoding` headers will cause the interceptor to throw `ProtocolException` if already present in the response message.
      Since:
        4.2

  - ### Method Detail

    - #### process

          public void process(HttpResponse response,
                     EntityDetails entity,
                     HttpContext context)
                       throws HttpException,
                              IOException

      Processes the response (possibly updating or inserting) Content-Length and Transfer-Encoding headers.
      Specified by:
        `process` in interface `HttpResponseInterceptor`
      Parameters:
        `response` - The HttpResponse to modify.
        `context` - Unused.
        `entity` - the request entity details or `null` if not available
      Throws:
        `ProtocolException` - If either the Content-Length or Transfer-Encoding headers are found.
        `IllegalArgumentException` - If the response is null.
        `HttpException` - in case of an HTTP protocol violation
        `IOException` - in case of an I/O error

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