http client: stop hardcoding Accept header, and use a default value if one is passed in 👭
This commit is contained in:
parent
a187e69650
commit
6a41b7389f
@ -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";
|
||||
|
@ -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/");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user