Project

General

Profile

Bug #1552 » mod_compress-match-for-complete-mime-type_lighty1.4.patch

Fixed some stupid bugs - stbuehler, 2008-02-15 15:38

View differences:

src/mod_compress.c
size_t m;
off_t max_fsize;
stat_cache_entry *sce = NULL;
buffer *content_type;
/* only GET and POST can get compressed */
if (con->request.http_method != HTTP_METHOD_GET &&
......
max_fsize = p->conf.compress_max_filesize;
stat_cache_get_entry(srv, con, con->physical.path, &sce);
if (!stat_cache_get_entry(srv, con, con->physical.path, &sce)) return HANDLER_GO_ON;
/* don't compress files that are too large as we need to much time to handle them */
if (max_fsize && (sce->st.st_size >> 10) > max_fsize) return HANDLER_GO_ON;
......
if (sce->st.st_size < 128) return HANDLER_GO_ON;
/* check if mimetype is in compress-config */
content_type = 0;
if (sce->content_type->ptr) {
char *c;
if ( (c = strchr(sce->content_type->ptr, ';')) != 0) {
content_type = buffer_init();
buffer_copy_string_len(content_type, sce->content_type->ptr, c - sce->content_type->ptr);
}
}
for (m = 0; m < p->conf.compress->used; m++) {
data_string *compress_ds = (data_string *)p->conf.compress->data[m];
......
return HANDLER_GO_ON;
}
if (buffer_is_equal(compress_ds->value, sce->content_type)) {
if (buffer_is_equal(compress_ds->value, sce->content_type)
|| (content_type && buffer_is_equal(compress_ds->value, content_type))) {
/* mimetype found */
data_string *ds;
buffer_free(content_type);
/* the response might change according to Accept-Encoding */
response_header_insert(srv, con, CONST_STR_LEN("Vary"), CONST_STR_LEN("Accept-Encoding"));
......
}
}
}
buffer_free(content_type);
return HANDLER_GO_ON;
}
(1-1/2)