summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2022-01-05 11:07:51 +0100
committerThierry Vignaud <thierry.vignaud@gmail.com>2022-01-05 11:07:51 +0100
commitf1548fa15e6a86bdb903d6645750bd850517b10f (patch)
treeba7b59fc52d5638e95ee527b7aae80101f52ee57
parentd8b6cd51b142f45de1f69c571bbf47cd31bf3770 (diff)
downloaddrakx-f1548fa15e6a86bdb903d6645750bd850517b10f.tar
drakx-f1548fa15e6a86bdb903d6645750bd850517b10f.tar.gz
drakx-f1548fa15e6a86bdb903d6645750bd850517b10f.tar.bz2
drakx-f1548fa15e6a86bdb903d6645750bd850517b10f.tar.xz
drakx-f1548fa15e6a86bdb903d6645750bd850517b10f.zip
allow to specify a different http port (mga#28367)
The default being the well know "80" port
-rw-r--r--mdk-stage1/NEWS2
-rw-r--r--mdk-stage1/url.c17
2 files changed, 16 insertions, 3 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS
index e8181198d..86d9c944a 100644
--- a/mdk-stage1/NEWS
+++ b/mdk-stage1/NEWS
@@ -1,3 +1,5 @@
+- http server: allow to specify a port different than default "80" (mga#28367)
+
2.56
- load exfat module to mount exfat (mga#28371)
diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c
index 3d2846649..14f1e25d6 100644
--- a/mdk-stage1/url.c
+++ b/mdk-stage1/url.c
@@ -398,9 +398,10 @@ char *str_ftp_error(int error)
}
-static int _http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion)
+static int _http_download_file(char * hostport, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion)
{
char * buf;
+ char * hostname = strdup(hostport);
char headers[4096];
char * nextChar = headers;
int statusCode;
@@ -418,8 +419,15 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c
http_server_name = proxyname;
http_server_port = atoi(proxyport);
} else {
- http_server_name = hostname;
- http_server_port = 80;
+ char *port = strchr(hostname, ':');
+ if (port) {
+ *port = '\0';
+ http_server_name = hostname;
+ http_server_port = atoi(++port);
+ } else {
+ http_server_name = hostname;
+ http_server_port = 80;
+ }
}
log_message("HTTP: connecting to server %s:%i (%s)",
@@ -430,6 +438,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (sock < 0) {
+ free(hostname);
return FTPERR_FAILED_CONNECT;
}
@@ -439,6 +448,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c
if (connect(sock, (struct sockaddr *) &destPort, sizeof(destPort))) {
close(sock);
+ free(hostname);
return FTPERR_FAILED_CONNECT;
}
@@ -446,6 +456,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c
: asprintf_("GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", remotename, hostname);
write(sock, buf, strlen(buf));
+ free(hostname);
/* This is fun; read the response a character at a time until we: