From e11dcaad414d0259b4bd8dcdd6edeed662ce5f06 Mon Sep 17 00:00:00 2001 From: lnmx Date: Sat, 12 Aug 2017 20:53:58 +0800 Subject: [PATCH] send content-type when LWS_WITH_RANGES=OFF https://github.com/warmcat/libwebsockets/pull/987 With the RANGES feature disabled, lws_serve_http_file would not add the content-type header to the response. --- lib/server.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/server.c b/lib/server.c index bed3d27..16e3808 100644 --- a/lib/server.c +++ b/lib/server.c @@ -2619,13 +2619,17 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type, lwsl_info("file is being provided in gzip\n"); } + if ( #if defined(LWS_WITH_RANGES) - if (ranges < 2 && content_type && content_type[0]) + ranges < 2 && +#endif + content_type && content_type[0]) if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE, (unsigned char *)content_type, strlen(content_type), &p, end)) return -1; +#if defined(LWS_WITH_RANGES) if (ranges >= 2) { /* multipart byteranges */ strncpy(wsi->u.http.multipart_content_type, content_type, sizeof(wsi->u.http.multipart_content_type) - 1); -- 2.7.4