structured headers
Hi, any plan to include support for parsing and serializing structured headers? (RFC8941)
Hey there! What specifically do you think the http crate would need to do? For turning HTTP headers into stronger Rust types, there's https://docs.rs/headers.
Hi, Thanks for pointing that out. Indeed that's a good starting point to implement the structured fields (item, list, dict). There might be a few differences to take into account, as the usage is a bit different compared to common headers:
- Ord on header name #391 would be nice, since ordering is important for HTTP message signature
- Allow header value to borrow 'static strings, rather than make allocations. Something like
pub struct HeaderValue<'a> { inner: Cow<'a, str>}, similar in spirit to #467
Are either of those needed for this specific issue? Or can they be tracked in those existing issues?
My original question is if there's anything specific we need to do to support structured fields? I think after reading through that RFC, we don't need to do anything here. It's more a way for a user to decide how to parse a header value, which we provide as a byte string. Is that right?
Probably yes. Mostly for hyper, the decision is to either include this in the core http library, or keep it separate. Same issue as in the go community.
The other issues can live separately, would probably help if resolved (for convenience and perf) but are not mandatory to get forward.
Crossposting here for reference https://github.com/http-rs/http-types/issues/344#issuecomment-1032804690
https://github.com/undef1nd/sfv
https://docs.rs/sfv/0.9.2/sfv