diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2024-04-13 14:04:18 +0200 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2024-04-13 14:04:18 +0200 |
commit | bd4992435ca8343cca0b34af13cf6da331a357f8 (patch) | |
tree | 73889845ee88f968ce14332fcfd9043d2c736a4b /ot_http.c | |
parent | 35f55290f3832740535c7b419e494b8b7266804d (diff) |
Add proper parsing for the gzip content encoding
Diffstat (limited to 'ot_http.c')
-rw-r--r-- | ot_http.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -162,7 +162,7 @@ fprintf(stderr, "http_sendiovecdata sending %d iovec entries found cookie->batch | |||
162 | header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n%sContent-Length: %zd\r\n\r\n", encoding, size ); | 162 | header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n%sContent-Length: %zd\r\n\r\n", encoding, size ); |
163 | else { | 163 | else { |
164 | if ( !(cookie->flag & STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER )) { | 164 | if ( !(cookie->flag & STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER )) { |
165 | header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n%sTransfer-Encoding: chunked\r\n\r\n%zx\r\n", encoding, size ); | 165 | header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: application/octet-stream\r\n%sTransfer-Encoding: chunked\r\n\r\n%zx\r\n", encoding, size ); |
166 | cookie->flag |= STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; | 166 | cookie->flag |= STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; |
167 | } else | 167 | } else |
168 | header_size = sprintf( header, "%zx\r\n", size ); | 168 | header_size = sprintf( header, "%zx\r\n", size ); |
@@ -269,12 +269,12 @@ static const ot_keywords keywords_format[] = | |||
269 | tai6464 t; | 269 | tai6464 t; |
270 | #ifdef WANT_COMPRESSION_GZIP | 270 | #ifdef WANT_COMPRESSION_GZIP |
271 | ws->request[ws->request_size] = 0; | 271 | ws->request[ws->request_size] = 0; |
272 | #ifdef WANT_COMPRESSION_GZIP_ALWAYS | 272 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS |
273 | if( strstr( read_ptr - 1, "gzip" ) ) { | 273 | if( strstr( read_ptr - 1, "gzip" ) ) { |
274 | #endif | 274 | #endif |
275 | cookie->flag |= STRUCT_HTTP_FLAG_GZIP; | 275 | cookie->flag |= STRUCT_HTTP_FLAG_GZIP; |
276 | format |= TASK_FLAG_GZIP; | 276 | format |= TASK_FLAG_GZIP; |
277 | #ifdef WANT_COMPRESSION_GZIP_ALWAYS | 277 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS |
278 | } | 278 | } |
279 | #endif | 279 | #endif |
280 | #endif | 280 | #endif |
@@ -337,12 +337,16 @@ static ssize_t http_handle_fullscrape( const int64 sock, struct ot_workstruct *w | |||
337 | 337 | ||
338 | #ifdef WANT_COMPRESSION_GZIP | 338 | #ifdef WANT_COMPRESSION_GZIP |
339 | ws->request[ws->request_size-1] = 0; | 339 | ws->request[ws->request_size-1] = 0; |
340 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS | ||
340 | if( strstr( ws->request, "gzip" ) ) { | 341 | if( strstr( ws->request, "gzip" ) ) { |
342 | #endif | ||
341 | cookie->flag |= STRUCT_HTTP_FLAG_GZIP; | 343 | cookie->flag |= STRUCT_HTTP_FLAG_GZIP; |
342 | format = TASK_FLAG_GZIP; | 344 | format = TASK_FLAG_GZIP; |
343 | stats_issue_event( EVENT_FULLSCRAPE_REQUEST_GZIP, 0, (uintptr_t)cookie->ip ); | 345 | stats_issue_event( EVENT_FULLSCRAPE_REQUEST_GZIP, 0, (uintptr_t)cookie->ip ); |
346 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS | ||
344 | } else | 347 | } else |
345 | #endif | 348 | #endif |
349 | #endif | ||
346 | stats_issue_event( EVENT_FULLSCRAPE_REQUEST, 0, (uintptr_t)cookie->ip ); | 350 | stats_issue_event( EVENT_FULLSCRAPE_REQUEST, 0, (uintptr_t)cookie->ip ); |
347 | 351 | ||
348 | #ifdef _DEBUG_HTTPERROR | 352 | #ifdef _DEBUG_HTTPERROR |