]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - lib/libfetch/fetch.3
MFC r363988:
[FreeBSD/stable/9.git] / lib / libfetch / fetch.3
1 .\"-
2 .\" Copyright (c) 1998-2013 Dag-Erling Smørgrav
3 .\" Copyright (c) 2013 Michael Gmelin <freebsd@grem.de>
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
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 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" SUCH DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd November 29, 2015
30 .Dt FETCH 3
31 .Os
32 .Sh NAME
33 .Nm fetchMakeURL ,
34 .Nm fetchParseURL ,
35 .Nm fetchFreeURL ,
36 .Nm fetchXGetURL ,
37 .Nm fetchGetURL ,
38 .Nm fetchPutURL ,
39 .Nm fetchStatURL ,
40 .Nm fetchListURL ,
41 .Nm fetchXGet ,
42 .Nm fetchGet ,
43 .Nm fetchPut ,
44 .Nm fetchStat ,
45 .Nm fetchList ,
46 .Nm fetchXGetFile ,
47 .Nm fetchGetFile ,
48 .Nm fetchPutFile ,
49 .Nm fetchStatFile ,
50 .Nm fetchListFile ,
51 .Nm fetchXGetHTTP ,
52 .Nm fetchGetHTTP ,
53 .Nm fetchPutHTTP ,
54 .Nm fetchStatHTTP ,
55 .Nm fetchListHTTP ,
56 .Nm fetchXGetFTP ,
57 .Nm fetchGetFTP ,
58 .Nm fetchPutFTP ,
59 .Nm fetchStatFTP ,
60 .Nm fetchListFTP
61 .Nd file transfer functions
62 .Sh LIBRARY
63 .Lb libfetch
64 .Sh SYNOPSIS
65 .In sys/param.h
66 .In stdio.h
67 .In fetch.h
68 .Ft struct url *
69 .Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd"
70 .Ft struct url *
71 .Fn fetchParseURL "const char *URL"
72 .Ft void
73 .Fn fetchFreeURL "struct url *u"
74 .Ft FILE *
75 .Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags"
76 .Ft FILE *
77 .Fn fetchGetURL "const char *URL" "const char *flags"
78 .Ft FILE *
79 .Fn fetchPutURL "const char *URL" "const char *flags"
80 .Ft int
81 .Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags"
82 .Ft struct url_ent *
83 .Fn fetchListURL "const char *URL" "const char *flags"
84 .Ft FILE *
85 .Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags"
86 .Ft FILE *
87 .Fn fetchGet "struct url *u" "const char *flags"
88 .Ft FILE *
89 .Fn fetchPut "struct url *u" "const char *flags"
90 .Ft int
91 .Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags"
92 .Ft struct url_ent *
93 .Fn fetchList "struct url *u" "const char *flags"
94 .Ft FILE *
95 .Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags"
96 .Ft FILE *
97 .Fn fetchGetFile "struct url *u" "const char *flags"
98 .Ft FILE *
99 .Fn fetchPutFile "struct url *u" "const char *flags"
100 .Ft int
101 .Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags"
102 .Ft struct url_ent *
103 .Fn fetchListFile "struct url *u" "const char *flags"
104 .Ft FILE *
105 .Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags"
106 .Ft FILE *
107 .Fn fetchGetHTTP "struct url *u" "const char *flags"
108 .Ft FILE *
109 .Fn fetchPutHTTP "struct url *u" "const char *flags"
110 .Ft int
111 .Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags"
112 .Ft struct url_ent *
113 .Fn fetchListHTTP "struct url *u" "const char *flags"
114 .Ft FILE *
115 .Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags"
116 .Ft FILE *
117 .Fn fetchGetFTP "struct url *u" "const char *flags"
118 .Ft FILE *
119 .Fn fetchPutFTP "struct url *u" "const char *flags"
120 .Ft int
121 .Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags"
122 .Ft struct url_ent *
123 .Fn fetchListFTP "struct url *u" "const char *flags"
124 .Sh DESCRIPTION
125 These functions implement a high-level library for retrieving and
126 uploading files using Uniform Resource Locators (URLs).
127 .Pp
128 .Fn fetchParseURL
129 takes a URL in the form of a null-terminated string and splits it into
130 its components function according to the Common Internet Scheme Syntax
131 detailed in RFC1738.
132 A regular expression which produces this syntax is:
133 .Bd -literal
134     <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
135 .Ed
136 .Pp
137 If the URL does not seem to begin with a scheme name, the following
138 syntax is assumed:
139 .Bd -literal
140     ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
141 .Ed
142 .Pp
143 Note that some components of the URL are not necessarily relevant to
144 all URL schemes.
145 For instance, the file scheme only needs the <scheme> and <document>
146 components.
147 .Pp
148 .Fn fetchMakeURL
149 and
150 .Fn fetchParseURL
151 return a pointer to a
152 .Vt url
153 structure, which is defined as follows in
154 .In fetch.h :
155 .Bd -literal
156 #define URL_SCHEMELEN 16
157 #define URL_USERLEN 256
158 #define URL_PWDLEN 256
159
160 struct url {
161     char         scheme[URL_SCHEMELEN+1];
162     char         user[URL_USERLEN+1];
163     char         pwd[URL_PWDLEN+1];
164     char         host[MAXHOSTNAMELEN+1];
165     int          port;
166     char        *doc;
167     off_t        offset;
168     size_t       length;
169     time_t       ims_time;
170 };
171 .Ed
172 .Pp
173 The
174 .Va ims_time
175 field stores the time value for
176 .Li If-Modified-Since
177 HTTP requests.
178 .Pp
179 The pointer returned by
180 .Fn fetchMakeURL
181 or
182 .Fn fetchParseURL
183 should be freed using
184 .Fn fetchFreeURL .
185 .Pp
186 .Fn fetchXGetURL ,
187 .Fn fetchGetURL ,
188 and
189 .Fn fetchPutURL
190 constitute the recommended interface to the
191 .Nm fetch
192 library.
193 They examine the URL passed to them to determine the transfer
194 method, and call the appropriate lower-level functions to perform the
195 actual transfer.
196 .Fn fetchXGetURL
197 also returns the remote document's metadata in the
198 .Vt url_stat
199 structure pointed to by the
200 .Fa us
201 argument.
202 .Pp
203 The
204 .Fa flags
205 argument is a string of characters which specify transfer options.
206 The
207 meaning of the individual flags is scheme-dependent, and is detailed
208 in the appropriate section below.
209 .Pp
210 .Fn fetchStatURL
211 attempts to obtain the requested document's metadata and fill in the
212 structure pointed to by its second argument.
213 The
214 .Vt url_stat
215 structure is defined as follows in
216 .In fetch.h :
217 .Bd -literal
218 struct url_stat {
219     off_t        size;
220     time_t       atime;
221     time_t       mtime;
222 };
223 .Ed
224 .Pp
225 If the size could not be obtained from the server, the
226 .Fa size
227 field is set to -1.
228 If the modification time could not be obtained from the server, the
229 .Fa mtime
230 field is set to the epoch.
231 If the access time could not be obtained from the server, the
232 .Fa atime
233 field is set to the modification time.
234 .Pp
235 .Fn fetchListURL
236 attempts to list the contents of the directory pointed to by the URL
237 provided.
238 If successful, it returns a malloced array of
239 .Vt url_ent
240 structures.
241 The
242 .Vt url_ent
243 structure is defined as follows in
244 .In fetch.h :
245 .Bd -literal
246 struct url_ent {
247     char         name[PATH_MAX];
248     struct url_stat stat;
249 };
250 .Ed
251 .Pp
252 The list is terminated by an entry with an empty name.
253 .Pp
254 The pointer returned by
255 .Fn fetchListURL
256 should be freed using
257 .Fn free .
258 .Pp
259 .Fn fetchXGet ,
260 .Fn fetchGet ,
261 .Fn fetchPut
262 and
263 .Fn fetchStat
264 are similar to
265 .Fn fetchXGetURL ,
266 .Fn fetchGetURL ,
267 .Fn fetchPutURL
268 and
269 .Fn fetchStatURL ,
270 except that they expect a pre-parsed URL in the form of a pointer to
271 a
272 .Vt struct url
273 rather than a string.
274 .Pp
275 All of the
276 .Fn fetchXGetXXX ,
277 .Fn fetchGetXXX
278 and
279 .Fn fetchPutXXX
280 functions return a pointer to a stream which can be used to read or
281 write data from or to the requested document, respectively.
282 Note that
283 although the implementation details of the individual access methods
284 vary, it can generally be assumed that a stream returned by one of the
285 .Fn fetchXGetXXX
286 or
287 .Fn fetchGetXXX
288 functions is read-only, and that a stream returned by one of the
289 .Fn fetchPutXXX
290 functions is write-only.
291 .Sh FILE SCHEME
292 .Fn fetchXGetFile ,
293 .Fn fetchGetFile
294 and
295 .Fn fetchPutFile
296 provide access to documents which are files in a locally mounted file
297 system.
298 Only the <document> component of the URL is used.
299 .Pp
300 .Fn fetchXGetFile
301 and
302 .Fn fetchGetFile
303 do not accept any flags.
304 .Pp
305 .Fn fetchPutFile
306 accepts the
307 .Ql a
308 (append to file) flag.
309 If that flag is specified, the data written to
310 the stream returned by
311 .Fn fetchPutFile
312 will be appended to the previous contents of the file, instead of
313 replacing them.
314 .Sh FTP SCHEME
315 .Fn fetchXGetFTP ,
316 .Fn fetchGetFTP
317 and
318 .Fn fetchPutFTP
319 implement the FTP protocol as described in RFC959.
320 .Pp
321 If the
322 .Ql P
323 (not passive) flag is specified, an active (rather than passive)
324 connection will be attempted.
325 .Pp
326 The
327 .Ql p
328 flag is supported for compatibility with earlier versions where active
329 connections were the default.
330 It has precedence over the
331 .Ql P
332 flag, so if both are specified,
333 .Nm
334 will use a passive connection.
335 .Pp
336 If the
337 .Ql l
338 (low) flag is specified, data sockets will be allocated in the low (or
339 default) port range instead of the high port range (see
340 .Xr ip 4 ) .
341 .Pp
342 If the
343 .Ql d
344 (direct) flag is specified,
345 .Fn fetchXGetFTP ,
346 .Fn fetchGetFTP
347 and
348 .Fn fetchPutFTP
349 will use a direct connection even if a proxy server is defined.
350 .Pp
351 If no user name or password is given, the
352 .Nm fetch
353 library will attempt an anonymous login, with user name "anonymous"
354 and password "anonymous@<hostname>".
355 .Sh HTTP SCHEME
356 The
357 .Fn fetchXGetHTTP ,
358 .Fn fetchGetHTTP
359 and
360 .Fn fetchPutHTTP
361 functions implement the HTTP/1.1 protocol.
362 With a little luck, there is
363 even a chance that they comply with RFC2616 and RFC2617.
364 .Pp
365 If the
366 .Ql d
367 (direct) flag is specified,
368 .Fn fetchXGetHTTP ,
369 .Fn fetchGetHTTP
370 and
371 .Fn fetchPutHTTP
372 will use a direct connection even if a proxy server is defined.
373 .Pp
374 If the
375 .Ql i
376 (if-modified-since) flag is specified, and
377 the
378 .Va ims_time
379 field is set in
380 .Vt "struct url" ,
381 then
382 .Fn fetchXGetHTTP
383 and
384 .Fn fetchGetHTTP
385 will send a conditional
386 .Li If-Modified-Since
387 HTTP header to only fetch the content if it is newer than
388 .Va ims_time .
389 .Pp
390 Since there seems to be no good way of implementing the HTTP PUT
391 method in a manner consistent with the rest of the
392 .Nm fetch
393 library,
394 .Fn fetchPutHTTP
395 is currently unimplemented.
396 .Sh HTTPS SCHEME
397 Based on HTTP SCHEME.
398 By default the peer is verified using the CA bundle located in
399 .Pa /etc/ssl/cert.pem .
400 The file may contain multiple CA certificates.
401 A common source of a current CA bundle is
402 .Pa \%security/ca_root_nss .
403 .Pp
404 The CA bundle used for peer verification can be changed by setting the
405 environment variables
406 .Ev SSL_CA_CERT_FILE
407 to point to a concatenated bundle of trusted certificates and
408 .Ev SSL_CA_CERT_PATH
409 to point to a directory containing hashes of trusted CAs (see
410 .Xr verify 1 ) .
411 .Pp
412 A certificate revocation list (CRL) can be used by setting the
413 environment variable
414 .Ev SSL_CRL_FILE
415 (see
416 .Xr crl 1 ) .
417 .Pp
418 Peer verification can be disabled by setting the environment variable
419 .Ev SSL_NO_VERIFY_PEER .
420 Note that this also disables CRL checking.
421 .Pp
422 By default the service identity is verified according to the rules
423 detailed in RFC6125 (also known as hostname verification).
424 This feature can be disabled by setting the environment variable
425 .Ev SSL_NO_VERIFY_HOSTNAME .
426 .Pp
427 Client certificate based authentication is supported.
428 The environment variable
429 .Ev SSL_CLIENT_CERT_FILE
430 should be set to point to a file containing key and client certificate
431 to be used in PEM format. In case the key is stored in a separate
432 file, the environment variable
433 .Ev SSL_CLIENT_KEY_FILE
434 can be set to point to the key in PEM format.
435 In case the key uses a password, the user will be prompted on standard
436 input (see
437 .Xr PEM 3 ) .
438 .Pp
439 By default
440 .Nm libfetch
441 allows TLSv1 when negotiating the connecting with the remote
442 peer.
443 You can change this behavior by setting the
444 .Ev SSL_ALLOW_SSL3
445 environment variable to allow SSLv3 and
446 .Ev SSL_NO_TLS1
447 to disable TLS 1.0.
448 .Sh AUTHENTICATION
449 Apart from setting the appropriate environment variables and
450 specifying the user name and password in the URL or the
451 .Vt struct url ,
452 the calling program has the option of defining an authentication
453 function with the following prototype:
454 .Pp
455 .Ft int
456 .Fn myAuthMethod "struct url *u"
457 .Pp
458 The callback function should fill in the
459 .Fa user
460 and
461 .Fa pwd
462 fields in the provided
463 .Vt struct url
464 and return 0 on success, or any other value to indicate failure.
465 .Pp
466 To register the authentication callback, simply set
467 .Va fetchAuthMethod
468 to point at it.
469 The callback will be used whenever a site requires authentication and
470 the appropriate environment variables are not set.
471 .Pp
472 This interface is experimental and may be subject to change.
473 .Sh RETURN VALUES
474 .Fn fetchParseURL
475 returns a pointer to a
476 .Vt struct url
477 containing the individual components of the URL.
478 If it is
479 unable to allocate memory, or the URL is syntactically incorrect,
480 .Fn fetchParseURL
481 returns a NULL pointer.
482 .Pp
483 The
484 .Fn fetchStat
485 functions return 0 on success and -1 on failure.
486 .Pp
487 All other functions return a stream pointer which may be used to
488 access the requested document, or NULL if an error occurred.
489 .Pp
490 The following error codes are defined in
491 .In fetch.h :
492 .Bl -tag -width 18n
493 .It Bq Er FETCH_ABORT
494 Operation aborted
495 .It Bq Er FETCH_AUTH
496 Authentication failed
497 .It Bq Er FETCH_DOWN
498 Service unavailable
499 .It Bq Er FETCH_EXISTS
500 File exists
501 .It Bq Er FETCH_FULL
502 File system full
503 .It Bq Er FETCH_INFO
504 Informational response
505 .It Bq Er FETCH_MEMORY
506 Insufficient memory
507 .It Bq Er FETCH_MOVED
508 File has moved
509 .It Bq Er FETCH_NETWORK
510 Network error
511 .It Bq Er FETCH_OK
512 No error
513 .It Bq Er FETCH_PROTO
514 Protocol error
515 .It Bq Er FETCH_RESOLV
516 Resolver error
517 .It Bq Er FETCH_SERVER
518 Server error
519 .It Bq Er FETCH_TEMP
520 Temporary error
521 .It Bq Er FETCH_TIMEOUT
522 Operation timed out
523 .It Bq Er FETCH_UNAVAIL
524 File is not available
525 .It Bq Er FETCH_UNKNOWN
526 Unknown error
527 .It Bq Er FETCH_URL
528 Invalid URL
529 .El
530 .Pp
531 The accompanying error message includes a protocol-specific error code
532 and message, e.g.\& "File is not available (404 Not Found)"
533 .Sh ENVIRONMENT
534 .Bl -tag -width ".Ev FETCH_BIND_ADDRESS"
535 .It Ev FETCH_BIND_ADDRESS
536 Specifies a hostname or IP address to which sockets used for outgoing
537 connections will be bound.
538 .It Ev FTP_LOGIN
539 Default FTP login if none was provided in the URL.
540 .It Ev FTP_PASSIVE_MODE
541 If set to
542 .Ql no ,
543 forces the FTP code to use active mode.
544 If set to any other value, forces passive mode even if the application
545 requested active mode.
546 .It Ev FTP_PASSWORD
547 Default FTP password if the remote server requests one and none was
548 provided in the URL.
549 .It Ev FTP_PROXY
550 URL of the proxy to use for FTP requests.
551 The document part is ignored.
552 FTP and HTTP proxies are supported; if no scheme is specified, FTP is
553 assumed.
554 If the proxy is an FTP proxy,
555 .Nm libfetch
556 will send
557 .Ql user@host
558 as user name to the proxy, where
559 .Ql user
560 is the real user name, and
561 .Ql host
562 is the name of the FTP server.
563 .Pp
564 If this variable is set to an empty string, no proxy will be used for
565 FTP requests, even if the
566 .Ev HTTP_PROXY
567 variable is set.
568 .It Ev ftp_proxy
569 Same as
570 .Ev FTP_PROXY ,
571 for compatibility.
572 .It Ev HTTP_ACCEPT
573 Specifies the value of the
574 .Va Accept
575 header for HTTP requests.
576 If empty, no
577 .Va Accept
578 header is sent.
579 The default is
580 .Dq */* .
581 .It Ev HTTP_AUTH
582 Specifies HTTP authorization parameters as a colon-separated list of
583 items.
584 The first and second item are the authorization scheme and realm
585 respectively; further items are scheme-dependent.
586 Currently, the
587 .Dq basic
588 and
589 .Dq digest
590 authorization methods are supported.
591 .Pp
592 Both methods require two parameters: the user name and
593 password, in that order.
594 .Pp
595 This variable is only used if the server requires authorization and
596 no user name or password was specified in the URL.
597 .It Ev HTTP_PROXY
598 URL of the proxy to use for HTTP requests.
599 The document part is ignored.
600 Only HTTP proxies are supported for HTTP requests.
601 If no port number is specified, the default is 3128.
602 .Pp
603 Note that this proxy will also be used for FTP documents, unless the
604 .Ev FTP_PROXY
605 variable is set.
606 .It Ev http_proxy
607 Same as
608 .Ev HTTP_PROXY ,
609 for compatibility.
610 .It Ev HTTP_PROXY_AUTH
611 Specifies authorization parameters for the HTTP proxy in the same
612 format as the
613 .Ev HTTP_AUTH
614 variable.
615 .Pp
616 This variable is used if and only if connected to an HTTP proxy, and
617 is ignored if a user and/or a password were specified in the proxy
618 URL.
619 .It Ev HTTP_REFERER
620 Specifies the referrer URL to use for HTTP requests.
621 If set to
622 .Dq auto ,
623 the document URL will be used as referrer URL.
624 .It Ev HTTP_USER_AGENT
625 Specifies the User-Agent string to use for HTTP requests.
626 This can be useful when working with HTTP origin or proxy servers that
627 differentiate between user agents.
628 If defined but empty, no User-Agent header is sent.
629 .It Ev NETRC
630 Specifies a file to use instead of
631 .Pa ~/.netrc
632 to look up login names and passwords for FTP and HTTP sites as well as
633 HTTP proxies.
634 See
635 .Xr ftp 1
636 for a description of the file format.
637 .It Ev NO_PROXY
638 Either a single asterisk, which disables the use of proxies
639 altogether, or a comma- or whitespace-separated list of hosts for
640 which proxies should not be used.
641 .It Ev no_proxy
642 Same as
643 .Ev NO_PROXY ,
644 for compatibility.
645 .It Ev SSL_ALLOW_SSL3
646 Allow SSL version 3 when negotiating the connection (not recommended).
647 .It Ev SSL_CA_CERT_FILE
648 CA certificate bundle containing trusted CA certificates.
649 Default value:
650 .Pa /etc/ssl/cert.pem .
651 .It Ev SSL_CA_CERT_PATH
652 Path containing trusted CA hashes.
653 .It Ev SSL_CLIENT_CERT_FILE
654 PEM encoded client certificate/key which will be used in
655 client certificate authentication.
656 .It Ev SSL_CLIENT_KEY_FILE
657 PEM encoded client key in case key and client certificate
658 are stored separately.
659 .It Ev SSL_CRL_FILE
660 File containing certificate revocation list.
661 .It Ev SSL_NO_TLS1
662 Do not allow TLS version 1.0 when negotiating the connection.
663 .It Ev SSL_NO_TLS1_1
664 Do not allow TLS version 1.1 when negotiating the connection.
665 .It Ev SSL_NO_TLS1_2
666 Do not allow TLS version 1.2 when negotiating the connection.
667 .It Ev SSL_NO_VERIFY_HOSTNAME
668 If set, do not verify that the hostname matches the subject of the
669 certificate presented by the server.
670 .It Ev SSL_NO_VERIFY_PEER
671 If set, do not verify the peer certificate against trusted CAs.
672 .El
673 .Sh EXAMPLES
674 To access a proxy server on
675 .Pa proxy.example.com
676 port 8080, set the
677 .Ev HTTP_PROXY
678 environment variable in a manner similar to this:
679 .Pp
680 .Dl HTTP_PROXY=http://proxy.example.com:8080
681 .Pp
682 If the proxy server requires authentication, there are
683 two options available for passing the authentication data.
684 The first method is by using the proxy URL:
685 .Pp
686 .Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080
687 .Pp
688 The second method is by using the
689 .Ev HTTP_PROXY_AUTH
690 environment variable:
691 .Bd -literal -offset indent
692 HTTP_PROXY=http://proxy.example.com:8080
693 HTTP_PROXY_AUTH=basic:*:<user>:<pwd>
694 .Ed
695 .Pp
696 To disable the use of a proxy for an HTTP server running on the local
697 host, define
698 .Ev NO_PROXY
699 as follows:
700 .Bd -literal -offset indent
701 NO_PROXY=localhost,127.0.0.1
702 .Ed
703 .Pp
704 Access HTTPS website without any certificate verification whatsoever:
705 .Bd -literal -offset indent
706 SSL_NO_VERIFY_PEER=1
707 SSL_NO_VERIFY_HOSTNAME=1
708 .Ed
709 .Pp
710 Access HTTPS website using client certificate based authentication
711 and a private CA:
712 .Bd -literal -offset indent
713 SSL_CLIENT_CERT_FILE=/path/to/client.pem
714 SSL_CA_CERT_FILE=/path/to/myca.pem
715 .Ed
716 .Sh SEE ALSO
717 .Xr fetch 1 ,
718 .Xr ftpio 3 ,
719 .Xr ip 4
720 .Rs
721 .%A J. Postel
722 .%A J. K. Reynolds
723 .%D October 1985
724 .%B File Transfer Protocol
725 .%O RFC959
726 .Re
727 .Rs
728 .%A P. Deutsch
729 .%A A. Emtage
730 .%A A. Marine.
731 .%D May 1994
732 .%T How to Use Anonymous FTP
733 .%O RFC1635
734 .Re
735 .Rs
736 .%A T. Berners-Lee
737 .%A L. Masinter
738 .%A M. McCahill
739 .%D December 1994
740 .%T Uniform Resource Locators (URL)
741 .%O RFC1738
742 .Re
743 .Rs
744 .%A R. Fielding
745 .%A J. Gettys
746 .%A J. Mogul
747 .%A H. Frystyk
748 .%A L. Masinter
749 .%A P. Leach
750 .%A T. Berners-Lee
751 .%D January 1999
752 .%B Hypertext Transfer Protocol -- HTTP/1.1
753 .%O RFC2616
754 .Re
755 .Rs
756 .%A J. Franks
757 .%A P. Hallam-Baker
758 .%A J. Hostetler
759 .%A S. Lawrence
760 .%A P. Leach
761 .%A A. Luotonen
762 .%A L. Stewart
763 .%D June 1999
764 .%B HTTP Authentication: Basic and Digest Access Authentication
765 .%O RFC2617
766 .Re
767 .Sh HISTORY
768 The
769 .Nm fetch
770 library first appeared in
771 .Fx 3.0 .
772 .Sh AUTHORS
773 .An -nosplit
774 The
775 .Nm fetch
776 library was mostly written by
777 .An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
778 with numerous suggestions and contributions from
779 .An Jordan K. Hubbard Aq jkh@FreeBSD.org ,
780 .An Eugene Skepner Aq eu@qub.com ,
781 .An Hajimu Umemoto Aq ume@FreeBSD.org ,
782 .An Henry Whincup Aq henry@techiebod.com ,
783 .An Jukka A. Ukkonen Aq jau@iki.fi ,
784 .An Jean-Fran\(,cois Dockes Aq jf@dockes.org ,
785 .An Michael Gmelin Aq freebsd@grem.de
786 and others.
787 It replaces the older
788 .Nm ftpio
789 library written by
790 .An Poul-Henning Kamp Aq phk@FreeBSD.org
791 and
792 .An Jordan K. Hubbard Aq jkh@FreeBSD.org .
793 .Pp
794 This manual page was written by
795 .An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
796 and
797 .An Michael Gmelin Aq freebsd@grem.de .
798 .Sh BUGS
799 Some parts of the library are not yet implemented.
800 The most notable
801 examples of this are
802 .Fn fetchPutHTTP ,
803 .Fn fetchListHTTP ,
804 .Fn fetchListFTP
805 and FTP proxy support.
806 .Pp
807 There is no way to select a proxy at run-time other than setting the
808 .Ev HTTP_PROXY
809 or
810 .Ev FTP_PROXY
811 environment variables as appropriate.
812 .Pp
813 .Nm libfetch
814 does not understand or obey 305 (Use Proxy) replies.
815 .Pp
816 Error numbers are unique only within a certain context; the error
817 codes used for FTP and HTTP overlap, as do those used for resolver and
818 system errors.
819 For instance, error code 202 means "Command not
820 implemented, superfluous at this site" in an FTP context and
821 "Accepted" in an HTTP context.
822 .Pp
823 .Fn fetchStatFTP
824 does not check that the result of an MDTM command is a valid date.
825 .Pp
826 In case password protected keys are used for client certificate based
827 authentication the user is prompted for the password on each and every
828 fetch operation.
829 .Pp
830 The man page is incomplete, poorly written and produces badly
831 formatted text.
832 .Pp
833 The error reporting mechanism is unsatisfactory.
834 .Pp
835 Some parts of the code are not fully reentrant.