Don't include default port in upstream url to proxy

This commit is contained in:
ejose19 2023-06-16 20:30:06 -03:00
parent 2935519eb7
commit 79b52bd783
No known key found for this signature in database
GPG Key ID: 09BEDF7CC137762C

View File

@ -1464,8 +1464,15 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
return -1;
}
/*
* if(HTTPS on port 443) don't include the port number
*/
if (request->port == HTTP_PORT_SSL) {
snprintf (combined_string, len, "%s", request->host);
} else {
snprintf (combined_string, len, "%s:%d", request->host,
request->port);
}
} else {
len = strlen (request->host) + strlen (request->path) + 14;
combined_string = (char *) safemalloc (len);
@ -1473,9 +1480,17 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
return -1;
}
/*
* if(HTTP on port 80) don't include the port number
*/
if (request->port == HTTP_PORT) {
snprintf (combined_string, len, "http://%s%s", request->host,
request->path);
} else {
snprintf (combined_string, len, "http://%s:%d%s", request->host,
request->port, request->path);
}
}
if (request->path)
safefree (request->path);