View | Details | Raw Unified | Return to bug 45023
Collapse All | Expand All

(-)modules/filters/mod_deflate.c (+36 lines)
Lines 49-54 Link Here
49
#include "zlib.h"
49
#include "zlib.h"
50
50
51
static const char deflateFilterName[] = "DEFLATE";
51
static const char deflateFilterName[] = "DEFLATE";
52
static const char etagFilterName[] = "ETAG";
52
module AP_MODULE_DECLARE_DATA deflate_module;
53
module AP_MODULE_DECLARE_DATA deflate_module;
53
54
54
typedef struct deflate_filter_config_t
55
typedef struct deflate_filter_config_t
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");
540
            ap_remove_output_filter(f);
544
            ap_remove_output_filter(f);
541
            return ap_pass_brigade(f->next, bb);
545
            return ap_pass_brigade(f->next, bb);
542
        }
546
        }
Lines 735-740 Link Here
735
    return APR_SUCCESS;
739
    return APR_SUCCESS;
736
}
740
}
737
741
742
static apr_status_t etag_in_filter(ap_filter_t *f,
743
                                      apr_bucket_brigade *bb,
744
                                      ap_input_mode_t mode,
745
                                      apr_read_type_e block,
746
                                      apr_off_t readbytes)
747
{
748
    request_rec *r = f->r;
749
    /* Do not disturb clients who aren't interested in gzip
750
    */
751
    const char* inm;
752
    char* gz;
753
    const char* accept = apr_table_get(r->headers_in, "Accept-Encoding");
754
    ap_remove_input_filter(f); /* go thru only once */
755
    if ((accept == NULL) || (ap_strstr_c(accept, "gzip") == NULL)) {
756
        return ap_get_brigade(f->next, bb, mode, block, readbytes);
757
    }
758
759
    /* Do they have a gzip version?
760
    */
761
    inm = apr_table_get(r->headers_in, "If-None-Match");
762
    if ((inm == NULL) || ( (gz = ap_strstr_c(inm, "-gzip")) == NULL )) {
763
        return ap_get_brigade(f->next, bb, mode, block, readbytes);
764
    }
765
766
    *gz = '\0';
767
    apr_table_set(r->headers_in, "If-None-Match", apr_pstrdup(r->pool, inm));
768
    apr_table_setn(r->notes, "If-None-Match", "1");
769
    return ap_get_brigade(f->next, bb, mode, block, readbytes);
770
}
771
738
/* This is the deflate input filter (inflates).  */
772
/* This is the deflate input filter (inflates).  */
739
static apr_status_t deflate_in_filter(ap_filter_t *f,
773
static apr_status_t deflate_in_filter(ap_filter_t *f,
740
                                      apr_bucket_brigade *bb,
774
                                      apr_bucket_brigade *bb,
Lines 1338-1343 Link Here
1338
                              AP_FTYPE_RESOURCE-1);
1372
                              AP_FTYPE_RESOURCE-1);
1339
    ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL,
1373
    ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL,
1340
                              AP_FTYPE_CONTENT_SET);
1374
                              AP_FTYPE_CONTENT_SET);
1375
    ap_register_input_filter(etagFilterName, etag_in_filter, NULL,
1376
                              AP_FTYPE_CONTENT_SET);
1341
}
1377
}
1342
1378
1343
static const command_rec deflate_filter_cmds[] = {
1379
static const command_rec deflate_filter_cmds[] = {

Return to bug 45023