On Fri, Jun 18, 2021 at 04:07:10PM +0200, Tim Düsterhus, WoltLab GmbH wrote:
> Remi,
> 
> On 6/18/21 3:46 PM, Remi Tricot-Le Breton wrote:
> > > please find a small fix for the 'Vary' support of the cache to
> > > correctly handle the difference between a missing 'accept-encoding'
> > > and an empty 'accept-encoding'.
> > > 
> > Nice catch, I completely forgot about this case.
> > 
> 
> Frankly it's a bit dumb that there even is a difference between a missing
> header and an empty header. And also that content-encoding is opt-out
> instead of opt-in.

It's the case for Host and for Accept-Encoding. There was even a lengthy
discussion on this topic during the definition of the structured-headers
(now RFC8941) which do not permit to express this difference. I don't
think there's any other in this situation. While some of us preferred to
maintain that ability for compatibility purposes, the general consensus
was rather that these are design mistakes to be avoided in the future.

> I found the issue, because HAProxy was serving me a gzip encoded response
> from the cache when I was not providing an 'accept-encoding' header and I
> initially wanted to report *that* as a bug report. Then I noticed that this
> was intentional and that it is the expected behavior based on the HTTP
> specification.

Yep, accept-encoding should be seen as a filter on what you're willing
to accept. Not specifying it means you're OK with anything.

> I would not be surprised if this case is not correctly handled by the
> majority of HTTP clients out there, because most (all?) servers tend to only
> serve compressed responses if the client explicitly indicates support.

This within the server's ability or willingness to compress, as this may
be permanently or temporarily disabled based on path, extension, CPU or
RAM usage.

> After sending the patch to HAProxy I also patched the HTTP client without
> compression support in our software to specify 'accept-encoding: identity'
> to be on the safe side :-/

That's the nice thing when you control multiple components in the chain,
you can adjust to whatever remains standard but suits you better :-)

Willy

Reply via email to