lostisland / faraday

Simple, but flexible HTTP client library, with support for multiple backends.
https://lostisland.github.io/faraday
MIT License
5.72k stars 972 forks source link

Allow application/x-www-form-url_encoded POST requests to use file objects as the request body #1415

Closed catlee closed 2 years ago

catlee commented 2 years ago

Description

Currently if you try to do something like

Faraday.post("https://httpbingo.org/post", StringIO.new("hello"), {'content-length': '5'})

you will get an ArgumentError raised from url_encoded.rb since it's trying to pass the StringIO object to Hash.

This PR skips over bodies that respond to the :read method in addition to bodies that respond to the :to_str method.

Todos

List any remaining work that needs to be done, i.e: