headers icon indicating copy to clipboard operation
headers copied to clipboard

Create a new AcceptEncoding header, and supporting structs/enums

Open ParkMyCar opened this issue 5 years ago • 9 comments

This PR creates a new version of the AcceptEncoding header which is built on top of a new struct QualityValue and enum ContentCoding

QualityValue is a wrapper around FlatCsv that parses the values in the csv as if they might have a quality value delimited by a default ";q=". We adhere to the spec for quality value, namely, if a value in the header doesn't have a weighting, we assign a default value of 1, and then sort equal values by order in the header (test cases are included that assert this).

ContentCoding is an enum that represents common values passed with Accept-Encoding, notably, "gzip", "deflate", "compress", "br", and "identity". The enum and its impls are derived via a new macro with doc tests to show behavior.

ParkMyCar avatar Mar 30 '20 05:03 ParkMyCar

I'd like to help get this PR approved and merged. Is there anything I can do to help?

nicksrandall avatar Jan 19 '21 17:01 nicksrandall

Is the itertools dependency strictly necessary? Who is this waiting on for approval? @seanmonstar ?

It's been almost 11 months since this was opened, and https://github.com/seanmonstar/warp/pull/513 is still waiting on this as well, which is a rather important step towards not needing nginx in front of warp.

novacrazy avatar Feb 15 '21 15:02 novacrazy

Any progress on this?

joseluisq avatar Apr 27 '21 15:04 joseluisq

Would be nice to have this merged this year, as it is required for handling compression correctly. I've been using a fork until now with this, but now I want to publish crates relying on the functionality.

What is the reason for this to not be accepted?

novacrazy avatar Jan 19 '22 08:01 novacrazy

Any progress on this?

attila-lin avatar Mar 29 '22 01:03 attila-lin

@seanmonstar Any chance to review this? I'm actually interesting in Accept not Accept-Encoding, but this seems to lay a solid foundation for other similar headers as per #7.

RReverser avatar Mar 05 '23 13:03 RReverser

Probably my biggest concern is around the QualityItem type. I feel like it was very clunky back when it existed in hyper::header.

Besides that, the design goal of porting the types in this crate has been to expose as minimal an API surface as possible, especially around internal storage, so that we can make changes for optimization purposes and not need more breaking releases. (So, not showing public fields, not giving out references to fields, but instead returning impl Iterators, etc.)

seanmonstar avatar Mar 06 '23 18:03 seanmonstar

This seems to encapsulate most APIs behind methods pretty well, except for yeah, QualityItem. Is there any better alternative it could be replaced with?

Not having Accept* headers is pretty limiting, and there are already Rust servers that implement their parsing incorrectly as a workaround (e.g. literally doing .split(",") on header value), so at this point even clunky design feels better than nothing.

RReverser avatar Mar 21 '23 23:03 RReverser

Version 0.4 of headers released without this. This could have been merged 3 years ago and improved upon since then to fix any emergent issues, but it's just sat here while everyone maintains their own outdated fork to support compression, myself included. Perfection is the enemy of progress.

novacrazy avatar Dec 15 '23 16:12 novacrazy