-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Content length handling #544
Conversation
- closes issue 514.
Test failure is due to out-of-sync libraries. The fix I used is to bump |
It's failing because of rust-lang/cargo#4902. |
This changeset is much more complicated than it needs to be. All that needs to happen is that the body needs to be stripped using |
I'm new to Rust and know very little of Rocket internals, so there may well be a better way of doing this. I'm afraid I can't see it though, and I did play with a few approaches. I'll take you through my logic. In order to correctly meet the HTTP spec, we need to:
In the original code, the body is stripped before the content-length is set. To correctly set the length, we can either move the code that sets the content-length so it happens before the strip, or save the content-length somewhere so we know what to set it to. I felt it was simpler to move the content-length code to dispatch. The final match branch can probably be simplified to I wonder if it would be possible to automatically generate HEAD routes at start-up rather than handle them in dispatch if they aren't set. This would simplify dispatch and get rid of the need to cache the method type for this patch. |
Unfortunately I don't have a lot of time at the moment, so I went ahead and took care of it, @amouat. Apologies for being a bit short on my previous response. |
No worries, I had assumed strip_body set the size to 0, which was wrong. |
Closes #514.
I moved all logic for setting Content-Length out of
write_response
and intodispatch
.I expanded the tests in lib/tests/head_handling.rs.