Skip to content
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

IfMatch succeeds decode without values given (for example) #145

Open
FlixCoder opened this issue Aug 23, 2023 · 4 comments
Open

IfMatch succeeds decode without values given (for example) #145

FlixCoder opened this issue Aug 23, 2023 · 4 comments

Comments

@FlixCoder
Copy link

Hi!

Axum's change to TypedHeader (via this issue) made it that decode is called on an empty iterator of values.
However, IfMatch and probably more headers now always succeed even if the header was not present and return an empty IfMatch(EntityTagRange::Tags("")).
It should probably fail if there is no value present.

Thank you!

@seanmonstar
Copy link
Member

Whether a certain header type should consider an empty value a header is probably worth discussing in each case. But I did want to point out that there is a method, typed_try_get(), which will return None if the name does not exist.

@FlixCoder
Copy link
Author

So you think I should rather open an issue in axum stating that the handling is actually incorrect?

@FlixCoder
Copy link
Author

After further discussion and looking at documentation, an empty value should either yield the header's default value or error.
For If-Match, I think erroring makes sense, though * as value might be fine, too. An empty tag, like now, seems nonsense to me.
The thing is, there was no empty value (iterator with an empty item), there was no value (empty iterator).

@jplatte
Copy link
Contributor

jplatte commented Oct 25, 2023

@seanmonstar to be clear (though I don't intend to work on it myself), in the specific case of IfMatch, you'd accept a PR that makes decode return an error when the input is an empty iterator?

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

No branches or pull requests

3 participants