Skip to content

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

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

TheFrozenFire
Copy link

@TheFrozenFire TheFrozenFire commented Nov 1, 2024

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"

Copy link
Member

@th4s th4s left a 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?

@th4s th4s requested a review from sinui0 November 25, 2024 09:33
Copy link
Member

@sinui0 sinui0 left a 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.

))
let bad_values = request
.headers_with_name("Transfer-Encoding")
.map(|h| std::str::from_utf8(h.value.0.as_bytes()).unwrap_or(""))
Copy link
Member

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.

Copy link
Author

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.

@TheFrozenFire TheFrozenFire force-pushed the fix/transfer-encoding-error-clarity branch from b78d6ba to 60472fc Compare April 28, 2025 20:51
@TheFrozenFire
Copy link
Author

Thanks lgtm,

looks like formatting is off. Did you use rustfmt?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants