@@ -361,6 +361,7 @@ namespace SimpleWeb {
361361
362362 std::string host;
363363 unsigned short port;
364+ unsigned short default_port;
364365
365366 std::unique_ptr<asio::ip::tcp::resolver::query> query;
366367
@@ -372,7 +373,7 @@ namespace SimpleWeb {
372373 std::size_t concurrent_synchronous_requests = 0 ;
373374 std::mutex concurrent_synchronous_requests_mutex;
374375
375- ClientBase (const std::string &host_port, unsigned short default_port) noexcept : handler_runner(new ScopeRunner()) {
376+ ClientBase (const std::string &host_port, unsigned short default_port) noexcept : default_port(default_port), handler_runner(new ScopeRunner()) {
376377 auto parsed_host_port = parse_host_port (host_port, default_port);
377378 host = parsed_host_port.first ;
378379 port = parsed_host_port.second ;
@@ -425,7 +426,10 @@ namespace SimpleWeb {
425426 std::unique_ptr<asio::streambuf> streambuf (new asio::streambuf ());
426427 std::ostream write_stream (streambuf.get ());
427428 write_stream << method << " " << corrected_path << " HTTP/1.1\r\n " ;
428- write_stream << " Host: " << host << " :" << std::to_string (port) << " \r\n " ;
429+ write_stream << " Host: " << host;
430+ if (port != default_port)
431+ write_stream << ' :' << std::to_string (port);
432+ write_stream << " \r\n " ;
429433 for (auto &h : header)
430434 write_stream << h.first << " : " << h.second << " \r\n " ;
431435 return streambuf;
0 commit comments