summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/ftp.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-07-25 11:45:38 +0000
committerdes <des@FreeBSD.org>2000-07-25 11:45:38 +0000
commit2de7b8d72b9f8324bd4e07219ca1dc1689ba4614 (patch)
tree11d2f391d90ea74c6b5e72fd1d769d97edc3e6ee /lib/libfetch/ftp.c
parent64de57e4e28f41b53af571e2f918c940e2286097 (diff)
downloadFreeBSD-src-2de7b8d72b9f8324bd4e07219ca1dc1689ba4614.zip
FreeBSD-src-2de7b8d72b9f8324bd4e07219ca1dc1689ba4614.tar.gz
Centralize the default port finding code.
Work around YA Apache bug: don't send port in Host: header if it's the default port.
Diffstat (limited to 'lib/libfetch/ftp.c')
-rw-r--r--lib/libfetch/ftp.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index a5eb1d3..8e38beb 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -75,7 +75,6 @@
#define FTP_ANONYMOUS_USER "ftp"
#define FTP_ANONYMOUS_PASSWORD "ftp"
-#define FTP_DEFAULT_PORT 21
#define FTP_OPEN_DATA_CONNECTION 150
#define FTP_OK 200
@@ -570,6 +569,19 @@ ouch:
}
/*
+ * Return default port
+ */
+static int
+_ftp_default_port(void)
+{
+ struct servent *se;
+
+ if ((se = getservbyname("ftp", "tcp")) != NULL)
+ return ntohs(se->s_port);
+ return FTP_DEFAULT_PORT;
+}
+
+/*
* Log on to FTP server
*/
static int
@@ -611,14 +623,8 @@ _ftp_connect(char *host, int port, char *user, char *pwd, char *flags)
/* XXX we should emit some kind of warning */
}
}
- if (!pp) {
- struct servent *se;
-
- if ((se = getservbyname("ftp", "tcp")) != NULL)
- pp = ntohs(se->s_port);
- else
- pp = FTP_DEFAULT_PORT;
- }
+ if (!pp)
+ pp = _ftp_default_port();
if (q) {
#ifdef INET6
if (q > p && *p == '[' && *(q - 1) == ']') {
@@ -732,14 +738,8 @@ _ftp_cached_connect(struct url *url, char *flags)
cd = -1;
/* set default port */
- if (!url->port) {
- struct servent *se;
-
- if ((se = getservbyname("ftp", "tcp")) != NULL)
- url->port = ntohs(se->s_port);
- else
- url->port = FTP_DEFAULT_PORT;
- }
+ if (!url->port)
+ url->port = _ftp_default_port();
/* try to use previously cached connection */
if (_ftp_isconnected(url)) {
OpenPOWER on IntegriCloud