Lines 43-48
Link Here
|
43 |
#include "util_filter.h" |
43 |
#include "util_filter.h" |
44 |
#include "apr_buckets.h" |
44 |
#include "apr_buckets.h" |
45 |
#include "http_request.h" |
45 |
#include "http_request.h" |
|
|
46 |
#include "http_protocol.h" |
46 |
#define APR_WANT_STRFUNC |
47 |
#define APR_WANT_STRFUNC |
47 |
#include "apr_want.h" |
48 |
#include "apr_want.h" |
48 |
|
49 |
|
Lines 537-542
Link Here
|
537 |
/* For a 304 or 204 response there is no entity included in |
538 |
/* For a 304 or 204 response there is no entity included in |
538 |
* the response and hence nothing to deflate. */ |
539 |
* the response and hence nothing to deflate. */ |
539 |
if (r->status == HTTP_NOT_MODIFIED || r->status == HTTP_NO_CONTENT) { |
540 |
if (r->status == HTTP_NOT_MODIFIED || r->status == HTTP_NO_CONTENT) { |
|
|
541 |
/* munge the etag only if we had done that when we came in.*/ |
542 |
if(apr_table_get(r->notes, "If-None-Match") != NULL) |
543 |
deflate_check_etag(r, "gzip"); |
544 |
|
540 |
ap_remove_output_filter(f); |
545 |
ap_remove_output_filter(f); |
541 |
return ap_pass_brigade(f->next, bb); |
546 |
return ap_pass_brigade(f->next, bb); |
542 |
} |
547 |
} |
Lines 1329-1334
Link Here
|
1329 |
return APR_SUCCESS; |
1334 |
return APR_SUCCESS; |
1330 |
} |
1335 |
} |
1331 |
|
1336 |
|
|
|
1337 |
static int etag_post_read_request(request_rec *r) |
1338 |
{ |
1339 |
/* Do not disturb clients who aren't interested in gzip |
1340 |
*/ |
1341 |
char* inm; |
1342 |
char* gz; |
1343 |
const char* accept = apr_table_get(r->headers_in, "Accept-Encoding"); |
1344 |
if ((accept == NULL) || (ap_strstr_c(accept, "gzip") == NULL)) { |
1345 |
return DECLINED; |
1346 |
} |
1347 |
|
1348 |
/* Do they have a gzip version? |
1349 |
*/ |
1350 |
inm = apr_table_get(r->headers_in, "If-None-Match"); |
1351 |
if ((inm == NULL) || ( (gz = ap_strstr(inm, "-gzip")) == NULL )) { |
1352 |
return DECLINED; |
1353 |
} |
1354 |
|
1355 |
*gz = '\0'; |
1356 |
apr_table_set(r->headers_in, "If-None-Match", apr_pstrdup(r->pool, inm)); |
1357 |
apr_table_setn(r->notes, "If-None-Match", "1"); |
1358 |
|
1359 |
return DECLINED; |
1360 |
} |
1361 |
|
1332 |
#define PROTO_FLAGS AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH |
1362 |
#define PROTO_FLAGS AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH |
1333 |
static void register_hooks(apr_pool_t *p) |
1363 |
static void register_hooks(apr_pool_t *p) |
1334 |
{ |
1364 |
{ |
Lines 1338-1343
Link Here
|
1338 |
AP_FTYPE_RESOURCE-1); |
1368 |
AP_FTYPE_RESOURCE-1); |
1339 |
ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL, |
1369 |
ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL, |
1340 |
AP_FTYPE_CONTENT_SET); |
1370 |
AP_FTYPE_CONTENT_SET); |
|
|
1371 |
ap_hook_post_read_request(etag_post_read_request, NULL, NULL, |
1372 |
APR_HOOK_MIDDLE); |
1373 |
|
1341 |
} |
1374 |
} |
1342 |
|
1375 |
|
1343 |
static const command_rec deflate_filter_cmds[] = { |
1376 |
static const command_rec deflate_filter_cmds[] = { |