do not add port number to "Host" header if it was not explicitly passed

This commit is contained in:
chme 2015-04-18 13:49:14 +02:00
parent 76a638a277
commit 72416e3258

View File

@ -186,6 +186,11 @@ http_client_request(struct http_client_ctx *ctx)
return ctx->ret;
}
if (port <= 0)
snprintf(s, PATH_MAX, "%s", hostname);
else
snprintf(s, PATH_MAX, "%s:%d", hostname, port);
if (port <= 0)
port = 80;
@ -231,7 +236,6 @@ http_client_request(struct http_client_ctx *ctx)
#endif
headers = evhttp_request_get_output_headers(req);
snprintf(s, PATH_MAX, "%s:%d", hostname, port);
evhttp_add_header(headers, "Host", s);
evhttp_add_header(headers, "Content-Length", "0");
evhttp_add_header(headers, "User-Agent", "forked-daapd/" VERSION);