http icon indicating copy to clipboard operation
http copied to clipboard

structured headers

Open fimbault opened this issue 4 years ago • 5 comments

Hi, any plan to include support for parsing and serializing structured headers? (RFC8941)

fimbault avatar Apr 07 '21 16:04 fimbault

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.

seanmonstar avatar Apr 07 '21 22:04 seanmonstar

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

fimbault avatar Apr 08 '21 09:04 fimbault

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?

seanmonstar avatar Apr 08 '21 13:04 seanmonstar

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.

fimbault avatar Apr 08 '21 14:04 fimbault

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

06chaynes avatar Feb 09 '22 14:02 06chaynes