Closed hhromic closed 4 years ago
RFC 7231 explicitly indicates identity
to be a synonym for no encoding [1]:
+----------+----------------------------------------+---------------+
| Name | Description | Reference |
+----------+----------------------------------------+---------------+
| identity | Reserved (synonym for "no encoding" in | Section 5.3.4 |
| | Accept-Encoding) | |
+----------+----------------------------------------+---------------+
Oh, I now realise that RFC 2616 (HTTP) states that ìdentity
should not be used in Content-Encoding
but only in the Accept-Encoding
header [1]:
identity
The default (identity) encoding; the use of no transformation
whatsoever. This content-coding is used only in the Accept-
Encoding header, and SHOULD NOT be used in the Content-Encoding
header.
Therefore what gziphandler
is doing is correct. I will migrate the issue to the component generating this header in my middleware pipeline. Sorry!
At the moment,
gziphandler
only compresses responses if there is noContent-Encoding
header already set in the response:https://github.com/nytimes/gziphandler/blob/master/gzip.go#L120-L141
This is ok however the Content Encoding specification contains an
identity
directive [1]:This directive essentially means a no-op encoding and should be threated the same as an empty content-encoding in
gziphandler
, i.e. candidate for on-the-fly compression.[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#Directives