uclient-http: send correct "Host:" header if port is set
authorAlexander Couzens <lynxis@fe80.eu>
Wed, 30 Nov 2016 17:49:10 +0000 (18:49 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 30 Nov 2016 18:42:31 +0000 (19:42 +0100)
When connecting to a website with a special port, uclient-fetch connects
to the correct port, but is sending an incorrect Host: header without
the corresponding port.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
uclient-http.c

index 899f367c616a35a10b37ff73f403063dad0c6b0f..8d26bd4884be11d06b8c7913ad31f159eaa60c3a 100644 (file)
@@ -569,9 +569,11 @@ uclient_http_send_headers(struct uclient_http *uh)
 
        ustream_printf(uh->us,
                "%s %s HTTP/1.1\r\n"
-               "Host: %s\r\n",
+               "Host: %s%s%s\r\n",
                request_types[req_type],
-               url->location, url->host);
+               url->location, url->host,
+               url->port ? ":" : "",
+               url->port ? url->port : "");
 
        blobmsg_for_each_attr(cur, uh->headers.head, rem)
                ustream_printf(uh->us, "%s: %s\r\n", blobmsg_name(cur), (char *) blobmsg_data(cur));