-
Notifications
You must be signed in to change notification settings - Fork 11
Improve handling of Transfer-Encoding errors #46
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
base: dev
Are you sure you want to change the base?
Improve handling of Transfer-Encoding errors #46
Conversation
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.
Thanks lgtm,
looks like formatting is off. Did you use rustfmt
?
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.
ty
comments on request logic also apply to response.
spansy/src/http/span.rs
Outdated
)) | ||
let bad_values = request | ||
.headers_with_name("Transfer-Encoding") | ||
.map(|h| std::str::from_utf8(h.value.0.as_bytes()).unwrap_or("")) |
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.
unwrap_or("")
will be misleading if the header value is not value utf8. Better to return a parse error indicating that.
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.
Instead of returning a parse error, which might be more confusing in this case, I've updated it to use the string {invalid utf-8}
in the error message, to signify that the header value cannot be parsed as utf-8. I'm of the mind that it's clearer that way.
…-8. Interpolate bad values directly into error message
b78d6ba
to
60472fc
Compare
I've run it just now for the one rust file I changed. When I run it for the repo or crate, it produces a lot of unrelated changes. |
Transfer-Encoding errors are currently very opaque. This change updates the logic to allow for
Transfer-Encoding: identity
(the effective default), and add the incorrect values to the error message to make it easier to troubleshoot bad Transfer-Encoding values.An example of the new error message:
parsing error: Transfer-Encoding other than identity not supported yet: "chunked"