summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/http.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-11-10 08:43:40 +0000
committerdes <des@FreeBSD.org>2000-11-10 08:43:40 +0000
commit985bff769942e74d8a4614115b7153a96bf6d0b6 (patch)
treeda8eae065a0f12e6489dde4d5fef45d7a0b7ac3d /lib/libfetch/http.c
parentfaf86e96f0a2a44d87ffbce68497bf4426dcc3af (diff)
downloadFreeBSD-src-985bff769942e74d8a4614115b7153a96bf6d0b6.zip
FreeBSD-src-985bff769942e74d8a4614115b7153a96bf6d0b6.tar.gz
Use the documented (and historical) defaults. Centralize the decision logic
in order to avoid this bug in the future. Submitted by: se
Diffstat (limited to 'lib/libfetch/http.c')
-rw-r--r--lib/libfetch/http.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index e8d193b..9c4bebb 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -609,23 +609,6 @@ _http_authorize(int fd, char *hdr, char *p)
*/
/*
- * Return the default port for this scheme
- */
-static int
-_http_default_port(char *scheme)
-{
- struct servent *se;
-
- if ((se = getservbyname(scheme, "tcp")) != NULL)
- return ntohs(se->s_port);
- if (strcasecmp(scheme, SCHEME_FTP) == 0)
- return FTP_DEFAULT_PORT;
- if (strcasecmp(scheme, SCHEME_HTTP) == 0)
- return HTTP_DEFAULT_PORT;
- return 0;
-}
-
-/*
* Connect to the correct HTTP server or proxy.
*/
static int
@@ -672,7 +655,7 @@ _http_get_proxy()
if (!*purl->scheme)
strcpy(purl->scheme, SCHEME_HTTP);
if (!purl->port)
- purl->port = _http_default_port(SCHEME_HTTP);
+ purl->port = _fetch_default_proxy_port(purl->scheme);
if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
return purl;
fetchFreeURL(purl);
@@ -733,7 +716,7 @@ _http_request(struct url *URL, char *op, struct url_stat *us,
retry:
/* check port */
if (!url->port)
- url->port = _http_default_port(url->scheme);
+ url->port = _fetch_default_port(url->scheme);
/* connect to server or proxy */
if ((fd = _http_connect(url, purl, flags)) == -1)
@@ -781,7 +764,7 @@ _http_request(struct url *URL, char *op, struct url_stat *us,
}
/* other headers */
- if (url->port == _http_default_port(url->scheme))
+ if (url->port == _fetch_default_port(url->scheme))
_http_cmd(fd, "Host: %s", host);
else
_http_cmd(fd, "Host: %s:%d", host, url->port);
OpenPOWER on IntegriCloud