Skip to content

Commit

Permalink
Fix #286 - http response headers overwritten with request headers
Browse files Browse the repository at this point in the history
  • Loading branch information
glenne committed Aug 25, 2023
1 parent a701963 commit 9f3944c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
6 changes: 1 addition & 5 deletions ixwebsocket/IXHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ namespace ix
content = gzipCompress(content);
headers["Content-Encoding"] = "gzip";
}
headers["Accept-Encoding"] = "gzip";
#endif

// Log request
Expand All @@ -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<HttpResponse>(
200, "OK", HttpErrorCode::Ok, headers, content);
});
Expand Down
1 change: 1 addition & 0 deletions test/IXHttpServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 9f3944c

Please sign in to comment.