-
Notifications
You must be signed in to change notification settings - Fork 83
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
HeaderMapExt should provide a typed_{try_}get
alternative that handles missing headers
#133
Comments
Ah, interesting. I guess a question then to answer is, are these two things worth distinguishing: the header was never sent, versus it was sent with an empty value. |
I'd say it's really up to specific header implementation and/or consumer. I guess if you want to keep
|
No, wait, I'm too tired by now, that doesn't help / doesn't make any sense. |
See the discussion in tokio-rs/axum#1781 (comment) for the original issue & motivation.
TL;DR is that
Header::decode
allows each typed header to handle empty iterators in its own way and let the header implementation decide whether missing header is an error or whether to provide some default "parsed" value (e.g. empty collection), butHeaderMapExt::typed_{try_}get
always returnOption::None
when header is not found in theHeaderMap
, not giving suchHeader
implementation a chance to correctly provide their own fallback.It would be useful to have variation of those methods that always return
Result<H, Error>
by forwarding an empty iterator to the specificH::decode
implementation and letting it decide whether to provide aOk(fallback_value)
or emit an error.The text was updated successfully, but these errors were encountered: