[httpd] Allow caller of httpd_send_reply to avoid gzipping

This commit is contained in:
ejurgensen
2016-10-17 14:18:13 +02:00
parent d8696e72ea
commit 249d923af2
5 changed files with 32 additions and 26 deletions

View File

@@ -757,7 +757,7 @@ httpd_stream_file(struct evhttp_request *req, int id)
/* Thread: httpd */
void
httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *evbuf)
httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *evbuf, enum httpd_send_flags flags)
{
struct evbuffer *gzbuf;
struct evkeyvalq *input_headers;
@@ -772,7 +772,8 @@ httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struc
input_headers = evhttp_request_get_input_headers(req);
output_headers = evhttp_request_get_output_headers(req);
do_gzip = ( evbuf && (evbuffer_get_length(evbuf) > 512) &&
do_gzip = ( (!(flags & HTTPD_SEND_NO_GZIP)) &&
evbuf && (evbuffer_get_length(evbuf) > 512) &&
(param = evhttp_find_header(input_headers, "Accept-Encoding")) &&
(strstr(param, "gzip") || strstr(param, "*"))
);