diff options
author | Timotej S <6674623+underhood@users.noreply.github.com> | 2020-09-10 13:48:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 13:48:06 +0200 |
commit | 54916258aa5b687766b8bcf7bb5a058fada3f855 (patch) | |
tree | aaf2f79845ff22b48486d6b6a37f962324b02239 /web | |
parent | c1698e87f058c770f087888aba224fbdd018026a (diff) |
Implements ACLK v2 http message with compression (#9895)
Allows cloud to use v2 queries which support compression.
Diffstat (limited to 'web')
-rw-r--r-- | web/server/web_client.c | 13 | ||||
-rw-r--r-- | web/server/web_client.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/web/server/web_client.c b/web/server/web_client.c index e60d0a94e2..88030352b6 100644 --- a/web/server/web_client.c +++ b/web/server/web_client.c @@ -199,6 +199,7 @@ void web_client_request_done(struct web_client *w) { w->response.zstream.total_in = 0; w->response.zstream.total_out = 0; w->response.zinitialized = 0; + w->flags &= ~WEB_CLIENT_CHUNKED_TRANSFER; } #endif // NETDATA_WITH_ZLIB } @@ -501,6 +502,7 @@ void web_client_enable_deflate(struct web_client *w, int gzip) { w->response.zsent = 0; w->response.zoutput = 1; w->response.zinitialized = 1; + w->flags |= WEB_CLIENT_CHUNKED_TRANSFER; debug(D_DEFLATE, "%llu: Initialized compression.", w->id); } @@ -1238,12 +1240,11 @@ void web_client_build_http_header(struct web_client *w) { buffer_strcat(w->response.header_output, buffer_tostring(w->response.header)); // headers related to the transfer method - if(likely(w->response.zoutput)) { - buffer_strcat(w->response.header_output, - "Content-Encoding: gzip\r\n" - "Transfer-Encoding: chunked\r\n" - ); - } + if(likely(w->response.zoutput)) + buffer_strcat(w->response.header_output, "Content-Encoding: gzip\r\n"); + + if(likely(w->flags & WEB_CLIENT_CHUNKED_TRANSFER)) + buffer_strcat(w->response.header_output, "Transfer-Encoding: chunked\r\n"); else { if(likely((w->response.data->len || w->response.rlen))) { // we know the content length, put it diff --git a/web/server/web_client.h b/web/server/web_client.h index a8595853bf..48bf1ac862 100644 --- a/web/server/web_client.h +++ b/web/server/web_client.h @@ -64,6 +64,8 @@ typedef enum web_client_flags { WEB_CLIENT_FLAG_UNIX_CLIENT = 1 << 8, // if set, the client is using a UNIX socket WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET = 1 << 9, // don't close the socket when cleaning up (static-threaded web server) + + WEB_CLIENT_CHUNKED_TRANSFER = 1 << 10, // chunked transfer (used with zlib compression) } WEB_CLIENT_FLAGS; //#ifdef HAVE_C___ATOMIC |