-
Notifications
You must be signed in to change notification settings - Fork 279
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
[BUG] New http return types always use chunked transfer encoding #511
Comments
I think this is probably due to our focus on supporting streaming bodies. There are probably some semantics that I missed when converting between different body types. I will try to figure out where this is coming from. |
I've created a test to reproduce the issue. #516 I'm not really sure how this can be solved. The return type that we accept is I think that in order to have JavaScript Response return an un-chunked body, it should be constructed from I could special case our Would appreciate any suggestions. |
Ok, I think I have something sort of working. If the This has a couple of limitations:
Overall this doesn't feel great, but it does address the specific case described above. |
I've been thinking about this a lot lately, diving into Workers (and loving it!) still not sure I have a strong enough grasp of the whole ecosystem to make strong suggestions... ... but one thing that feels like "the right thing to do" is to not be more restrictive than the JS API, but rather allow using Rust idioms within the JS API. So for example, it should be possible to use a Rust Stream and have it turn into ReadableStream under the hood. Rust Option::None or Unit type should turn into plain Response constructor under the hood, etc. I'm not sure that's achievable with the http type, they seem to be at odds at first glance- since the http type is generic and to convert into web_sys means knowing what that concrete type is. I don't think forcing it into a stream everywhere is the ultimate best approach, though it does seem like a great approach if one concrete type must be chosen. As an alternative, what do you think about having a trait that requires into/from web_sys types? I am not sure if it can literally be bound by From/Into or just have those as methods, but either way- having it trait-based means downstream can impl it for anything. Features can be enabled to add impls for it on various http types, axum, etc. if workers really needs access to something like headers, in the library code, that can be on the trait too I may not be seeing all the problems, but I think this also might be a way to let people transition over to http without any backwards compatibility issues, so it could be easier to get to a stable API. Just sharing some thoughts though, no pressure to go this route! |
opened a PR to demonstrate: #530 |
@dakom I think you make convincing arguments 👏 and it feels similar to Axum's |
Is there an existing issue for this?
What version of
workers-rs
are you using?0.0.23
What version of
wrangler
are you using?3.39.0
Describe the bug
After experimenting with the new http feature, I noticed that
transfer-encoding: chunked
is returned for all responses, even when manually specifying acontent-length
header. I'm not sure this is a problem for everyone but it's a change from earlier releases.Steps To Reproduce
Prior release returning
Content-Length: 2
:0.0.23 release returning
Transfer-Encoding: chunked
:The text was updated successfully, but these errors were encountered: