version 1.207, 2021/11/09 12:14:35 |
version 1.208, 2021/11/10 07:32:55 |
|
|
int ishttpsurl = 0; |
int ishttpsurl = 0; |
#endif /* !NOSSL */ |
#endif /* !NOSSL */ |
#ifndef SMALL |
#ifndef SMALL |
char *eurl = NULL; |
|
char *full_host = NULL; |
char *full_host = NULL; |
const char *scheme; |
const char *scheme; |
char *locbase; |
char *locbase; |
|
|
struct stat stbuf; |
struct stat stbuf; |
struct tm lmt = { 0 }; |
struct tm lmt = { 0 }; |
struct timespec ts[2]; |
struct timespec ts[2]; |
#else |
|
char *eurl = NULL; |
|
#endif /* !SMALL */ |
#endif /* !SMALL */ |
struct tls *tls = NULL; |
struct tls *tls = NULL; |
int status; |
int status; |
|
|
#endif /* !NOSSL */ |
#endif /* !NOSSL */ |
|
|
epath = url_encode(path); |
epath = url_encode(path); |
#ifndef SMALL |
|
if (asprintf(&eurl, "%s%s%s%s/%s", |
|
scheme, |
|
full_host, |
|
portnum ? ":" : "", |
|
portnum ? portnum : "", |
|
epath) == -1) |
|
errx(1, "Cannot build encoded URL"); |
|
#endif |
|
if (proxyurl) { |
if (proxyurl) { |
#ifndef SMALL |
|
if (verbose) { |
if (verbose) { |
fprintf(ttyout, "Requesting %s (via %s)\n", |
fprintf(ttyout, "Requesting %s (via %s)\n", |
eurl, proxyurl); |
origline, proxyurl); |
} |
} |
#endif |
|
/* |
/* |
* Host: directive must use the destination host address for |
* Host: directive must use the destination host address for |
* the original URI (path). |
* the original URI (path). |
|
|
proxy_credentials); |
proxy_credentials); |
ftp_printf(fin, "\r\n"); |
ftp_printf(fin, "\r\n"); |
} else { |
} else { |
#ifndef SMALL |
|
if (verbose) |
if (verbose) |
fprintf(ttyout, "Requesting %s\n", eurl); |
fprintf(ttyout, "Requesting %s\n", origline); |
|
#ifndef SMALL |
if (resume || timestamp) { |
if (resume || timestamp) { |
if (stat(savefile, &stbuf) == 0) { |
if (stat(savefile, &stbuf) == 0) { |
if (resume) |
if (resume) |
|
|
status = strtonum(ststr, 200, 503, &errstr); |
status = strtonum(ststr, 200, 503, &errstr); |
if (errstr) { |
if (errstr) { |
strnvis(gerror, cp, sizeof gerror, VIS_SAFE); |
strnvis(gerror, cp, sizeof gerror, VIS_SAFE); |
#ifndef SMALL |
|
warnx("Error retrieving %s: %s", eurl, gerror); |
|
#else |
|
warnx("Error retrieving %s: %s", origline, gerror); |
warnx("Error retrieving %s: %s", origline, gerror); |
#endif |
|
goto cleanup_url_get; |
goto cleanup_url_get; |
} |
} |
|
|
|
|
break; |
break; |
default: |
default: |
strnvis(gerror, cp, sizeof gerror, VIS_SAFE); |
strnvis(gerror, cp, sizeof gerror, VIS_SAFE); |
#ifndef SMALL |
|
warnx("Error retrieving %s: %s", eurl, gerror); |
|
#else |
|
warnx("Error retrieving %s: %s", origline, gerror); |
warnx("Error retrieving %s: %s", origline, gerror); |
#endif |
|
goto cleanup_url_get; |
goto cleanup_url_get; |
} |
} |
|
|
|
|
if (isunavail) { |
if (isunavail) { |
if (retried || retryafter != 0) |
if (retried || retryafter != 0) |
warnx("Error retrieving %s: 503 Service Unavailable", |
warnx("Error retrieving %s: 503 Service Unavailable", |
#ifndef SMALL |
|
eurl); |
|
#else |
|
origline); |
origline); |
#endif |
|
else { |
else { |
if (verbose) |
if (verbose) |
fprintf(ttyout, "Retrying %s\n", origline); |
fprintf(ttyout, "Retrying %s\n", origline); |
|
|
|
|
cleanup_url_get: |
cleanup_url_get: |
#ifndef SMALL |
#ifndef SMALL |
free(eurl); |
|
free(full_host); |
free(full_host); |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
#ifndef NOSSL |
#ifndef NOSSL |