-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL-encoded bodies are not readable - request errors during processing #36
Comments
@iMacTia is there documentation about what valid |
work-around for now: task = Async do
conn = Faraday.new do |c|
c.adapter :async_http
end
conn.post("https://httpbin.org/post") do |req|
req.body = StringIO.new({foo: 42}.to_query)
req.headers[Faraday::Request::UrlEncoded::CONTENT_TYPE] ||= Faraday::Request::UrlEncoded.mime_type
end
ensure
conn&.close
end
task.wait |
I think I found the solution, I'll try to make a release within a few hours including the fix. |
also seeing this with e.g. task = Async do
conn = Faraday.new do |c|
c.request :json
c.adapter :async_http
end
conn.post("https://httpbin.org/post") do |req|
req.body = {foo: 42}
end
ensure
conn&.close
end
task.wait fwiw. almost certainly has the same fix, though. |
Do you mind trying out |
|
Thank you for the quick fix @ioquatix 🙌 I'm surprised this never happened before because to my knowledge it's fairly common for Faraday to pass a string as the request body for post/put/patch methods 🤔
|
It seems like it's at least either:
|
mmmh it seems like To be fair, Faraday have just recently added first-class support for RESPONSE streaming, this looks more like we want to support request body streaming. Might be a good addition to the API. Adapters like |
For sure it seems needed for multipart post - because that is a rich object which responds to |
Actually yes, Net::HTTP does support streams, but you also have to set
And this is exactly what So yeah, it seems like adapters should support both. Documentation should definitely point this out more explicitly |
Opened lostisland/faraday#1554, thank you so much for the discussion 🙌 ! |
it seems setting the body to a hash for
url_encoded
requests results in aString
body in the async faraday adapter where it is expecting aReadable
?code to repro:
The text was updated successfully, but these errors were encountered: