[
https://issues.apache.org/jira/browse/HTTPCORE-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16356784#comment-16356784
]
Oleg Kalnichevski commented on HTTPCORE-512:
--------------------------------------------
(1) I see no such thing in
[RequestContent|https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java]
in master, which is the only branch of HttpCore expected to be compliant with
RFC 7230.
(2)
[RequestContent|https://github.com/apache/httpcomponents-core/blob/4.4.x/httpcore/src/main/java/org/apache/http/protocol/RequestContent.java]
in the 4.4.x branch adds {{Content-Length: 0}} header _only_ if the request
method is expected to enclose an entity (the request object implements
{{HttpEntityEnclosingRequest}} interface). This applies to PUT and POST methods
only in the stock version of HttpCore. Moreover, the 4.4.x branch of HttpCore
is expected to be compliant with RFC 2616 only.
Oleg
> GET request should not include Content-Length header
> ----------------------------------------------------
>
> Key: HTTPCORE-512
> URL: https://issues.apache.org/jira/browse/HTTPCORE-512
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Reporter: Daniel Dyląg
> Priority: Major
>
> According to RFC 7230, chapter 3.3.2:
> {noformat}
> A user agent SHOULD NOT send a Content-Length header field when the request
> message does not contain a payload body and the method semantics do not
> anticipate such a body.
> {noformat}
>
> This most importantly includes GET method. Instead, in RequestContent class,
> this header is always added if there is no entity.
> {code:java}
> if (entity == null) {
> request.addHeader(HTTP.CONTENT_LEN, "0");
> return;
> }{code}
>
> Some servers take advantage of this rule and make incorrect assumptions when
> dealing with requests from this library.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]