http client: stop hardcoding Accept header, and use a default value if one is passed in 👭
This commit is contained in:
parent
1e2a5ee21d
commit
6b933391e5
@ -74,7 +74,6 @@ namespace ix
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << verb << " " << path << " HTTP/1.1\r\n";
|
ss << verb << " " << path << " HTTP/1.1\r\n";
|
||||||
ss << "Host: " << host << "\r\n";
|
ss << "Host: " << host << "\r\n";
|
||||||
ss << "Accept: */*" << "\r\n";
|
|
||||||
|
|
||||||
if (args.compress)
|
if (args.compress)
|
||||||
{
|
{
|
||||||
@ -87,6 +86,18 @@ namespace ix
|
|||||||
ss << it.first << ": " << it.second << "\r\n";
|
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)
|
if (verb == kPost)
|
||||||
{
|
{
|
||||||
ss << "Content-Length: " << body.size() << "\r\n";
|
ss << "Content-Length: " << body.size() << "\r\n";
|
||||||
|
@ -64,7 +64,7 @@ TEST_CASE("http client", "[http]")
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(IXWEBSOCKET_USE_TLS)
|
#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/");
|
std::string url("https://httpbin.org/");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user