diff options
author | 2009-06-13 20:01:10 +0000 | |
---|---|---|
committer | 2009-06-13 20:01:10 +0000 | |
commit | 38fe73969a9d196700507875b2a78fcc3eff8fb6 (patch) | |
tree | 9c26e7861415d85b6ff96fb75b95bcb33bdf9225 | |
parent | tcpdrop broke with the addition of routing domains. Repair. (diff) | |
download | wireguard-openbsd-38fe73969a9d196700507875b2a78fcc3eff8fb6.tar.xz wireguard-openbsd-38fe73969a9d196700507875b2a78fcc3eff8fb6.zip |
- stat is not fatal, since we want resume not to fail for non-existent
file transfers in all cases
- do it a bit earlier and use HTTP/1.0 if we won't send the range header
- change resume -> restart_point where it is intended
ok halex@, millert@
-rw-r--r-- | usr.bin/ftp/fetch.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index a8000fbad87..d6c3c69a26f 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.89 2009/06/04 23:37:09 halex Exp $ */ +/* $OpenBSD: fetch.c,v 1.90 2009/06/13 20:01:10 martynas Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -491,9 +491,19 @@ again: path, buf ? buf : "", HTTP_USER_AGENT); } else { +#ifndef SMALL + if (resume) { + struct stat stbuf; + + if (stat(savefile, &stbuf) == 0) + restart_point = stbuf.st_size; + else + restart_point = 0; + } +#endif /* !SMALL */ ftp_printf(fin, ssl, "GET /%s %s\r\nHost: ", path, #ifndef SMALL - resume ? "HTTP/1.1" : + restart_point ? "HTTP/1.1" : #endif /* !SMALL */ "HTTP/1.0"); if (strchr(host, ':')) { @@ -521,21 +531,9 @@ again: #ifndef SMALL if (port && strcmp(port, (ishttpsurl ? "443" : "80")) != 0) ftp_printf(fin, ssl, ":%s", port); - if (resume) { - int ret; - struct stat stbuf; - - ret = stat(savefile, &stbuf); - if (ret < 0) { - if (verbose) - fprintf(ttyout, "\n"); - warn("Can't open %s", savefile); - goto cleanup_url_get; - } - restart_point = stbuf.st_size; + if (restart_point) ftp_printf(fin, ssl, "\r\nRange: bytes=%lld-", (long long)restart_point); - } #else /* !SMALL */ if (port && strcmp(port, "80") != 0) ftp_printf(fin, ssl, ":%s", port); @@ -637,7 +635,7 @@ again: if (errstr != NULL) goto improper; #ifndef SMALL - if (resume) + if (restart_point) filesize += restart_point; #endif /* !SMALL */ #define LOCATION "Location: " |