From 72416e32583e4cedbafaf440043b7f2a7025441e Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 18 Apr 2015 13:49:14 +0200 Subject: [PATCH] do not add port number to "Host" header if it was not explicitly passed --- src/http.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/http.c b/src/http.c index 2592c28d..5f3b94b2 100644 --- a/src/http.c +++ b/src/http.c @@ -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);