You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by da...@aol.com on 2016/10/22 17:04:02 UTC
Including Content-Length request header
I understand that HttpClient automatically includes the Content-Length request header when passing a StringEntity. But I would like to set the position of the header. But when I include the request header myself I get the following exception
"org.apache.http.ProtocolException: Content-Length header already present"
Is there anyway to bypass the auto inclusion of the Content-Length header?
Re: Including Content-Length request header
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2016-10-22 at 13:04 -0400, davidjesse091@aol.com wrote:
> I understand that HttpClient automatically includes the Content-Length request header when passing a StringEntity. But I would like to set the position of the header. But when I include the request header myself I get the following exception
>
>
> "org.apache.http.ProtocolException: Content-Length header already present"
>
>
>
>
> Is there anyway to bypass the auto inclusion of the Content-Length header?
>
If are really convinced this is a good idea you will have to remove
RequestContent interceptor from the protocol processing chain.
http://hc.apache.org/httpcomponents-client-4.5.x/httpclient/xref/org/apache/http/impl/client/HttpClientBuilder.html#1079
The only way to do so it set a custom HttpProcessor when building
HttpClient instance with HttpClientBuilder. This can be done but one
needs to be careful when assembling a custom HttpProcessor. There are
several protocol interceptors whose absence in the protocol processing
chain is very likely to cause unexpected behavior.
Proceed at your own risk.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org