]> git.pld-linux.org Git - packages/lighttpd.git/blame - lighttpd-mod_compress-disable-bzip2.patch
- add compress.allowed_encodings
[packages/lighttpd.git] / lighttpd-mod_compress-disable-bzip2.patch
CommitLineData
fcf08160
ER
1--- lighttpd-1.4.19/src/mod_compress.c 2008-09-19 13:24:30.921429633 +0300
2+++ lighttpd-1.4.19/src/mod_compress.c 2008-09-19 14:16:06.292324544 +0300
cd20e898 3@@ -49,12 +49,14 @@
38ad24eb
ER
4 buffer *compress_cache_dir;
5 array *compress;
6 off_t compress_max_filesize; /** max filesize in kb */
cd20e898
ER
7+ int allowed_encodings;
8 } plugin_config;
9
10 typedef struct {
11 PLUGIN_DATA;
12 buffer *ofn;
13 buffer *b;
14+ array *encodings_arr;
15
16 plugin_config **config_storage;
17 plugin_config conf;
18@@ -154,6 +156,7 @@
38ad24eb
ER
19 { "compress.cache-dir", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },
20 { "compress.filetype", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },
21 { "compress.max-filesize", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },
cd20e898 22+ { "compress.allowed_encodings", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },
38ad24eb
ER
23 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
24 };
25
cd20e898 26@@ -166,10 +169,12 @@
38ad24eb
ER
27 s->compress_cache_dir = buffer_init();
28 s->compress = array_init();
29 s->compress_max_filesize = 0;
cd20e898 30+ s->allowed_encodings = 0;
38ad24eb
ER
31
32 cv[0].destination = s->compress_cache_dir;
33 cv[1].destination = s->compress;
34 cv[2].destination = &(s->compress_max_filesize);
cd20e898 35+ cv[3].destination = p->encodings_arr; /* temp array for allowed encodings list */
38ad24eb
ER
36
37 p->config_storage[i] = s;
38
cd20e898
ER
39@@ -177,6 +182,32 @@
40 return HANDLER_ERROR;
41 }
42
43+ if (p->encodings_arr->used) {
44+ size_t j = 0;
45+ for (j = 0; j < p->encodings_arr->used; j++) {
46+ data_string *ds = (data_string *)p->encodings_arr->data[j];
47+#ifdef USE_ZLIB
48+ if (NULL != strstr(ds->value->ptr, "gzip"))
49+ s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP;
50+ if (NULL != strstr(ds->value->ptr, "deflate"))
51+ s->allowed_encodings |= HTTP_ACCEPT_ENCODING_DEFLATE;
52+#endif
53+ /*
54+ if (NULL != strstr(ds->value->ptr, "compress"))
55+ s->allowed_encodings |= HTTP_ACCEPT_ENCODING_COMPRESS;
56+ */
57+#ifdef USE_BZ2LIB
58+ if (NULL != strstr(ds->value->ptr, "bzip2"))
59+ s->allowed_encodings |= HTTP_ACCEPT_ENCODING_BZIP2;
60+#endif
61+ }
62+ } else {
63+ /* default encodings */
64+ s->allowed_encodings = HTTP_ACCEPT_ENCODING_IDENTITY | HTTP_ACCEPT_ENCODING_GZIP |
65+ HTTP_ACCEPT_ENCODING_DEFLATE | HTTP_ACCEPT_ENCODING_COMPRESS | HTTP_ACCEPT_ENCODING_BZIP2;
66+ }
67+
68+
69 if (!buffer_is_empty(s->compress_cache_dir)) {
70 struct stat st;
71 mkdir_recursive(s->compress_cache_dir->ptr);
72@@ -587,6 +618,7 @@
38ad24eb
ER
73 PATCH(compress_cache_dir);
74 PATCH(compress);
75 PATCH(compress_max_filesize);
cd20e898 76+ PATCH(allowed_encodings);
38ad24eb
ER
77
78 /* skip the first, the global context */
79 for (i = 1; i < srv->config_context->used; i++) {
cd20e898 80@@ -606,6 +638,8 @@
38ad24eb
ER
81 PATCH(compress);
82 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("compress.max-filesize"))) {
83 PATCH(compress_max_filesize);
cd20e898
ER
84+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("compress.allowed_encodings"))) {
85+ PATCH(allowed_encodings);
38ad24eb
ER
86 }
87 }
88 }
cd20e898 89@@ -668,27 +702,19 @@
fcf08160
ER
90 if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "Accept-Encoding"))) {
91 int accept_encoding = 0;
92 char *value = ds->value->ptr;
93- int srv_encodings = 0;
94 int matched_encodings = 0;
95
96 /* get client side support encodings */
cd20e898 97 if (NULL != strstr(value, "gzip")) accept_encoding |= HTTP_ACCEPT_ENCODING_GZIP;
fcf08160
ER
98 if (NULL != strstr(value, "deflate")) accept_encoding |= HTTP_ACCEPT_ENCODING_DEFLATE;
99 if (NULL != strstr(value, "compress")) accept_encoding |= HTTP_ACCEPT_ENCODING_COMPRESS;
cd20e898
ER
100- if (NULL != strstr(value, "bzip2")) accept_encoding |= HTTP_ACCEPT_ENCODING_BZIP2;
101- if (NULL != strstr(value, "identity")) accept_encoding |= HTTP_ACCEPT_ENCODING_IDENTITY;
102-
fcf08160 103- /* get server side supported ones */
cd20e898
ER
104 #ifdef USE_BZ2LIB
105- srv_encodings |= HTTP_ACCEPT_ENCODING_BZIP2;
fcf08160
ER
106-#endif
107-#ifdef USE_ZLIB
108- srv_encodings |= HTTP_ACCEPT_ENCODING_GZIP;
109- srv_encodings |= HTTP_ACCEPT_ENCODING_DEFLATE;
cd20e898
ER
110+ if (NULL != strstr(value, "bzip2")) accept_encoding |= HTTP_ACCEPT_ENCODING_BZIP2;
111 #endif
112+ if (NULL != strstr(value, "identity")) accept_encoding |= HTTP_ACCEPT_ENCODING_IDENTITY;
113
fcf08160
ER
114 /* find matching entries */
115- matched_encodings = accept_encoding & srv_encodings;
116+ matched_encodings = accept_encoding & p->conf.allowed_encodings;
117
118 if (matched_encodings) {
119 const char *dflt_gzip = "gzip";
120--- lighttpd-1.4.19/doc/compress.txt 2008-09-19 13:27:27.571638906 +0300
121+++ lighttpd-1.4.19/doc/compress.txt 2008-09-19 14:24:12.308407368 +0300
122@@ -32,6 +32,12 @@
38ad24eb
ER
123 Options
124 =======
125
fcf08160
ER
126+compress.allowed_encodings
127+ override default set of allowed encodings
128+
129+ e.g.: ::
130+ compress.allowed_encodings = ("bzip2", "gzip", "deflate")
38ad24eb
ER
131+
132 compress.cache-dir
133 name of the directory where compressed content will be cached
134
This page took 0.04689 seconds and 4 git commands to generate.