summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libfetch/fetch.319
-rw-r--r--lib/libfetch/fetch.c11
-rw-r--r--lib/libfetch/fetch.h1
-rw-r--r--lib/libfetch/ftp.c2
4 files changed, 11 insertions, 22 deletions
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 7dbaa0a764f5..9c21fcd9b60b 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -422,9 +422,9 @@ and message, e.g. "File is not available (404 Not Found)"
.Sh ENVIRONMENT
.Bl -tag -width FTP_PASSIVE_MODE
.It Ev FTP_PASSIVE_MODE
-The FTP code selects passive mode by default.
-To force active mode FTP, set this variable to
-.Ql no .
+If set to anything but
+.Ql no ,
+forces the FTP code to use passive mode.
.It Ev FTP_PASSWORD
Default FTP password if the remote server requests one and none was
provided in the URL.
@@ -549,17 +549,8 @@ or
environment variables as appropriate.
.Pp
.Nm libfetch
-does not attempt to interpret and respond to authentication requests
-from the HTTP server or proxy (code 401 and 407 respectively).
-.Pp
-.Nm libfetch
does not understand or obey 305 (Use Proxy) replies.
.Pp
-No attempt is made to encode spaces etc. within URLs.
-Spaces in the
-document part of an URLshould be replaced with "%20" in HTTP URLs and
-"\\ " in FTP URLs.
-.Pp
Error numbers are unique only within a certain context; the error
codes used for FTP and HTTP overlap, as do those used for resolver and
system errors.
@@ -570,13 +561,9 @@ implemented, superfluous at this site" in an FTP context and
.Fn fetchStatFTP
does not check that the result of an MDTM command is a valid date.
.Pp
-The HTTP code needs a complete rewrite, or at least a serious cleanup.
-.Pp
The man page is incomplete, poorly written and produces badly
formatted text.
.Pp
The error reporting mechanism is unsatisfactory.
.Pp
Some parts of the code are not fully reentrant.
-.Pp
-Tons of other stuff.
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 46da7ce15510..b26cad08a59b 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -294,7 +294,7 @@ fetchMakeURL(char *scheme, char *host, int port, char *doc,
struct url *
fetchParseURL(char *URL)
{
- char *p, *q;
+ char *doc, *p, *q;
struct url *u;
int i;
@@ -367,15 +367,16 @@ nohost:
if (!*p)
p = "/";
- if (strcmp(u->scheme, "http") == 0 || strcmp(u->scheme, "https") == 0) {
+ if (strcasecmp(u->scheme, SCHEME_HTTP) == 0 ||
+ strcasecmp(u->scheme, SCHEME_HTTPS) == 0) {
const char hexnums[] = "0123456789abcdef";
- char *doc;
- /* Perform %hh encoding of white space. */
- if ((doc = u->doc = malloc(strlen(p) * 3 + 1)) == NULL) {
+ /* percent-escape whitespace. */
+ if ((doc = malloc(strlen(p) * 3 + 1)) == NULL) {
_fetch_syserr();
goto ouch;
}
+ u->doc = doc;
while (*p != '\0') {
if (!isspace(*p)) {
*doc++ = *p++;
diff --git a/lib/libfetch/fetch.h b/lib/libfetch/fetch.h
index aedd472cb1a8..bc944c8b9931 100644
--- a/lib/libfetch/fetch.h
+++ b/lib/libfetch/fetch.h
@@ -62,6 +62,7 @@ struct url_ent {
/* Recognized schemes */
#define SCHEME_FTP "ftp"
#define SCHEME_HTTP "http"
+#define SCHEME_HTTPS "https"
#define SCHEME_FILE "file"
/* Error codes */
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index d9f624ef4852..59d71908d29e 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -464,7 +464,7 @@ _ftp_transfer(int cd, char *oper, char *file,
/* passive mode */
if (!pasv)
- pasv = ((s = getenv("FTP_PASSIVE_MODE")) == NULL ||
+ pasv = ((s = getenv("FTP_PASSIVE_MODE")) != NULL &&
strncasecmp(s, "no", 2) != 0);
/* find our own address, bind, and listen */