From 28832f8732e544cd683bd2f0b5d11f536a7fbaf5 Mon Sep 17 00:00:00 2001 From: Glenn Engel Date: Fri, 1 Sep 2023 08:11:07 -0700 Subject: [PATCH] Fix #286 - http response headers overwritten with request headers (#483) --- ixwebsocket/IXHttpServer.cpp | 6 +----- test/IXHttpServerTest.cpp | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ixwebsocket/IXHttpServer.cpp b/ixwebsocket/IXHttpServer.cpp index c5c5f84e..00456629 100644 --- a/ixwebsocket/IXHttpServer.cpp +++ b/ixwebsocket/IXHttpServer.cpp @@ -148,6 +148,7 @@ namespace ix content = gzipCompress(content); headers["Content-Encoding"] = "gzip"; } + headers["Accept-Encoding"] = "gzip"; #endif // Log request @@ -161,11 +162,6 @@ namespace ix // headers["Content-Type"] = "application/octet-stream"; headers["Accept-Ranges"] = "none"; - for (auto&& it : request->headers) - { - headers[it.first] = it.second; - } - return std::make_shared( 200, "OK", HttpErrorCode::Ok, headers, content); }); diff --git a/test/IXHttpServerTest.cpp b/test/IXHttpServerTest.cpp index e06f958c..924ba8f1 100644 --- a/test/IXHttpServerTest.cpp +++ b/test/IXHttpServerTest.cpp @@ -60,6 +60,7 @@ TEST_CASE("http server", "[httpd]") REQUIRE(response->errorCode == HttpErrorCode::Ok); REQUIRE(response->statusCode == 200); REQUIRE(response->headers["Accept-Encoding"] == "gzip"); + REQUIRE(response->headers["Content-Encoding"] == "gzip"); server.stop(); }