Anas Quazbary created HTTPCLIENT-2382: -----------------------------------------
Summary: Apache HttpClient removes the `Content-Length` header from a DELETE request even when the request has a body and the header is explicitly set. Key: HTTPCLIENT-2382 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2382 Project: HttpComponents HttpClient Issue Type: Bug Components: HttpClient (classic) Reporter: Anas Quazbary Fix For: 5.3.1 *Describe the bug* ** _(Usage via http4k-client-apache 5.29.0.0 with Apache HttpClient 5.3.1)_ ** When using Apache HttpClient (via http4k in Kotlin), I noticed that the {{Content-Length}} header is removed from DELETE requests, even when: * a body is explicitly set, and * the header is manually added to the request. As a result, the request is rejected or mishandled by the server expecting the header (e.g., visible via ngrok). *To Reproduce* Steps to reproduce the behavior: # Create a {{DELETE}} request with a JSON body and explicitly set the {{Content-Length}} header. # Send it using Apache HttpClient (via http4k). # Observe the outgoing request (e.g., via ngrok or a proxy). # {{Content-Length}} is missing. kotlin : {code:java} val request = Request(Method.DELETE, "https://xxx.ngrok.io") .header("Content-Type", "application/json") .header("Content-Length", "16") .body("""{"some": "data"}""")val client = ApacheClient() val response = client(request) {code} Expected behavior Either: Apache HttpClient should honor manually set Content-Length when a body is present, or automatically compute and include it when a body is given, even for DELETE requests. Thank you for your time and assistance. Please let me know if you need any additional information to help diagnose this issue. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org