MINOR: compression: automatically disable compression for older browsers

A number of older browsers have many issues with compressed contents. It
happens that all these older browsers announce themselves as "Mozilla/4"
and that despite not being all broken, the amount of working browsers
announcing themselves this way compared to all other ones is so tiny
that it's not worth wasting cycles trying to adapt to every specific
one.

So let's simply disable compression for these older browsers.

More information on this very detailed article :

   http://zoompf.com/2012/02/lose-the-wait-http-compression
This commit is contained in:
Willy Tarreau 2012-10-26 02:11:25 +02:00
parent 82fe75c1a7
commit 05d846092f

View File

@ -1970,14 +1970,25 @@ static inline int http_skip_chunk_crlf(struct http_msg *msg)
/*
* Selects a compression algorithm depending on the client request.
*/
*/
int select_compression_request_header(struct session *s, struct buffer *req)
{
struct http_txn *txn = &s->txn;
struct hdr_ctx ctx;
struct comp_algo *comp_algo = NULL;
/* Disable compression for older user agents announcing themselves as "Mozilla/4".
* Note all of them are broken but they are very few and the broken ones are there.
* See http://zoompf.com/2012/02/lose-the-wait-http-compression for more details.
*/
ctx.idx = 0;
if (http_find_header2("User-Agent", 10, req->p, &txn->hdr_idx, &ctx) &&
ctx.vlen >= 9 &&
memcmp(ctx.line + ctx.val, "Mozilla/4", 9) == 0) {
s->comp_algo = NULL;
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)) {