Package org.apache.http.protocol
Class ResponseContent
java.lang.Object
org.apache.http.protocol.ResponseContent
- All Implemented Interfaces:
HttpResponseInterceptor
@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
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ResponseContent
(boolean overwrite) Constructor that can be used to fine-tune behavior of this interceptor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
process
(HttpResponse response, HttpContext context) Processes the response (possibly updating or inserting) Content-Length and Transfer-Encoding headers.
-
Field Details
-
overwrite
private final boolean overwrite
-
-
Constructor Details
-
ResponseContent
public ResponseContent()Default constructor. TheContent-Length
orTransfer-Encoding
will cause the interceptor to throwProtocolException
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 totrue
theContent-Length
andTransfer-Encoding
headers will be created or updated if already present. If set tofalse
theContent-Length
andTransfer-Encoding
headers will cause the interceptor to throwProtocolException
if already present in the response message.- Since:
- 4.2
-
-
Method Details
-
process
Processes the response (possibly updating or inserting) Content-Length and Transfer-Encoding headers.- Specified by:
process
in interfaceHttpResponseInterceptor
- Parameters:
response
- The HttpResponse to modify.context
- Unused.- 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 violationIOException
- in case of an I/O error
-