]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd-mod_compress-disable-bzip2.patch
- skip encodings at compile time
[packages/lighttpd.git] / lighttpd-mod_compress-disable-bzip2.patch
1 --- lighttpd-1.4.19/src/mod_compress.c  2008-09-19 17:24:45.542342957 +0300
2 +++ lighttpd-1.4.19/src/mod_compress.c  2008-09-22 14:24:00.738911820 +0300
3 @@ -49,6 +49,7 @@
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 @@ -154,6 +155,7 @@
12                 { "compress.cache-dir",             NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },
13                 { "compress.filetype",              NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },
14                 { "compress.max-filesize",          NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },
15 +               { "compress.allowed_encodings",     NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },
16                 { NULL,                             NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
17         };
18  
19 @@ -161,15 +163,18 @@
20  
21         for (i = 0; i < srv->config_context->used; i++) {
22                 plugin_config *s;
23 +               array  *encodings_arr = array_init();
24  
25                 s = calloc(1, sizeof(plugin_config));
26                 s->compress_cache_dir = buffer_init();
27                 s->compress = array_init();
28                 s->compress_max_filesize = 0;
29 +               s->allowed_encodings = 0;
30  
31                 cv[0].destination = s->compress_cache_dir;
32                 cv[1].destination = s->compress;
33                 cv[2].destination = &(s->compress_max_filesize);
34 +               cv[3].destination = encodings_arr; /* temp array for allowed encodings list */
35  
36                 p->config_storage[i] = s;
37  
38 @@ -177,6 +182,39 @@
39                         return HANDLER_ERROR;
40                 }
41  
42 +               if (encodings_arr->used) {
43 +                       size_t j = 0;
44 +                       for (j = 0; j < encodings_arr->used; j++) {
45 +                               data_string *ds = (data_string *)encodings_arr->data[j];
46 +#ifdef USE_ZLIB
47 +                               if (NULL != strstr(ds->value->ptr, "gzip"))
48 +                                       s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP;
49 +                               if (NULL != strstr(ds->value->ptr, "deflate"))
50 +                                       s->allowed_encodings |= HTTP_ACCEPT_ENCODING_DEFLATE;
51 +                               /*
52 +                               if (NULL != strstr(ds->value->ptr, "compress"))
53 +                                       s->allowed_encodings |= HTTP_ACCEPT_ENCODING_COMPRESS;
54 +                               */
55 +#endif
56 +#ifdef USE_BZ2LIB
57 +                               if (NULL != strstr(ds->value->ptr, "bzip2"))
58 +                                       s->allowed_encodings |= HTTP_ACCEPT_ENCODING_BZIP2;
59 +#endif
60 +                       }
61 +               } else {
62 +                       /* default encodings */
63 +                       s->allowed_encodings = 0
64 +#ifdef USE_ZLIB
65 +                               | HTTP_ACCEPT_ENCODING_GZIP | HTTP_ACCEPT_ENCODING_DEFLATE
66 +#endif
67 +#ifdef USE_BZ2LIB
68 +                               | HTTP_ACCEPT_ENCODING_BZIP2
69 +#endif
70 +                               ;
71 +               }
72 +
73 +               array_free(encodings_arr);
74 +
75                 if (!buffer_is_empty(s->compress_cache_dir)) {
76                         struct stat st;
77                         mkdir_recursive(s->compress_cache_dir->ptr);
78 @@ -587,6 +625,7 @@
79         PATCH(compress_cache_dir);
80         PATCH(compress);
81         PATCH(compress_max_filesize);
82 +       PATCH(allowed_encodings);
83  
84         /* skip the first, the global context */
85         for (i = 1; i < srv->config_context->used; i++) {
86 @@ -606,6 +645,8 @@
87                                 PATCH(compress);
88                         } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("compress.max-filesize"))) {
89                                 PATCH(compress_max_filesize);
90 +                       } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("compress.allowed_encodings"))) {
91 +                               PATCH(allowed_encodings);
92                         }
93                 }
94         }
95 @@ -668,27 +709,21 @@
96                         if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "Accept-Encoding"))) {
97                                 int accept_encoding = 0;
98                                 char *value = ds->value->ptr;
99 -                               int srv_encodings = 0;
100                                 int matched_encodings = 0;
101  
102                                 /* get client side support encodings */
103 +#ifdef USE_ZLIB
104                                 if (NULL != strstr(value, "gzip")) accept_encoding |= HTTP_ACCEPT_ENCODING_GZIP;
105                                 if (NULL != strstr(value, "deflate")) accept_encoding |= HTTP_ACCEPT_ENCODING_DEFLATE;
106                                 if (NULL != strstr(value, "compress")) accept_encoding |= HTTP_ACCEPT_ENCODING_COMPRESS;
107 -                               if (NULL != strstr(value, "bzip2")) accept_encoding |= HTTP_ACCEPT_ENCODING_BZIP2;
108 -                               if (NULL != strstr(value, "identity")) accept_encoding |= HTTP_ACCEPT_ENCODING_IDENTITY;
109 -
110 -                               /* get server side supported ones */
111 -#ifdef USE_BZ2LIB
112 -                               srv_encodings |= HTTP_ACCEPT_ENCODING_BZIP2;
113  #endif
114 -#ifdef USE_ZLIB
115 -                               srv_encodings |= HTTP_ACCEPT_ENCODING_GZIP;
116 -                               srv_encodings |= HTTP_ACCEPT_ENCODING_DEFLATE;
117 +#ifdef USE_BZ2LIB
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.103967 seconds and 4 git commands to generate.