[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-commons-dev
Subject:    [jira] [Comment Edited] (HTTPCORE-759) Content-Length missing on null entity request content
From:       "Arturo Bernal (Jira)" <jira () apache ! org>
Date:       2023-09-29 11:37:00
Message-ID: JIRA.13552406.1695980024000.112213.1695987420019 () Atlassian ! JIRA
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/HTTPCORE-759?page=com.atlassian.jira.plugi \
n.system.issuetabpanels:comment-tabpanel&focusedCommentId=17770393#comment-17770393 ] \


Arturo Bernal edited comment on HTTPCORE-759 at 9/29/23 11:36 AM:
------------------------------------------------------------------

  I agree with your [~michael-o] ,   in the interpretation of [RFC \
9110|https://www.rfc-editor.org/rfc/rfc9110#name-content-length:]. It clearly states \
that a 'Content-Length' header should not be sent when the request doesn't contain \
content and the method doesn't anticipate such data.    


was (Author: abernal):
  I agree with your [~michael-o] ,   in the interpretation of RFC 9110. It clearly \
states that a 'Content-Length' header should not be sent when the request doesn't \
contain content and the method doesn't anticipate such data.    

> Content-Length missing on null entity request content
> -----------------------------------------------------
> 
> Key: HTTPCORE-759
> URL: https://issues.apache.org/jira/browse/HTTPCORE-759
> Project: HttpComponents HttpCore
> Issue Type: Improvement
> Components: HttpCore
> Affects Versions: 5.2.2
> Reporter: Billy Jaime Beltran
> Priority: Minor
> Labels: easyfix
> Time Spent: 10m
> Remaining Estimate: 0h
> 
> When making a POST request with an empty body, the following difference in \
> behaviour was observed. In HttpComponents 4.4.x, a null body causes a \
> Content-Length zero header to be added. In HttpComponents 5.2.x, a null body causes \
> no Content-Length headers being added. While upgrading an Apache Camel application, \
> we noticed that this breaks calls to an upstream IIS server which replies with 411 \
> (Length Required). That server expects either a Content-Length 0 or a \
> Transfer-Encoding: chunked header (with a chunk-size of zero) on requests that have \
> a body semantic (POST, PUT). As the code currently stands written, if we manually \
> set `Content-Length: 0` a ProtocolException is thrown \
> [RequestContent.java:106|https://github.com/apache/httpcomponents-core/blob/e3c770b5 \
> 5602eb9e5a45dfe7c6a07a1adede2c95/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java#L106]
>  and if we call the constructor with overwrite, this header is removed anyway \
> without being replaced.   The previous behaviour (4.x) is documented \
> [RequestContent.java:102|https://github.com/apache/httpcomponents-core/blob/a5c11702 \
> 8b7c620974304636d52f06f172f1d08b/httpcore/src/main/java/org/apache/http/protocol/RequestContent.java#L102]
>  
> A suggested fix: re-add the null check and set Content-Length to zero.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic