diff options
author | Jeremy Katz <katzj@redhat.com> | 2004-06-16 17:45:40 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2004-06-16 17:45:40 +0000 |
commit | e211050de1567c950cc6c01abe8d3cd3e5c0aad5 (patch) | |
tree | d7e6eef3710ca2e1bc95be1b5d084fe3df9633a7 /loader2/ftp.c | |
parent | 4d42471661be5f5851d6b749dce0ca0f391ee25b (diff) | |
download | anaconda-e211050de1567c950cc6c01abe8d3cd3e5c0aad5.tar.gz anaconda-e211050de1567c950cc6c01abe8d3cd3e5c0aad5.tar.xz anaconda-e211050de1567c950cc6c01abe8d3cd3e5c0aad5.zip |
add support for passing a port with your http host. patch from
otaylor (#126100)
Diffstat (limited to 'loader2/ftp.c')
-rw-r--r-- | loader2/ftp.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/loader2/ftp.c b/loader2/ftp.c index 0f0fa6d51..f3a8004ce 100644 --- a/loader2/ftp.c +++ b/loader2/ftp.c @@ -427,6 +427,7 @@ int httpGetFileDesc(char * hostname, int port, char * remotename, char *extraHea struct timeval timeout; char headers[4096]; char * nextChar = headers; + char *realhost; char *hstr; int checkedCode; struct in_addr serverAddress; @@ -435,9 +436,21 @@ int httpGetFileDesc(char * hostname, int port, char * remotename, char *extraHea struct sockaddr_in destPort; fd_set readSet; - if (port < 0) port = 80; + realhost = hostname; + if (port < 0) { + char *colonptr = strchr(hostname, ':'); + if (colonptr != NULL) { + int realhostlen = colonptr - hostname; + port = atoi(colonptr + 1); + realhost = alloca (realhostlen + 1); + memcpy (realhost, hostname, realhostlen); + realhost[realhostlen] = '\0'; + } else { + port = 80; + } + } - if ((rc = getHostAddress(hostname, &serverAddress))) return rc; + if ((rc = getHostAddress(realhost, &serverAddress))) return rc; sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sock < 0) { @@ -458,8 +471,8 @@ int httpGetFileDesc(char * hostname, int port, char * remotename, char *extraHea else hstr = ""; - buf = alloca(strlen(remotename) + strlen(hostname) + strlen(hstr) + 25); - sprintf(buf, "GET %s HTTP/1.0\r\nHost: %s\r\n%s\r\n", remotename, hostname, hstr); + buf = alloca(strlen(remotename) + strlen(realhost) + strlen(hstr) + 25); + sprintf(buf, "GET %s HTTP/1.0\r\nHost: %s\r\n%s\r\n", remotename, realhost, hstr); write(sock, buf, strlen(buf)); /* This is fun; read the response a character at a time until we: |