diff options
author | des <des@FreeBSD.org> | 2000-07-17 21:25:00 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2000-07-17 21:25:00 +0000 |
commit | 3033318809d10165bff918597656578a8dc16bd9 (patch) | |
tree | 00a4cf3f1c1814ebff20dc85906c41eb5d9c7ccb /lib/libfetch/http.c | |
parent | 9e42d615d8102289f59981b6332a387ed4c92781 (diff) | |
download | FreeBSD-src-3033318809d10165bff918597656578a8dc16bd9.zip FreeBSD-src-3033318809d10165bff918597656578a8dc16bd9.tar.gz |
Introduce fetchXGet*(), which combine the functionalities of fetchGet*() and
fetchStat*(). In most cases, either fetchGet*() or fetchXGet*() is a wrapper
around the other; in all cases, calling fetchGet*() is identical to calling
fetchXGet*() with the second argument set to NULL.
Diffstat (limited to 'lib/libfetch/http.c')
-rw-r--r-- | lib/libfetch/http.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index a384e04..ce748c5 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -772,8 +772,10 @@ _http_request(struct url *URL, char *op, struct url_stat *us, char *flags) for (url = URL, i = 0; i < n; ++i) { new = NULL; - us->size = -1; - us->atime = us->mtime = 0; + if (us) { + us->size = -1; + us->atime = us->mtime = 0; + } chunked = 0; need_auth = 0; offset = 0; @@ -883,13 +885,15 @@ _http_request(struct url *URL, char *op, struct url_stat *us, char *flags) _http_seterr(HTTP_PROTOCOL_ERROR); goto ouch; case hdr_content_length: - us->size = _http_parse_length(p); + if (us) + us->size = _http_parse_length(p); break; case hdr_content_range: offset = _http_parse_range(p); break; case hdr_last_modified: - us->atime = us->mtime = _http_parse_mtime(p); + if (us) + us->atime = us->mtime = _http_parse_mtime(p); break; case hdr_location: if (!HTTP_REDIRECT(code)) @@ -978,16 +982,26 @@ _http_request(struct url *URL, char *op, struct url_stat *us, char *flags) */ /* + * Retrieve and stat a file by HTTP + */ +FILE * +fetchXGetHTTP(struct url *URL, struct url_stat *us, char *flags) +{ + return _http_request(URL, "GET", us, flags); +} + +/* * Retrieve a file by HTTP */ FILE * fetchGetHTTP(struct url *URL, char *flags) { - struct url_stat us; - - return _http_request(URL, "GET", &us, flags); + return fetchXGetHTTP(URL, NULL, flags); } +/* + * Store a file by HTTP + */ FILE * fetchPutHTTP(struct url *URL, char *flags) { |