disabled deflate - only gzip is supported
Costa Tsaousis (ktsaou) committed
May 21, 2016 at 18:12 UTC
99b045f7f7ddd0812834d0408206970e817aafb6
1 file changed
+9
-10
src/web_client.c
+9
-10
@@ -192,7 +192,6 @@ void web_client_reset(struct web_client *w)
192
w->origin[1] = '\0';
193
194
w->mode = WEB_CLIENT_MODE_NORMAL;
195
- w->enable_gzip = 0;
195
w->keepalive = 0;
196
w->decoded_url[0] = '\0';
197
@@ -425,7 +424,7 @@ int mysendfile(struct web_client *w, char *filename)
424
425
426
#ifdef NETDATA_WITH_ZLIB
428
-void web_client_enable_deflate(struct web_client *w) {
427
+void web_client_enable_deflate(struct web_client *w, int gzip) {
428
if(w->response.zinitialized == 1) {
429
error("%llu: Compression has already be initialized for this client.", w->id);
430
return;
@@ -458,7 +457,7 @@ void web_client_enable_deflate(struct web_client *w) {
457
// }
458
459
// Select GZIP compression: windowbits = 15 + 16 = 31
461
- if(deflateInit2(&w->response.zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
460
+ if(deflateInit2(&w->response.zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + ((gzip)?16:0), 8, Z_DEFAULT_STRATEGY) != Z_OK) {
461
error("%llu: Failed to initialize zlib. Proceeding without compression.", w->id);
462
return;
463
}
@@ -1229,8 +1228,13 @@ static inline char *http_header_parse(struct web_client *w, char *s) {
1228
}
1229
#ifdef NETDATA_WITH_ZLIB
1230
else if(!strcasecmp(s, "Accept-Encoding")) {
1232
- if(web_enable_gzip && (strcasestr(v, "gzip") || strcasestr(v, "deflate"))) {
1233
- w->enable_gzip = 1;
1231
+ if(web_enable_gzip) {
1232
+ if(strcasestr(v, "gzip"))
1233
+ web_client_enable_deflate(w, 1);
1234
+ //
1235
+ // does not seem to work
1236
+ // else if(strcasestr(v, "deflate"))
1237
+ // web_client_enable_deflate(w, 0);
1238
}
1239
}
1240
#endif /* NETDATA_WITH_ZLIB */
@@ -1361,11 +1365,6 @@ void web_client_process(struct web_client *w) {
1365
buffer_strcat(w->response.data, "OK");
1366
}
1367
else {
1364
-#ifdef NETDATA_WITH_ZLIB
1365
- if(w->enable_gzip)
1366
- web_client_enable_deflate(w);
1367
-#endif
1368
-
1368
char *url = w->decoded_url;
1369
char *tok = mystrsep(&url, "/?");
1370
if(tok && *tok) {