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);