Skip to content

Commit 079a5eb

Browse files
committed
Exclude port from Host: header if port is 80.
1 parent b21fb35 commit 079a5eb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

easywsclient.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,12 @@ easywsclient::WebSocket::pointer from_url(/service/std::string url, bool useMask) {
398398
int status;
399399
int i;
400400
snprintf(line, 256, "GET /%s HTTP/1.1\r\n", path); ::send(sockfd, line, strlen(line), 0);
401-
snprintf(line, 256, "Host: %s:%d\r\n", host, port); ::send(sockfd, line, strlen(line), 0);
401+
if (port == 80) {
402+
snprintf(line, 256, "Host: %s\r\n", host); ::send(sockfd, line, strlen(line), 0);
403+
}
404+
else {
405+
snprintf(line, 256, "Host: %s:%d\r\n", host, port); ::send(sockfd, line, strlen(line), 0);
406+
}
402407
snprintf(line, 256, "Upgrade: websocket\r\n"); ::send(sockfd, line, strlen(line), 0);
403408
snprintf(line, 256, "Connection: Upgrade\r\n"); ::send(sockfd, line, strlen(line), 0);
404409
snprintf(line, 256, "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==\r\n"); ::send(sockfd, line, strlen(line), 0);

0 commit comments

Comments
 (0)