Skip to content

Commit bd089e9

Browse files
committed
Fixed #18
1 parent df94286 commit bd089e9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

httplib.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class Client {
177177

178178
const std::string host_;
179179
const int port_;
180+
const std::string host_and_port_;
180181

181182
private:
182183
bool read_response_line(Stream& strm, Response& res);
@@ -1035,6 +1036,7 @@ inline bool Server::read_and_close_socket(socket_t sock)
10351036
inline Client::Client(const char* host, int port)
10361037
: host_(host)
10371038
, port_(port)
1039+
, host_and_port_(host_ + ":" + std::to_string(port_))
10381040
{
10391041
}
10401042

@@ -1098,7 +1100,7 @@ inline bool Client::read_and_close_socket(socket_t sock, const Request& req, Res
10981100

10991101
inline void Client::add_default_headers(Request& req)
11001102
{
1101-
req.set_header("Host", host_.c_str());
1103+
req.set_header("Host", host_and_port_.c_str());
11021104
req.set_header("Accept", "*/*");
11031105
req.set_header("User-Agent", "cpp-httplib/0.1");
11041106
}

0 commit comments

Comments
 (0)