Open
Description
Minimal reproduction (requires a webserver running on localhost:9292):
require "rubygems"
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "async-http-faraday", require: false
end
require "faraday"
require "async/http/faraday"
Faraday.default_adapter = :async_http
conn = Faraday.new(url: "http://localhost:9292")
conn.post("/")
Here's the raw request I get, notice the double content-length
(although with different capitalization):
POST / HTTP/1.1\r\n
host: localhost:9200\r\n
User-Agent: Faraday v2.12.2\r\n
Content-Length: 0\r\n
content-length: 0\r\n
\r\n
Changing the Faraday adapter to :net_http
doesn't have this problem.
The capitalized Content-Length
seems to be set by Faraday itself at Faraday::Env#clear_body
. Async::HTTP
seems to be adding the lower-case one.
I also noticed that setting the body to empty string doesn't suffer from this issue, but I can't do that in my case since I'm using a 3rd party library:
conn.post("/") do |req|
req.body = ""
end
Results in:
POST / HTTP/1.1\r\n
host: localhost:9200\r\n
User-Agent: Faraday v2.12.2\r\n
Content-Type: application/x-www-form-urlencoded\r\n
content-length: 0\r\n
\r\n
Metadata
Metadata
Assignees
Labels
No labels