Skip to content

Commit 28832f8

Browse files
authored
Fix #286 - http response headers overwritten with request headers (#483)
1 parent 0dd2842 commit 28832f8

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

ixwebsocket/IXHttpServer.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ namespace ix
148148
content = gzipCompress(content);
149149
headers["Content-Encoding"] = "gzip";
150150
}
151+
headers["Accept-Encoding"] = "gzip";
151152
#endif
152153

153154
// Log request
@@ -161,11 +162,6 @@ namespace ix
161162
// headers["Content-Type"] = "application/octet-stream";
162163
headers["Accept-Ranges"] = "none";
163164

164-
for (auto&& it : request->headers)
165-
{
166-
headers[it.first] = it.second;
167-
}
168-
169165
return std::make_shared<HttpResponse>(
170166
200, "OK", HttpErrorCode::Ok, headers, content);
171167
});

test/IXHttpServerTest.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ TEST_CASE("http server", "[httpd]")
6060
REQUIRE(response->errorCode == HttpErrorCode::Ok);
6161
REQUIRE(response->statusCode == 200);
6262
REQUIRE(response->headers["Accept-Encoding"] == "gzip");
63+
REQUIRE(response->headers["Content-Encoding"] == "gzip");
6364

6465
server.stop();
6566
}

0 commit comments

Comments
 (0)