BUG/MINOR: http-compression: lookup Cache-Control in the response, not the request
As stated in both RFC2616 and the http-bis drafts, Cache-Control:
no-transform must be looked up in the response since we're modifying
the response. However, its presence in the request is irrelevant to
any changes in the response :
7.2.1.6. no-transform
The "no-transform" request directive indicates that an intermediary
(whether or not it implements a cache) MUST NOT change the Content-
Encoding, Content-Range or Content-Type request header fields, nor
the request representation.
7.2.2.9. no-transform
The "no-transform" response directive indicates that an intermediary
(regardless of whether it implements a cache) MUST NOT change the
Content-Encoding, Content-Range or Content-Type response header
fields, nor the response representation.
Note: according to the specs, we're supposed to emit the following
response header :
Warning: 214 transformation applied
However no other product seems to do it, so the effect on user agents
is unclear.
diff --git a/src/proto_http.c b/src/proto_http.c
index aaa9476..a2f14c9 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1994,15 +1994,6 @@
return 0;
}
- ctx.idx = 0;
- /* no compression when Cache-Control: no-transform found */
- while (http_find_header2("Cache-Control", 13, req->p, &txn->hdr_idx, &ctx)) {
- if (word_match(ctx.line + ctx.val, ctx.vlen, "no-transform", 12)) {
- s->comp_algo = NULL;
- return 0;
- }
- }
-
/* search for the algo in the backend in priority or the frontend */
if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) || (s->fe->comp && (comp_algo_back = s->fe->comp->algos))) {
ctx.idx = 0;
@@ -2073,6 +2064,13 @@
if (http_find_header2("Content-Encoding", 16, res->p, &txn->hdr_idx, &ctx))
goto fail;
+ /* no compression when Cache-Control: no-transform is present in the message */
+ ctx.idx = 0;
+ while (http_find_header2("Cache-Control", 13, res->p, &txn->hdr_idx, &ctx)) {
+ if (word_match(ctx.line + ctx.val, ctx.vlen, "no-transform", 12))
+ goto fail;
+ }
+
comp_type = NULL;
/* we don't want to compress multipart content-types, nor content-types that are