HTTP should contain port in 'Host' header (#427)

This commit is contained in:
Vol-Alex
2023-02-12 00:27:40 +01:00
committed by GitHub
parent 679ce519dd
commit 6cc21f3658
3 changed files with 44 additions and 16 deletions

View File

@ -139,8 +139,9 @@ namespace ix
std::string protocol, host, path, query;
int port;
bool isProtocolDefaultPort;
if (!UrlParser::parse(url, protocol, host, path, query, port))
if (!UrlParser::parse(url, protocol, host, path, query, port, isProtocolDefaultPort))
{
std::stringstream ss;
ss << "Cannot parse url: " << url;
@ -173,7 +174,12 @@ namespace ix
// Build request string
std::stringstream ss;
ss << verb << " " << path << " HTTP/1.1\r\n";
ss << "Host: " << host << "\r\n";
ss << "Host: " << host;
if (!isProtocolDefaultPort)
{
ss << ":" << port;
}
ss << "\r\n";
#ifdef IXWEBSOCKET_USE_ZLIB
if (args->compress && !args->onChunkCallback)