From ed00704566080327ea2b41e2a99fa5d88b0b533b Mon Sep 17 00:00:00 2001 From: Alexander Bruines Date: Mon, 15 Oct 2018 05:05:39 +0800 Subject: [PATCH] lws_serve_http_file: skip adding cache control if h1 other_headers do it --- lib/roles/http/server/server.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index bbd16b94b..74b74f040 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -2195,9 +2195,14 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type, } } - if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CACHE_CONTROL, - (unsigned char *)cc, cclen, &p, end)) - return -1; + /* Only add cache control if its not specified by any other_headers. */ + if (!other_headers || + (!strstr(other_headers, "cache-control") && + !strstr(other_headers, "Cache-Control"))) { + if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CACHE_CONTROL, + (unsigned char *)cc, cclen, &p, end)) + return -1; + } if (other_headers) { if ((end - p) < other_headers_len)