jira-importer opened a new issue, #1282: URL: https://github.com/apache/httpcomponents-core/issues/1282
**[Billy Jaime Beltran](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER284297)** opened **[HTTPCORE-759](https://issues.apache.org/jira/browse/HTTPCORE-759?redirect=false)** and commented 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/e3c770b55602eb9e5a45dfe7c6a07a1adede2c95/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/a5c117028b7c620974304636d52f06f172f1d08b/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. --- **Affects:** 5.2.2 0 votes, 5 watchers -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
