-
Notifications
You must be signed in to change notification settings - Fork 129
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
Support any enumerable in mutlipart #444
Conversation
@wojtekmach is there anything I can do to fix failing tests? I see one CI job passed. |
Thank you! |
|
||
enum -> | ||
Enumerable.impl_for!(enum) | ||
size = Keyword.get(options, :content_length, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knightpp oh, I don't think 0
is a good default:
iex> url = "https://httpbin.org/anything"
iex> stream = Stream.cycle(["abc"]) |> Stream.take(3)
iex> Req.post!(url, form_multipart: [file: {stream, filename: "a.txt"}]).body["files"]
%{}
iex> Req.post!(url, form_multipart: [file: {stream, filename: "a.txt", content_length: 9}]).body["files"]
%{"file" => "abcabcabc"}
should I change this to size = Keyword.fetch!(options, :content_length)
?
body = body |> Enum.to_list() |> IO.iodata_to_binary() | ||
|
||
# content_length is +10 of actual size | ||
assert size == byte_size(body) + 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI we should have kept this property from the above test:
assert size == byte_size(body)
i.e. the size
will be used as the content-length
of the entire HTTP request and the body
will be that http request body`.
This reverts commit a745a9a.
Closes #442