headers
headers copied to clipboard
IfMatch succeeds decode without values given (for example)
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!
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.
So you think I should rather open an issue in axum stating that the handling is actually incorrect?
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).
@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?