[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17520928#comment-17520928
 ] 

Oleg Kalnichevski commented on HTTPCLIENT-2211:
-----------------------------------------------

>  Also notice content-length does not show up in headers if you have 
> org.apache.hc.client5.http.headers turned up to Debug

[~patrickjamesbarry] The content-length does not show up because it is simply 
not there. HttpClient does not generate it and does not sent it to the opposite 
endpoint. 

GET (as well as DELETE) requests with an enclosed entity are _monumentally 
stupid_ and a lot of servers and proxies have trouble dealing with them. Please 
review your server side code.

Oleg

> content-length header should not be sent when chunked encoding specified
> ------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-2211
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2211
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 5.1.3
>            Reporter: Patrick Barry
>            Priority: Major
>
> According to HTTP 1.1 spec, content-length header should never be sent with 
> Transfer-Encoding: chunked on request.  However, when you send a request 
> using a non-body Method like GET or DELETE using this async client, it is 
> adding content-length:0 to the request.  This header should not be sent 
> according to RFC.
> Because it is sent, it causes the server that is responding to either reject 
> the request with a 400 or go down other paths. For example, Tomcat 9 chose to 
> accept the request but will close the connection, even if 
> Connection:Keep-Alive is requested on request.  This has major performance 
> drawbacks, and is only one way a server chose to handle this.
>  
> As per RFC 7230:
> <quote>
> A sender MUST NOT send a Content-Length header field in any message that 
> contains a Transfer-Encoding header field.
> </quote>



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to