diff --git a/ixwebsocket/IXHttpClient.cpp b/ixwebsocket/IXHttpClient.cpp index 5a6b380b..0afeb9c6 100644 --- a/ixwebsocket/IXHttpClient.cpp +++ b/ixwebsocket/IXHttpClient.cpp @@ -74,7 +74,6 @@ namespace ix std::stringstream ss; ss << verb << " " << path << " HTTP/1.1\r\n"; ss << "Host: " << host << "\r\n"; - ss << "Accept: */*" << "\r\n"; if (args.compress) { @@ -87,6 +86,18 @@ namespace ix ss << it.first << ": " << it.second << "\r\n"; } + // Set a default Accept header if none is present + if (headers.find("Accept") == headers.end()) + { + ss << "Accept: */*" << "\r\n"; + } + + // Set a default User agent if none is present + if (headers.find("User-Agent") == headers.end()) + { + ss << "User-Agent: ixwebsocket" << "\r\n"; + } + if (verb == kPost) { ss << "Content-Length: " << body.size() << "\r\n"; diff --git a/test/IXHttpClientTest.cpp b/test/IXHttpClientTest.cpp index d3567677..4dde45a0 100644 --- a/test/IXHttpClientTest.cpp +++ b/test/IXHttpClientTest.cpp @@ -64,7 +64,7 @@ TEST_CASE("http client", "[http]") } #if defined(IXWEBSOCKET_USE_TLS) - SECTION("Connect to a remote HTTP server") + SECTION("Connect to a remote HTTPS server") { std::string url("https://httpbin.org/");