BUG/MINOR: http: do not ignore cache-control: public

In check_response_for_cacheability(), we don't check the
cache-control flags if the response is already supposed not to be
cacheable. This was introduced very early when cache-control:public
was not checked, and it basically results in this last one not being
able to properly mark the response as cacheable if it uses a status
code which is non-cacheable by default. Till now the impact is very
limited as it doesn't check that cookies set on non-default status
codes are not cacheable, and it prevents the cache from caching such
responses.

Let's fix this by doing two things :
  - remove the test for !TX_CACHEABLE in the aforementionned function
  - however take care of 1xx status codes here (which used to be
    implicitly dealt with by the test above) and remove the explicit
    check for 101 in the caller

This fix must be backported to 1.8.
This commit is contained in:
Willy Tarreau 2017-12-21 16:08:09 +01:00
parent 83ece462b4
commit 12b32f212f

View File

@ -5833,7 +5833,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
/*
* Check for cache-control or pragma headers if required.
*/
if (((s->be->options & PR_O_CHK_CACHE) || (s->be->ck_opts & PR_CK_NOC)) && txn->status != 101)
if ((s->be->options & PR_O_CHK_CACHE) || (s->be->ck_opts & PR_CK_NOC))
check_response_for_cacheability(s, rep);
/*
@ -7690,8 +7690,11 @@ void check_response_for_cacheability(struct stream *s, struct channel *rtr)
char *cur_ptr, *cur_end, *cur_next;
int cur_idx;
if (!(txn->flags & TX_CACHEABLE))
if (txn->status < 200) {
/* do not try to cache interim responses! */
txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK;
return;
}
/* Iterate through the headers.
* we start with the start line.