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

List:       httpclient-commons-dev
Subject:    [jira] [Commented] (HTTPCORE-759) Content-Length missing on null entity request content
From:       "ASF subversion and git services (Jira)" <jira () apache ! org>
Date:       2023-09-29 13:22:00
Message-ID: JIRA.13552406.1695980024000.112548.1695993720033 () 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=17770447#comment-17770447 ] \


ASF subversion and git services commented on HTTPCORE-759:
----------------------------------------------------------

Commit de2e80749ad1c7e6e0352eb7ac82d7798c073c6f in httpcomponents-core's branch \
refs/heads/5.3.x from Billy [ \
https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=de2e80749 ]

HTTPCORE-759: Add Content-Length to POST, PUT and PATCH with null entity request \
content (#435)



> 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: 2h 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