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