2 * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
33 * The following copyright applies to the base64 code:
36 * Copyright 1997 Massachusetts Institute of Technology
38 * Permission to use, copy, modify, and distribute this software and
39 * its documentation for any purpose and without fee is hereby
40 * granted, provided that both the above copyright notice and this
41 * permission notice appear in all copies, that both the above
42 * copyright notice and this permission notice appear in all
43 * supporting documentation, and that the name of M.I.T. not be used
44 * in advertising or publicity pertaining to distribution of the
45 * software without specific, written prior permission. M.I.T. makes
46 * no representations about the suitability of this software for any
47 * purpose. It is provided "as is" without express or implied
50 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
51 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
52 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
54 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
57 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
58 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
59 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
60 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 #include <sys/param.h>
65 #include <sys/socket.h>
79 #include <netinet/in.h>
80 #include <netinet/tcp.h>
86 /* Maximum number of redirects to follow */
87 #define MAX_REDIRECT 5
89 /* Symbolic names for reply codes we care about */
91 #define HTTP_PARTIAL 206
92 #define HTTP_MOVED_PERM 301
93 #define HTTP_MOVED_TEMP 302
94 #define HTTP_SEE_OTHER 303
95 #define HTTP_NEED_AUTH 401
96 #define HTTP_NEED_PROXY_AUTH 407
97 #define HTTP_BAD_RANGE 416
98 #define HTTP_PROTOCOL_ERROR 999
100 #define HTTP_REDIRECT(xyz) ((xyz) == HTTP_MOVED_PERM \
101 || (xyz) == HTTP_MOVED_TEMP \
102 || (xyz) == HTTP_SEE_OTHER)
104 #define HTTP_ERROR(xyz) ((xyz) > 400 && (xyz) < 599)
107 /*****************************************************************************
108 * I/O functions for decoding chunked streams
113 conn_t *conn; /* connection */
114 int chunked; /* chunked mode */
115 char *buf; /* chunk buffer */
116 size_t bufsize; /* size of chunk buffer */
117 ssize_t buflen; /* amount of data currently in buffer */
118 int bufpos; /* current read offset in buffer */
119 int eof; /* end-of-file flag */
120 int error; /* error flag */
121 size_t chunksize; /* remaining size of current chunk */
128 * Get next chunk header
131 _http_new_chunk(struct httpio *io)
135 if (_fetch_getln(io->conn) == -1)
138 if (io->conn->buflen < 2 || !ishexnumber(*io->conn->buf))
141 for (p = io->conn->buf; *p && !isspace(*p); ++p) {
144 if (!ishexnumber(*p))
147 io->chunksize = io->chunksize * 16 +
150 io->chunksize = io->chunksize * 16 +
151 10 + tolower(*p) - 'a';
157 io->total += io->chunksize;
158 if (io->chunksize == 0)
159 fprintf(stderr, "%s(): end of last chunk\n", __func__);
161 fprintf(stderr, "%s(): new chunk: %lu (%lu)\n",
162 __func__, (unsigned long)io->chunksize,
163 (unsigned long)io->total);
167 return (io->chunksize);
171 * Grow the input buffer to at least len bytes
174 _http_growbuf(struct httpio *io, size_t len)
178 if (io->bufsize >= len)
181 if ((tmp = realloc(io->buf, len)) == NULL)
189 * Fill the input buffer, do chunk decoding on the fly
192 _http_fillbuf(struct httpio *io, size_t len)
199 if (io->chunked == 0) {
200 if (_http_growbuf(io, len) == -1)
202 if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) {
210 if (io->chunksize == 0) {
211 switch (_http_new_chunk(io)) {
221 if (len > io->chunksize)
223 if (_http_growbuf(io, len) == -1)
225 if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) {
229 io->chunksize -= io->buflen;
231 if (io->chunksize == 0) {
234 if (_fetch_read(io->conn, endl, 2) != 2 ||
235 endl[0] != '\r' || endl[1] != '\n')
248 _http_readfn(void *v, char *buf, int len)
250 struct httpio *io = (struct httpio *)v;
258 for (pos = 0; len > 0; pos += l, len -= l) {
260 if (!io->buf || io->bufpos == io->buflen)
261 if (_http_fillbuf(io, len) < 1)
263 l = io->buflen - io->bufpos;
266 bcopy(io->buf + io->bufpos, buf + pos, l);
270 if (!pos && io->error)
279 _http_writefn(void *v, const char *buf, int len)
281 struct httpio *io = (struct httpio *)v;
283 return (_fetch_write(io->conn, buf, len));
290 _http_closefn(void *v)
292 struct httpio *io = (struct httpio *)v;
295 r = _fetch_close(io->conn);
303 * Wrap a file descriptor up
306 _http_funopen(conn_t *conn, int chunked)
311 if ((io = calloc(1, sizeof(*io))) == NULL) {
316 io->chunked = chunked;
317 f = funopen(io, _http_readfn, _http_writefn, NULL, _http_closefn);
327 /*****************************************************************************
328 * Helper functions for talking to the server and parsing its replies
341 hdr_transfer_encoding,
345 /* Names of interesting headers */
350 { hdr_content_length, "Content-Length" },
351 { hdr_content_range, "Content-Range" },
352 { hdr_last_modified, "Last-Modified" },
353 { hdr_location, "Location" },
354 { hdr_transfer_encoding, "Transfer-Encoding" },
355 { hdr_www_authenticate, "WWW-Authenticate" },
356 { hdr_unknown, NULL },
360 * Send a formatted line; optionally echo to terminal
363 _http_cmd(conn_t *conn, const char *fmt, ...)
371 len = vasprintf(&msg, fmt, ap);
380 r = _fetch_putln(conn, msg, len);
392 * Get and parse status line
395 _http_get_reply(conn_t *conn)
399 if (_fetch_getln(conn) == -1)
402 * A valid status line looks like "HTTP/m.n xyz reason" where m
403 * and n are the major and minor protocol version numbers and xyz
405 * Unfortunately, there are servers out there (NCSA 1.5.1, to name
406 * just one) that do not send a version number, so we can't rely
407 * on finding one, but if we do, insist on it being 1.0 or 1.1.
408 * We don't care about the reason phrase.
410 if (strncmp(conn->buf, "HTTP", 4) != 0)
411 return (HTTP_PROTOCOL_ERROR);
414 if (p[1] != '1' || p[2] != '.' || (p[3] != '0' && p[3] != '1'))
415 return (HTTP_PROTOCOL_ERROR);
418 if (*p != ' ' || !isdigit(p[1]) || !isdigit(p[2]) || !isdigit(p[3]))
419 return (HTTP_PROTOCOL_ERROR);
421 conn->err = (p[1] - '0') * 100 + (p[2] - '0') * 10 + (p[3] - '0');
426 * Check a header; if the type matches the given string, return a pointer
427 * to the beginning of the value.
430 _http_match(const char *str, const char *hdr)
432 while (*str && *hdr && tolower(*str++) == tolower(*hdr++))
434 if (*str || *hdr != ':')
436 while (*hdr && isspace(*++hdr))
442 * Get the next header and return the appropriate symbolic code.
445 _http_next_header(conn_t *conn, const char **p)
449 if (_fetch_getln(conn) == -1)
450 return (hdr_syserror);
451 while (conn->buflen && isspace(conn->buf[conn->buflen - 1]))
453 conn->buf[conn->buflen] = '\0';
454 if (conn->buflen == 0)
457 * We could check for malformed headers but we don't really care.
458 * A valid header starts with a token immediately followed by a
459 * colon; a token is any sequence of non-control, non-whitespace
460 * characters except "()<>@,;:\\\"{}".
462 for (i = 0; hdr_names[i].num != hdr_unknown; i++)
463 if ((*p = _http_match(hdr_names[i].name, conn->buf)) != NULL)
464 return (hdr_names[i].num);
465 return (hdr_unknown);
469 * Parse a last-modified header
472 _http_parse_mtime(const char *p, time_t *mtime)
477 strncpy(locale, setlocale(LC_TIME, NULL), sizeof(locale));
478 setlocale(LC_TIME, "C");
479 r = strptime(p, "%a, %d %b %Y %H:%M:%S GMT", &tm);
480 /* XXX should add support for date-2 and date-3 */
481 setlocale(LC_TIME, locale);
484 DEBUG(fprintf(stderr, "last modified: [%04d-%02d-%02d "
486 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
487 tm.tm_hour, tm.tm_min, tm.tm_sec));
488 *mtime = timegm(&tm);
493 * Parse a content-length header
496 _http_parse_length(const char *p, off_t *length)
500 for (len = 0; *p && isdigit(*p); ++p)
501 len = len * 10 + (*p - '0');
504 DEBUG(fprintf(stderr, "content length: [%lld]\n",
511 * Parse a content-range header
514 _http_parse_range(const char *p, off_t *offset, off_t *length, off_t *size)
516 off_t first, last, len;
518 if (strncasecmp(p, "bytes ", 6) != 0)
525 for (first = 0; *p && isdigit(*p); ++p)
526 first = first * 10 + *p - '0';
529 for (last = 0, ++p; *p && isdigit(*p); ++p)
530 last = last * 10 + *p - '0';
532 if (first > last || *p != '/')
534 for (len = 0, ++p; *p && isdigit(*p); ++p)
535 len = len * 10 + *p - '0';
536 if (*p || len < last - first + 1)
539 DEBUG(fprintf(stderr, "content range: [*/%lld]\n",
543 DEBUG(fprintf(stderr, "content range: [%lld-%lld/%lld]\n",
544 (long long)first, (long long)last, (long long)len));
545 *length = last - first + 1;
553 /*****************************************************************************
554 * Helper functions for authorization
561 _http_base64(const char *src)
563 static const char base64[] =
564 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
565 "abcdefghijklmnopqrstuvwxyz"
572 if ((str = malloc(((l + 2) / 3) * 4 + 1)) == NULL)
578 t = (src[0] << 16) | (src[1] << 8) | src[2];
579 dst[0] = base64[(t >> 18) & 0x3f];
580 dst[1] = base64[(t >> 12) & 0x3f];
581 dst[2] = base64[(t >> 6) & 0x3f];
582 dst[3] = base64[(t >> 0) & 0x3f];
589 t = (src[0] << 16) | (src[1] << 8);
590 dst[0] = base64[(t >> 18) & 0x3f];
591 dst[1] = base64[(t >> 12) & 0x3f];
592 dst[2] = base64[(t >> 6) & 0x3f];
599 dst[0] = base64[(t >> 18) & 0x3f];
600 dst[1] = base64[(t >> 12) & 0x3f];
601 dst[2] = dst[3] = '=';
614 * Encode username and password
617 _http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd)
622 DEBUG(fprintf(stderr, "usr: [%s]\n", usr));
623 DEBUG(fprintf(stderr, "pwd: [%s]\n", pwd));
624 if (asprintf(&upw, "%s:%s", usr, pwd) == -1)
626 auth = _http_base64(upw);
630 r = _http_cmd(conn, "%s: Basic %s", hdr, auth);
636 * Send an authorization header
639 _http_authorize(conn_t *conn, const char *hdr, const char *p)
641 /* basic authorization */
642 if (strncasecmp(p, "basic:", 6) == 0) {
643 char *user, *pwd, *str;
647 for (p += 6; *p && *p != ':'; ++p)
649 if (!*p || strchr(++p, ':') == NULL)
651 if ((str = strdup(p)) == NULL)
652 return (-1); /* XXX */
654 pwd = strchr(str, ':');
656 r = _http_basic_auth(conn, hdr, user, pwd);
664 /*****************************************************************************
665 * Helper functions for connecting to a server or proxy
669 * Connect to the correct HTTP server or proxy.
672 _http_connect(struct url *URL, struct url *purl, const char *flags)
684 verbose = CHECK_FLAG('v');
688 else if (CHECK_FLAG('6'))
692 if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) {
694 } else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) {
695 /* can't talk http to an ftp server */
696 /* XXX should set an error code */
700 if ((conn = _fetch_connect(URL->host, URL->port, af, verbose)) == NULL)
701 /* _fetch_connect() has already set an error code */
703 if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 &&
704 _fetch_ssl(conn, verbose) == -1) {
713 setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val));
719 _http_get_proxy(const char *flags)
724 if (flags != NULL && strchr(flags, 'd') != NULL)
726 if (((p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) &&
727 *p && (purl = fetchParseURL(p))) {
729 strcpy(purl->scheme, SCHEME_HTTP);
731 purl->port = _fetch_default_proxy_port(purl->scheme);
732 if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
740 _http_print_html(FILE *out, FILE *in)
747 while ((line = fgetln(in, &len)) != NULL) {
748 while (len && isspace(line[len - 1]))
750 for (p = q = line; q < line + len; ++q) {
751 if (comment && *q == '-') {
752 if (q + 2 < line + len &&
753 strcmp(q, "-->") == 0) {
757 } else if (tag && !comment && *q == '>') {
760 } else if (!tag && *q == '<') {
762 fwrite(p, q - p, 1, out);
764 if (q + 3 < line + len &&
765 strcmp(q, "<!--") == 0) {
772 fwrite(p, q - p, 1, out);
778 /*****************************************************************************
783 * Send a request and process the reply
785 * XXX This function is way too long, the do..while loop should be split
786 * XXX off into a separate function.
789 _http_request(struct url *URL, const char *op, struct url_stat *us,
790 struct url *purl, const char *flags)
793 struct url *url, *new;
794 int chunked, direct, need_auth, noredirect, verbose;
796 off_t offset, clength, length, size;
801 char hbuf[MAXHOSTNAMELEN + 7], *host;
803 direct = CHECK_FLAG('d');
804 noredirect = CHECK_FLAG('A');
805 verbose = CHECK_FLAG('v');
807 if (direct && purl) {
812 /* try the provided URL first */
815 /* if the A flag is set, we only get one try */
816 n = noredirect ? 1 : MAX_REDIRECT;
819 e = HTTP_PROTOCOL_ERROR;
832 url->port = _fetch_default_port(url->scheme);
834 /* were we redirected to an FTP URL? */
835 if (purl == NULL && strcmp(url->scheme, SCHEME_FTP) == 0) {
836 if (strcmp(op, "GET") == 0)
837 return (_ftp_request(url, "RETR", us, purl, flags));
838 else if (strcmp(op, "HEAD") == 0)
839 return (_ftp_request(url, "STAT", us, purl, flags));
842 /* connect to server or proxy */
843 if ((conn = _http_connect(url, purl, flags)) == NULL)
848 if (strchr(url->host, ':')) {
849 snprintf(hbuf, sizeof(hbuf), "[%s]", url->host);
853 if (url->port != _fetch_default_port(url->scheme)) {
858 snprintf(hbuf + strlen(hbuf),
859 sizeof(hbuf) - strlen(hbuf), ":%d", url->port);
864 _fetch_info("requesting %s://%s%s",
865 url->scheme, host, url->doc);
867 _http_cmd(conn, "%s %s://%s%s HTTP/1.1",
868 op, url->scheme, host, url->doc);
870 _http_cmd(conn, "%s %s HTTP/1.1",
875 _http_cmd(conn, "Host: %s", host);
877 /* proxy authorization */
879 if (*purl->user || *purl->pwd)
880 _http_basic_auth(conn, "Proxy-Authorization",
881 purl->user, purl->pwd);
882 else if ((p = getenv("HTTP_PROXY_AUTH")) != NULL && *p != '\0')
883 _http_authorize(conn, "Proxy-Authorization", p);
886 /* server authorization */
887 if (need_auth || *url->user || *url->pwd) {
888 if (*url->user || *url->pwd)
889 _http_basic_auth(conn, "Authorization", url->user, url->pwd);
890 else if ((p = getenv("HTTP_AUTH")) != NULL && *p != '\0')
891 _http_authorize(conn, "Authorization", p);
892 else if (fetchAuthMethod && fetchAuthMethod(url) == 0) {
893 _http_basic_auth(conn, "Authorization", url->user, url->pwd);
895 _http_seterr(HTTP_NEED_AUTH);
901 if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') {
902 if (strcasecmp(p, "auto") == 0)
903 _http_cmd(conn, "Referer: %s://%s%s",
904 url->scheme, host, url->doc);
906 _http_cmd(conn, "Referer: %s", p);
908 if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
909 _http_cmd(conn, "User-Agent: %s", p);
911 _http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
913 _http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
914 _http_cmd(conn, "Connection: close");
918 * Force the queued request to be dispatched. Normally, one
919 * would do this with shutdown(2) but squid proxies can be
920 * configured to disallow such half-closed connections. To
921 * be compatible with such configurations, fiddle with socket
922 * options to force the pending data to be written.
925 setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val,
928 setsockopt(conn->sd, IPPROTO_TCP, TCP_NODELAY, &val,
932 switch (_http_get_reply(conn)) {
937 case HTTP_MOVED_PERM:
938 case HTTP_MOVED_TEMP:
941 * Not so fine, but we still have to read the
942 * headers to get the new location.
948 * We already sent out authorization code,
949 * so there's nothing more we can do.
951 _http_seterr(conn->err);
954 /* try again, but send the password this time */
956 _fetch_info("server requires authorization");
958 case HTTP_NEED_PROXY_AUTH:
960 * If we're talking to a proxy, we already sent
961 * our proxy authorization code, so there's
962 * nothing more we can do.
964 _http_seterr(conn->err);
968 * This can happen if we ask for 0 bytes because
969 * we already have the whole file. Consider this
970 * a success for now, and check sizes later.
973 case HTTP_PROTOCOL_ERROR:
979 _http_seterr(conn->err);
982 /* fall through so we can get the full error message */
987 switch ((h = _http_next_header(conn, &p))) {
992 _http_seterr(HTTP_PROTOCOL_ERROR);
994 case hdr_content_length:
995 _http_parse_length(p, &clength);
997 case hdr_content_range:
998 _http_parse_range(p, &offset, &length, &size);
1000 case hdr_last_modified:
1001 _http_parse_mtime(p, &mtime);
1004 if (!HTTP_REDIRECT(conn->err))
1009 _fetch_info("%d redirect to %s", conn->err, p);
1012 new = fetchMakeURL(url->scheme, url->host, url->port, p,
1013 url->user, url->pwd);
1015 new = fetchParseURL(p);
1017 /* XXX should set an error code */
1018 DEBUG(fprintf(stderr, "failed to parse new URL\n"));
1021 if (!*new->user && !*new->pwd) {
1022 strcpy(new->user, url->user);
1023 strcpy(new->pwd, url->pwd);
1025 new->offset = url->offset;
1026 new->length = url->length;
1028 case hdr_transfer_encoding:
1030 chunked = (strcasecmp(p, "chunked") == 0);
1032 case hdr_www_authenticate:
1033 if (conn->err != HTTP_NEED_AUTH)
1035 /* if we were smarter, we'd check the method and realm */
1043 } while (h > hdr_end);
1045 /* we need to provide authentication */
1046 if (conn->err == HTTP_NEED_AUTH) {
1054 /* requested range not satisfiable */
1055 if (conn->err == HTTP_BAD_RANGE) {
1056 if (url->offset == size && url->length == 0) {
1057 /* asked for 0 bytes; fake it */
1058 offset = url->offset;
1059 conn->err = HTTP_OK;
1062 _http_seterr(conn->err);
1067 /* we have a hit or an error */
1068 if (conn->err == HTTP_OK || conn->err == HTTP_PARTIAL || HTTP_ERROR(conn->err))
1071 /* all other cases: we got a redirect */
1077 DEBUG(fprintf(stderr, "redirect with no new location\n"));
1085 /* we failed, or ran out of retries */
1091 DEBUG(fprintf(stderr, "offset %lld, length %lld,"
1092 " size %lld, clength %lld\n",
1093 (long long)offset, (long long)length,
1094 (long long)size, (long long)clength));
1096 /* check for inconsistencies */
1097 if (clength != -1 && length != -1 && clength != length) {
1098 _http_seterr(HTTP_PROTOCOL_ERROR);
1104 length = offset + clength;
1105 if (length != -1 && size != -1 && length != size) {
1106 _http_seterr(HTTP_PROTOCOL_ERROR);
1115 us->atime = us->mtime = mtime;
1119 if (URL->offset > 0 && offset > URL->offset) {
1120 _http_seterr(HTTP_PROTOCOL_ERROR);
1124 /* report back real offset and size */
1125 URL->offset = offset;
1126 URL->length = clength;
1128 /* wrap it up in a FILE */
1129 if ((f = _http_funopen(conn, chunked)) == NULL) {
1139 if (HTTP_ERROR(conn->err)) {
1140 _http_print_html(stderr, f);
1158 /*****************************************************************************
1163 * Retrieve and stat a file by HTTP
1166 fetchXGetHTTP(struct url *URL, struct url_stat *us, const char *flags)
1168 return (_http_request(URL, "GET", us, _http_get_proxy(flags), flags));
1172 * Retrieve a file by HTTP
1175 fetchGetHTTP(struct url *URL, const char *flags)
1177 return (fetchXGetHTTP(URL, NULL, flags));
1181 * Store a file by HTTP
1184 fetchPutHTTP(struct url *URL __unused, const char *flags __unused)
1186 warnx("fetchPutHTTP(): not implemented");
1191 * Get an HTTP document's metadata
1194 fetchStatHTTP(struct url *URL, struct url_stat *us, const char *flags)
1198 f = _http_request(URL, "HEAD", us, _http_get_proxy(flags), flags);
1209 fetchListHTTP(struct url *url __unused, const char *flags __unused)
1211 warnx("fetchListHTTP(): not implemented");