-
Notifications
You must be signed in to change notification settings - Fork 63
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
http4s-blaze-client: File upload (Multipart) fails if server doesn't support "Transfer-Encoding: chunked" #639
Comments
Setting the |
Entity Encoders will set a Workarounds:
|
All three of those are bad answers and we should make this better. |
@rossabaker Thanks for your answer. I think I can probably try the second option which is compiling to Regarding a proper solution, what about adding an optional length info to final case class Part[F[_]](headers: Headers, body: Stream[F, Byte], length: Option[Long]) extends Media[F] When a |
Sorry, never mind what I said about |
Using |
Issue in
http4s-blaze-client
Summary
A
POST
request with Multipart body for uploading a file to GitHub Release using GitHub API fails with the following error message.Cause
It looks like GitHub API doesn't support
Transfer-Encoding: chunked
header.It's confirmed by the following curl command.
If I remove
-H "Transfer-Encoding: chunked
from the header, it succeeds.curl
sets theContent-Length
whenTransfer-Encoding: chunked
is not set.Detailed Description
When I do it using
http4s-blaze-client
, it fails sinceMultipart.headers
hasTransfer-Encoding: chunked
.If I remove
Transfer-Encoding: chunked
from theMultipart.headers
before adding it toRequest
, it can successfully upload a file when the file size is small. I don't know how small is small (maybe default buffer size?), but the file with about 719k (719,018 bytes) was OK while the one with about 2.3M (2,301,910 bytes) was not.If I remove the
Transfer-Encoding: chunked
header and set theContent-Length
manually, it can successfully upload the file.I don't think it matters but these are the Scala and http4s versions.
Scala version: 2.12.12
http4s version: 0.21.16
My guess for GitHub API not supporting
Transfer-Encoding
is probably because of this?https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
Since HTTP 2 doesn't support it and the current GitHub API is designed for HTTP 2 so it has probably dropped any HTTP 1/1.1 specific things?
Is there any way to make
http4s-blaze-client
automatically setContent-Length
?The text was updated successfully, but these errors were encountered: