xref: /freebsd/lib/libfetch/fetch.3 (revision 01ed3ca3dedacaf3449a953e213dd462995c04fd)
12cbbf9daSDag-Erling Smørgrav.\"-
21453595fSDag-Erling Smørgrav.\" Copyright (c) 1998-2013 Dag-Erling Smørgrav
3dcd47379SDag-Erling Smørgrav.\" Copyright (c) 2013 Michael Gmelin <freebsd@grem.de>
44ca1ab94SDag-Erling Smørgrav.\" All rights reserved.
54ca1ab94SDag-Erling Smørgrav.\"
64ca1ab94SDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without
74ca1ab94SDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions
84ca1ab94SDag-Erling Smørgrav.\" are met:
94ca1ab94SDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright
104ca1ab94SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer.
114ca1ab94SDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright
124ca1ab94SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer in the
134ca1ab94SDag-Erling Smørgrav.\"    documentation and/or other materials provided with the distribution.
144ca1ab94SDag-Erling Smørgrav.\"
154ca1ab94SDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
164ca1ab94SDag-Erling Smørgrav.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
174ca1ab94SDag-Erling Smørgrav.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
184ca1ab94SDag-Erling Smørgrav.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
194ca1ab94SDag-Erling Smørgrav.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
204ca1ab94SDag-Erling Smørgrav.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
214ca1ab94SDag-Erling Smørgrav.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
224ca1ab94SDag-Erling Smørgrav.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
234ca1ab94SDag-Erling Smørgrav.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
244ca1ab94SDag-Erling Smørgrav.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
254ca1ab94SDag-Erling Smørgrav.\" SUCH DAMAGE.
264ca1ab94SDag-Erling Smørgrav.\"
277f3dea24SPeter Wemm.\" $FreeBSD$
284ca1ab94SDag-Erling Smørgrav.\"
29*01ed3ca3SJung-uk Kim.Dd March 25, 2015
304ca1ab94SDag-Erling Smørgrav.Dt FETCH 3
314ca1ab94SDag-Erling Smørgrav.Os
324ca1ab94SDag-Erling Smørgrav.Sh NAME
339a964d6aSDag-Erling Smørgrav.Nm fetchMakeURL ,
3460245e42SDag-Erling Smørgrav.Nm fetchParseURL ,
3560245e42SDag-Erling Smørgrav.Nm fetchFreeURL ,
361a5faa10SDag-Erling Smørgrav.Nm fetchXGetURL ,
374ca1ab94SDag-Erling Smørgrav.Nm fetchGetURL ,
384ca1ab94SDag-Erling Smørgrav.Nm fetchPutURL ,
39d8acd8dcSDag-Erling Smørgrav.Nm fetchStatURL ,
40ce71b736SDag-Erling Smørgrav.Nm fetchListURL ,
411a5faa10SDag-Erling Smørgrav.Nm fetchXGet ,
42db5f8cebSDag-Erling Smørgrav.Nm fetchGet ,
43db5f8cebSDag-Erling Smørgrav.Nm fetchPut ,
44d8acd8dcSDag-Erling Smørgrav.Nm fetchStat ,
45ce71b736SDag-Erling Smørgrav.Nm fetchList ,
461a5faa10SDag-Erling Smørgrav.Nm fetchXGetFile ,
474ca1ab94SDag-Erling Smørgrav.Nm fetchGetFile ,
484ca1ab94SDag-Erling Smørgrav.Nm fetchPutFile ,
49d8acd8dcSDag-Erling Smørgrav.Nm fetchStatFile ,
50ce71b736SDag-Erling Smørgrav.Nm fetchListFile ,
511a5faa10SDag-Erling Smørgrav.Nm fetchXGetHTTP ,
524ca1ab94SDag-Erling Smørgrav.Nm fetchGetHTTP ,
534ca1ab94SDag-Erling Smørgrav.Nm fetchPutHTTP ,
54d8acd8dcSDag-Erling Smørgrav.Nm fetchStatHTTP ,
55ce71b736SDag-Erling Smørgrav.Nm fetchListHTTP ,
561a5faa10SDag-Erling Smørgrav.Nm fetchXGetFTP ,
574ca1ab94SDag-Erling Smørgrav.Nm fetchGetFTP ,
5815efcd39SAlexey Zelkin.Nm fetchPutFTP ,
5915efcd39SAlexey Zelkin.Nm fetchStatFTP ,
6015efcd39SAlexey Zelkin.Nm fetchListFTP
6115efcd39SAlexey Zelkin.Nd file transfer functions
6215efcd39SAlexey Zelkin.Sh LIBRARY
6315efcd39SAlexey Zelkin.Lb libfetch
644ca1ab94SDag-Erling Smørgrav.Sh SYNOPSIS
6532eef9aeSRuslan Ermilov.In sys/param.h
6632eef9aeSRuslan Ermilov.In stdio.h
6732eef9aeSRuslan Ermilov.In fetch.h
6860245e42SDag-Erling Smørgrav.Ft struct url *
6938c7e4a6SArchie Cobbs.Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd"
709a964d6aSDag-Erling Smørgrav.Ft struct url *
7138c7e4a6SArchie Cobbs.Fn fetchParseURL "const char *URL"
7260245e42SDag-Erling Smørgrav.Ft void
7338c7e4a6SArchie Cobbs.Fn fetchFreeURL "struct url *u"
74db5f8cebSDag-Erling Smørgrav.Ft FILE *
7538c7e4a6SArchie Cobbs.Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags"
761a5faa10SDag-Erling Smørgrav.Ft FILE *
7738c7e4a6SArchie Cobbs.Fn fetchGetURL "const char *URL" "const char *flags"
78db5f8cebSDag-Erling Smørgrav.Ft FILE *
7938c7e4a6SArchie Cobbs.Fn fetchPutURL "const char *URL" "const char *flags"
80d8acd8dcSDag-Erling Smørgrav.Ft int
8138c7e4a6SArchie Cobbs.Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags"
82ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
8338c7e4a6SArchie Cobbs.Fn fetchListURL "const char *URL" "const char *flags"
844ca1ab94SDag-Erling Smørgrav.Ft FILE *
8538c7e4a6SArchie Cobbs.Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags"
861a5faa10SDag-Erling Smørgrav.Ft FILE *
8738c7e4a6SArchie Cobbs.Fn fetchGet "struct url *u" "const char *flags"
88db5f8cebSDag-Erling Smørgrav.Ft FILE *
8938c7e4a6SArchie Cobbs.Fn fetchPut "struct url *u" "const char *flags"
90d8acd8dcSDag-Erling Smørgrav.Ft int
9138c7e4a6SArchie Cobbs.Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags"
92ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
9338c7e4a6SArchie Cobbs.Fn fetchList "struct url *u" "const char *flags"
94db5f8cebSDag-Erling Smørgrav.Ft FILE *
9538c7e4a6SArchie Cobbs.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags"
961a5faa10SDag-Erling Smørgrav.Ft FILE *
9738c7e4a6SArchie Cobbs.Fn fetchGetFile "struct url *u" "const char *flags"
984ca1ab94SDag-Erling Smørgrav.Ft FILE *
9938c7e4a6SArchie Cobbs.Fn fetchPutFile "struct url *u" "const char *flags"
100d8acd8dcSDag-Erling Smørgrav.Ft int
10138c7e4a6SArchie Cobbs.Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags"
102ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
10338c7e4a6SArchie Cobbs.Fn fetchListFile "struct url *u" "const char *flags"
1044ca1ab94SDag-Erling Smørgrav.Ft FILE *
10538c7e4a6SArchie Cobbs.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags"
1061a5faa10SDag-Erling Smørgrav.Ft FILE *
10738c7e4a6SArchie Cobbs.Fn fetchGetHTTP "struct url *u" "const char *flags"
1084ca1ab94SDag-Erling Smørgrav.Ft FILE *
10938c7e4a6SArchie Cobbs.Fn fetchPutHTTP "struct url *u" "const char *flags"
110d8acd8dcSDag-Erling Smørgrav.Ft int
11138c7e4a6SArchie Cobbs.Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags"
112ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
11338c7e4a6SArchie Cobbs.Fn fetchListHTTP "struct url *u" "const char *flags"
1144ca1ab94SDag-Erling Smørgrav.Ft FILE *
11538c7e4a6SArchie Cobbs.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags"
1161a5faa10SDag-Erling Smørgrav.Ft FILE *
11738c7e4a6SArchie Cobbs.Fn fetchGetFTP "struct url *u" "const char *flags"
1184ca1ab94SDag-Erling Smørgrav.Ft FILE *
11938c7e4a6SArchie Cobbs.Fn fetchPutFTP "struct url *u" "const char *flags"
120d8acd8dcSDag-Erling Smørgrav.Ft int
12138c7e4a6SArchie Cobbs.Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags"
122ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
12338c7e4a6SArchie Cobbs.Fn fetchListFTP "struct url *u" "const char *flags"
1244ca1ab94SDag-Erling Smørgrav.Sh DESCRIPTION
1254ca1ab94SDag-Erling SmørgravThese functions implement a high-level library for retrieving and
1264ca1ab94SDag-Erling Smørgravuploading files using Uniform Resource Locators (URLs).
1274ca1ab94SDag-Erling Smørgrav.Pp
12860245e42SDag-Erling Smørgrav.Fn fetchParseURL
12960245e42SDag-Erling Smørgravtakes a URL in the form of a null-terminated string and splits it into
13060245e42SDag-Erling Smørgravits components function according to the Common Internet Scheme Syntax
1319364c532SDag-Erling Smørgravdetailed in RFC1738.
1329364c532SDag-Erling SmørgravA regular expression which produces this syntax is:
13360245e42SDag-Erling Smørgrav.Bd -literal
13460245e42SDag-Erling Smørgrav    <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
13560245e42SDag-Erling Smørgrav.Ed
13660245e42SDag-Erling Smørgrav.Pp
1371df2031cSDag-Erling SmørgravIf the URL does not seem to begin with a scheme name, the following
1381df2031cSDag-Erling Smørgravsyntax is assumed:
1391df2031cSDag-Erling Smørgrav.Bd -literal
1401df2031cSDag-Erling Smørgrav    ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
1411df2031cSDag-Erling Smørgrav.Ed
1421df2031cSDag-Erling Smørgrav.Pp
14360245e42SDag-Erling SmørgravNote that some components of the URL are not necessarily relevant to
14460245e42SDag-Erling Smørgravall URL schemes.
1451df2031cSDag-Erling SmørgravFor instance, the file scheme only needs the <scheme> and <document>
1461df2031cSDag-Erling Smørgravcomponents.
14760245e42SDag-Erling Smørgrav.Pp
1489a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL
1499a964d6aSDag-Erling Smørgravand
15040ac2845SDag-Erling Smørgrav.Fn fetchParseURL
1519a964d6aSDag-Erling Smørgravreturn a pointer to a
152a7e16a9dSRuslan Ermilov.Vt url
15340ac2845SDag-Erling Smørgravstructure, which is defined as follows in
154fe08efe6SRuslan Ermilov.In fetch.h :
15540ac2845SDag-Erling Smørgrav.Bd -literal
15640ac2845SDag-Erling Smørgrav#define URL_SCHEMELEN 16
15740ac2845SDag-Erling Smørgrav#define URL_USERLEN 256
15840ac2845SDag-Erling Smørgrav#define URL_PWDLEN 256
15940ac2845SDag-Erling Smørgrav
16040ac2845SDag-Erling Smørgravstruct url {
16140ac2845SDag-Erling Smørgrav    char	 scheme[URL_SCHEMELEN+1];
16240ac2845SDag-Erling Smørgrav    char	 user[URL_USERLEN+1];
16340ac2845SDag-Erling Smørgrav    char	 pwd[URL_PWDLEN+1];
16440ac2845SDag-Erling Smørgrav    char	 host[MAXHOSTNAMELEN+1];
16540ac2845SDag-Erling Smørgrav    int		 port;
16640ac2845SDag-Erling Smørgrav    char	*doc;
16740ac2845SDag-Erling Smørgrav    off_t	 offset;
16840ac2845SDag-Erling Smørgrav    size_t	 length;
1697f92799fSMurray Stokely    time_t	 ims_time;
17040ac2845SDag-Erling Smørgrav};
17140ac2845SDag-Erling Smørgrav.Ed
17240ac2845SDag-Erling Smørgrav.Pp
1737f92799fSMurray StokelyThe
1747f92799fSMurray Stokely.Va ims_time
1757f92799fSMurray Stokelyfield stores the time value for
1767f92799fSMurray Stokely.Li If-Modified-Since
1777f92799fSMurray StokelyHTTP requests.
1787f92799fSMurray Stokely.Pp
17960245e42SDag-Erling SmørgravThe pointer returned by
1809a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL
1819a964d6aSDag-Erling Smørgravor
18260245e42SDag-Erling Smørgrav.Fn fetchParseURL
18360245e42SDag-Erling Smørgravshould be freed using
18460245e42SDag-Erling Smørgrav.Fn fetchFreeURL .
18560245e42SDag-Erling Smørgrav.Pp
1861a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL ,
1871a5faa10SDag-Erling Smørgrav.Fn fetchGetURL ,
188db5f8cebSDag-Erling Smørgravand
189db5f8cebSDag-Erling Smørgrav.Fn fetchPutURL
190db5f8cebSDag-Erling Smørgravconstitute the recommended interface to the
191db5f8cebSDag-Erling Smørgrav.Nm fetch
192c6ff3a1bSSheldon Hearnlibrary.
193c6ff3a1bSSheldon HearnThey examine the URL passed to them to determine the transfer
194db5f8cebSDag-Erling Smørgravmethod, and call the appropriate lower-level functions to perform the
195c6ff3a1bSSheldon Hearnactual transfer.
1961a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL
1971a5faa10SDag-Erling Smørgravalso returns the remote document's metadata in the
198a7e16a9dSRuslan Ermilov.Vt url_stat
1991a5faa10SDag-Erling Smørgravstructure pointed to by the
2001a5faa10SDag-Erling Smørgrav.Fa us
2011a5faa10SDag-Erling Smørgravargument.
2021a5faa10SDag-Erling Smørgrav.Pp
203c6ff3a1bSSheldon HearnThe
204db5f8cebSDag-Erling Smørgrav.Fa flags
205c6ff3a1bSSheldon Hearnargument is a string of characters which specify transfer options.
206c6ff3a1bSSheldon HearnThe
207db5f8cebSDag-Erling Smørgravmeaning of the individual flags is scheme-dependent, and is detailed
208db5f8cebSDag-Erling Smørgravin the appropriate section below.
209db5f8cebSDag-Erling Smørgrav.Pp
210d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL
211d8acd8dcSDag-Erling Smørgravattempts to obtain the requested document's metadata and fill in the
2125e75e35cSDima Dorfmanstructure pointed to by its second argument.
213c6ff3a1bSSheldon HearnThe
214a7e16a9dSRuslan Ermilov.Vt url_stat
215d8acd8dcSDag-Erling Smørgravstructure is defined as follows in
216fe08efe6SRuslan Ermilov.In fetch.h :
217d8acd8dcSDag-Erling Smørgrav.Bd -literal
218d8acd8dcSDag-Erling Smørgravstruct url_stat {
219d8acd8dcSDag-Erling Smørgrav    off_t	 size;
2205aea254fSDag-Erling Smørgrav    time_t	 atime;
2215aea254fSDag-Erling Smørgrav    time_t	 mtime;
222d8acd8dcSDag-Erling Smørgrav};
223d8acd8dcSDag-Erling Smørgrav.Ed
224d8acd8dcSDag-Erling Smørgrav.Pp
22540ac2845SDag-Erling SmørgravIf the size could not be obtained from the server, the
22640ac2845SDag-Erling Smørgrav.Fa size
22740ac2845SDag-Erling Smørgravfield is set to -1.
22840ac2845SDag-Erling SmørgravIf the modification time could not be obtained from the server, the
22940ac2845SDag-Erling Smørgrav.Fa mtime
23040ac2845SDag-Erling Smørgravfield is set to the epoch.
23140ac2845SDag-Erling SmørgravIf the access time could not be obtained from the server, the
23240ac2845SDag-Erling Smørgrav.Fa atime
23340ac2845SDag-Erling Smørgravfield is set to the modification time.
23440ac2845SDag-Erling Smørgrav.Pp
235ce71b736SDag-Erling Smørgrav.Fn fetchListURL
236ce71b736SDag-Erling Smørgravattempts to list the contents of the directory pointed to by the URL
237c6ff3a1bSSheldon Hearnprovided.
238c6ff3a1bSSheldon HearnIf successful, it returns a malloced array of
239a7e16a9dSRuslan Ermilov.Vt url_ent
240c6ff3a1bSSheldon Hearnstructures.
241c6ff3a1bSSheldon HearnThe
242a7e16a9dSRuslan Ermilov.Vt url_ent
243ce71b736SDag-Erling Smørgravstructure is defined as follows in
244fe08efe6SRuslan Ermilov.In fetch.h :
245ce71b736SDag-Erling Smørgrav.Bd -literal
246ce71b736SDag-Erling Smørgravstruct url_ent {
247e97f516cSDag-Erling Smørgrav    char         name[PATH_MAX];
248ce71b736SDag-Erling Smørgrav    struct url_stat stat;
249ce71b736SDag-Erling Smørgrav};
250ce71b736SDag-Erling Smørgrav.Ed
251ce71b736SDag-Erling Smørgrav.Pp
252ce71b736SDag-Erling SmørgravThe list is terminated by an entry with an empty name.
253ce71b736SDag-Erling Smørgrav.Pp
254ce71b736SDag-Erling SmørgravThe pointer returned by
255ce71b736SDag-Erling Smørgrav.Fn fetchListURL
256ce71b736SDag-Erling Smørgravshould be freed using
257ce71b736SDag-Erling Smørgrav.Fn free .
258ce71b736SDag-Erling Smørgrav.Pp
2591a5faa10SDag-Erling Smørgrav.Fn fetchXGet ,
260d8acd8dcSDag-Erling Smørgrav.Fn fetchGet ,
261db5f8cebSDag-Erling Smørgrav.Fn fetchPut
2624ca1ab94SDag-Erling Smørgravand
263d8acd8dcSDag-Erling Smørgrav.Fn fetchStat
264d8acd8dcSDag-Erling Smørgravare similar to
2651a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL ,
266d8acd8dcSDag-Erling Smørgrav.Fn fetchGetURL ,
267d8acd8dcSDag-Erling Smørgrav.Fn fetchPutURL
268d8acd8dcSDag-Erling Smørgravand
269d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL ,
270db5f8cebSDag-Erling Smørgravexcept that they expect a pre-parsed URL in the form of a pointer to
271d8acd8dcSDag-Erling Smørgrava
272a7e16a9dSRuslan Ermilov.Vt struct url
273d8acd8dcSDag-Erling Smørgravrather than a string.
2744ca1ab94SDag-Erling Smørgrav.Pp
2754ca1ab94SDag-Erling SmørgravAll of the
2761a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX ,
2774ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX
2784ca1ab94SDag-Erling Smørgravand
2794ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX
2804ca1ab94SDag-Erling Smørgravfunctions return a pointer to a stream which can be used to read or
281c6ff3a1bSSheldon Hearnwrite data from or to the requested document, respectively.
282c6ff3a1bSSheldon HearnNote that
2834ca1ab94SDag-Erling Smørgravalthough the implementation details of the individual access methods
2844ca1ab94SDag-Erling Smørgravvary, it can generally be assumed that a stream returned by one of the
2851a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX
2861a5faa10SDag-Erling Smørgravor
2874ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX
2884ca1ab94SDag-Erling Smørgravfunctions is read-only, and that a stream returned by one of the
2894ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX
2904ca1ab94SDag-Erling Smørgravfunctions is write-only.
2914ca1ab94SDag-Erling Smørgrav.Sh FILE SCHEME
2921a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile ,
2934ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile
2944ca1ab94SDag-Erling Smørgravand
2954ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile
2964ca1ab94SDag-Erling Smørgravprovide access to documents which are files in a locally mounted file
297c6ff3a1bSSheldon Hearnsystem.
298c6ff3a1bSSheldon HearnOnly the <document> component of the URL is used.
2994ca1ab94SDag-Erling Smørgrav.Pp
3001a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile
3011a5faa10SDag-Erling Smørgravand
3024ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile
3031a5faa10SDag-Erling Smørgravdo not accept any flags.
3044ca1ab94SDag-Erling Smørgrav.Pp
3054ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile
3064ca1ab94SDag-Erling Smørgravaccepts the
307a7e16a9dSRuslan Ermilov.Ql a
308c6ff3a1bSSheldon Hearn(append to file) flag.
309c6ff3a1bSSheldon HearnIf that flag is specified, the data written to
3104ca1ab94SDag-Erling Smørgravthe stream returned by
3114ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile
3124ca1ab94SDag-Erling Smørgravwill be appended to the previous contents of the file, instead of
3134ca1ab94SDag-Erling Smørgravreplacing them.
3144ca1ab94SDag-Erling Smørgrav.Sh FTP SCHEME
3151a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP ,
3164ca1ab94SDag-Erling Smørgrav.Fn fetchGetFTP
3174ca1ab94SDag-Erling Smørgravand
3184ca1ab94SDag-Erling Smørgrav.Fn fetchPutFTP
3194ca1ab94SDag-Erling Smørgravimplement the FTP protocol as described in RFC959.
3204ca1ab94SDag-Erling Smørgrav.Pp
3214ca1ab94SDag-Erling SmørgravIf the
322ecd18c96SDag-Erling Smørgrav.Ql P
323ecd18c96SDag-Erling Smørgrav(not passive) flag is specified, an active (rather than passive)
324ecd18c96SDag-Erling Smørgravconnection will be attempted.
325ecd18c96SDag-Erling Smørgrav.Pp
326ecd18c96SDag-Erling SmørgravThe
327a7e16a9dSRuslan Ermilov.Ql p
328ecd18c96SDag-Erling Smørgravflag is supported for compatibility with earlier versions where active
329ecd18c96SDag-Erling Smørgravconnections were the default.
330ecd18c96SDag-Erling SmørgravIt has precedence over the
331ecd18c96SDag-Erling Smørgrav.Ql P
332ecd18c96SDag-Erling Smørgravflag, so if both are specified,
333ecd18c96SDag-Erling Smørgrav.Nm
334ecd18c96SDag-Erling Smørgravwill use a passive connection.
3354ca1ab94SDag-Erling Smørgrav.Pp
336f5f109a0SDag-Erling SmørgravIf the
337a7e16a9dSRuslan Ermilov.Ql l
338d5f175ceSDag-Erling Smørgrav(low) flag is specified, data sockets will be allocated in the low (or
339d5c24aa8SBill Fennerdefault) port range instead of the high port range (see
340f5f109a0SDag-Erling Smørgrav.Xr ip 4 ) .
341f5f109a0SDag-Erling Smørgrav.Pp
342f5f109a0SDag-Erling SmørgravIf the
343a7e16a9dSRuslan Ermilov.Ql d
344f5f109a0SDag-Erling Smørgrav(direct) flag is specified,
3451a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP ,
346f5f109a0SDag-Erling Smørgrav.Fn fetchGetFTP
347f5f109a0SDag-Erling Smørgravand
348f5f109a0SDag-Erling Smørgrav.Fn fetchPutFTP
349f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined.
350f5f109a0SDag-Erling Smørgrav.Pp
3514ca1ab94SDag-Erling SmørgravIf no user name or password is given, the
3524ca1ab94SDag-Erling Smørgrav.Nm fetch
353c86c6f74SDag-Erling Smørgravlibrary will attempt an anonymous login, with user name "anonymous"
354c86c6f74SDag-Erling Smørgravand password "anonymous@<hostname>".
3554ca1ab94SDag-Erling Smørgrav.Sh HTTP SCHEME
3564ca1ab94SDag-Erling SmørgravThe
3571a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP ,
3584ca1ab94SDag-Erling Smørgrav.Fn fetchGetHTTP
3594ca1ab94SDag-Erling Smørgravand
3604ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP
361c6ff3a1bSSheldon Hearnfunctions implement the HTTP/1.1 protocol.
36236a142c4SRuslan ErmilovWith a little luck, there is
36306b533d3SDag-Erling Smørgraveven a chance that they comply with RFC2616 and RFC2617.
3644ca1ab94SDag-Erling Smørgrav.Pp
365f5f109a0SDag-Erling SmørgravIf the
366a7e16a9dSRuslan Ermilov.Ql d
367f5f109a0SDag-Erling Smørgrav(direct) flag is specified,
3681a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP ,
369f5f109a0SDag-Erling Smørgrav.Fn fetchGetHTTP
370f5f109a0SDag-Erling Smørgravand
371f5f109a0SDag-Erling Smørgrav.Fn fetchPutHTTP
372f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined.
373f5f109a0SDag-Erling Smørgrav.Pp
3747f92799fSMurray StokelyIf the
3757f92799fSMurray Stokely.Ql i
3767f92799fSMurray Stokely(if-modified-since) flag is specified, and
3777f92799fSMurray Stokelythe
3787f92799fSMurray Stokely.Va ims_time
3797f92799fSMurray Stokelyfield is set in
3807f92799fSMurray Stokely.Vt "struct url" ,
3817f92799fSMurray Stokelythen
3827f92799fSMurray Stokely.Fn fetchXGetHTTP
3837f92799fSMurray Stokelyand
3847f92799fSMurray Stokely.Fn fetchGetHTTP
3857f92799fSMurray Stokelywill send a conditional
3867f92799fSMurray Stokely.Li If-Modified-Since
3877f92799fSMurray StokelyHTTP header to only fetch the content if it is newer than
3887f92799fSMurray Stokely.Va ims_time .
3897f92799fSMurray Stokely.Pp
3904ca1ab94SDag-Erling SmørgravSince there seems to be no good way of implementing the HTTP PUT
3914ca1ab94SDag-Erling Smørgravmethod in a manner consistent with the rest of the
3924ca1ab94SDag-Erling Smørgrav.Nm fetch
3934ca1ab94SDag-Erling Smørgravlibrary,
3944ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP
3954ca1ab94SDag-Erling Smørgravis currently unimplemented.
396dcd47379SDag-Erling Smørgrav.Sh HTTPS SCHEME
397dcd47379SDag-Erling SmørgravBased on HTTP SCHEME.
398dcd47379SDag-Erling SmørgravBy default the peer is verified using the CA bundle located in
399dcd47379SDag-Erling Smørgrav.Pa /etc/ssl/cert.pem .
400dcd47379SDag-Erling SmørgravThe file may contain multiple CA certificates.
401dcd47379SDag-Erling SmørgravA common source of a current CA bundle is
402dcd47379SDag-Erling Smørgrav.Pa \%security/ca_root_nss .
403dcd47379SDag-Erling Smørgrav.Pp
404dcd47379SDag-Erling SmørgravThe CA bundle used for peer verification can be changed by setting the
405dcd47379SDag-Erling Smørgravenvironment variables
406dcd47379SDag-Erling Smørgrav.Ev SSL_CA_CERT_FILE
407dcd47379SDag-Erling Smørgravto point to a concatenated bundle of trusted certificates and
408dcd47379SDag-Erling Smørgrav.Ev SSL_CA_CERT_PATH
409dcd47379SDag-Erling Smørgravto point to a directory containing hashes of trusted CAs (see
410dcd47379SDag-Erling Smørgrav.Xr verify 1 ) .
411dcd47379SDag-Erling Smørgrav.Pp
412dcd47379SDag-Erling SmørgravA certificate revocation list (CRL) can be used by setting the
413dcd47379SDag-Erling Smørgravenvironment variable
414dcd47379SDag-Erling Smørgrav.Ev SSL_CRL_FILE
415dcd47379SDag-Erling Smørgrav(see
416dcd47379SDag-Erling Smørgrav.Xr crl 1 ) .
417dcd47379SDag-Erling Smørgrav.Pp
418dcd47379SDag-Erling SmørgravPeer verification can be disabled by setting the environment variable
419dcd47379SDag-Erling Smørgrav.Ev SSL_NO_VERIFY_PEER .
420dcd47379SDag-Erling SmørgravNote that this also disables CRL checking.
421dcd47379SDag-Erling Smørgrav.Pp
422dcd47379SDag-Erling SmørgravBy default the service identity is verified according to the rules
423dcd47379SDag-Erling Smørgravdetailed in RFC6125 (also known as hostname verification).
424dcd47379SDag-Erling SmørgravThis feature can be disabled by setting the environment variable
425dcd47379SDag-Erling Smørgrav.Ev SSL_NO_VERIFY_HOSTNAME .
426dcd47379SDag-Erling Smørgrav.Pp
427dcd47379SDag-Erling SmørgravClient certificate based authentication is supported.
428dcd47379SDag-Erling SmørgravThe environment variable
429dcd47379SDag-Erling Smørgrav.Ev SSL_CLIENT_CERT_FILE
430dcd47379SDag-Erling Smørgravshould be set to point to a file containing key and client certificate
431dcd47379SDag-Erling Smørgravto be used in PEM format. In case the key is stored in a separate
432dcd47379SDag-Erling Smørgravfile, the environment variable
433dcd47379SDag-Erling Smørgrav.Ev SSL_CLIENT_KEY_FILE
434dcd47379SDag-Erling Smørgravcan be set to point to the key in PEM format.
435dcd47379SDag-Erling SmørgravIn case the key uses a password, the user will be prompted on standard
436dcd47379SDag-Erling Smørgravinput (see
437dcd47379SDag-Erling Smørgrav.Xr PEM 3 ) .
438dcd47379SDag-Erling Smørgrav.Pp
439dcd47379SDag-Erling SmørgravBy default
440dcd47379SDag-Erling Smørgrav.Nm libfetch
44176720765SDag-Erling Smørgravallows TLSv1 and newer when negotiating the connecting with the remote
442dcd47379SDag-Erling Smørgravpeer.
44376720765SDag-Erling SmørgravYou can change this behavior by setting the
44476720765SDag-Erling Smørgrav.Ev SSL_ALLOW_SSL3
445*01ed3ca3SJung-uk Kimenvironment variable to allow SSLv3 and
44676720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1 ,
44776720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1_1 and
44876720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1_2
44976720765SDag-Erling Smørgravto disable TLS 1.0, 1.1 and 1.2 respectively.
45006b533d3SDag-Erling Smørgrav.Sh AUTHENTICATION
45106b533d3SDag-Erling SmørgravApart from setting the appropriate environment variables and
45206b533d3SDag-Erling Smørgravspecifying the user name and password in the URL or the
453a7e16a9dSRuslan Ermilov.Vt struct url ,
45406b533d3SDag-Erling Smørgravthe calling program has the option of defining an authentication
45506b533d3SDag-Erling Smørgravfunction with the following prototype:
45606b533d3SDag-Erling Smørgrav.Pp
45706b533d3SDag-Erling Smørgrav.Ft int
45806b533d3SDag-Erling Smørgrav.Fn myAuthMethod "struct url *u"
45906b533d3SDag-Erling Smørgrav.Pp
46006b533d3SDag-Erling SmørgravThe callback function should fill in the
46106b533d3SDag-Erling Smørgrav.Fa user
46206b533d3SDag-Erling Smørgravand
46306b533d3SDag-Erling Smørgrav.Fa pwd
46406b533d3SDag-Erling Smørgravfields in the provided
465a7e16a9dSRuslan Ermilov.Vt struct url
46606b533d3SDag-Erling Smørgravand return 0 on success, or any other value to indicate failure.
46706b533d3SDag-Erling Smørgrav.Pp
46806b533d3SDag-Erling SmørgravTo register the authentication callback, simply set
469a7e16a9dSRuslan Ermilov.Va fetchAuthMethod
47006b533d3SDag-Erling Smørgravto point at it.
47106b533d3SDag-Erling SmørgravThe callback will be used whenever a site requires authentication and
4720227791bSRuslan Ermilovthe appropriate environment variables are not set.
47306b533d3SDag-Erling Smørgrav.Pp
47406b533d3SDag-Erling SmørgravThis interface is experimental and may be subject to change.
4754ca1ab94SDag-Erling Smørgrav.Sh RETURN VALUES
4764ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL
4774ca1ab94SDag-Erling Smørgravreturns a pointer to a
478a7e16a9dSRuslan Ermilov.Vt struct url
479c6ff3a1bSSheldon Hearncontaining the individual components of the URL.
480c6ff3a1bSSheldon HearnIf it is
4814ca1ab94SDag-Erling Smørgravunable to allocate memory, or the URL is syntactically incorrect,
4824ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL
4834ca1ab94SDag-Erling Smørgravreturns a NULL pointer.
4844ca1ab94SDag-Erling Smørgrav.Pp
485d8acd8dcSDag-Erling SmørgravThe
486d8acd8dcSDag-Erling Smørgrav.Fn fetchStat
487d8acd8dcSDag-Erling Smørgravfunctions return 0 on success and -1 on failure.
488d8acd8dcSDag-Erling Smørgrav.Pp
4894ca1ab94SDag-Erling SmørgravAll other functions return a stream pointer which may be used to
490d8acd8dcSDag-Erling Smørgravaccess the requested document, or NULL if an error occurred.
491d8acd8dcSDag-Erling Smørgrav.Pp
492ba101983SDag-Erling SmørgravThe following error codes are defined in
493fe08efe6SRuslan Ermilov.In fetch.h :
49415efcd39SAlexey Zelkin.Bl -tag -width 18n
495d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_ABORT
496d8acd8dcSDag-Erling SmørgravOperation aborted
497d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_AUTH
498d8acd8dcSDag-Erling SmørgravAuthentication failed
499d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_DOWN
500d8acd8dcSDag-Erling SmørgravService unavailable
501d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_EXISTS
502d8acd8dcSDag-Erling SmørgravFile exists
503d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_FULL
504d8acd8dcSDag-Erling SmørgravFile system full
505d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_INFO
506d8acd8dcSDag-Erling SmørgravInformational response
507d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MEMORY
508d8acd8dcSDag-Erling SmørgravInsufficient memory
509d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MOVED
510d8acd8dcSDag-Erling SmørgravFile has moved
511d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_NETWORK
512d8acd8dcSDag-Erling SmørgravNetwork error
513d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_OK
514d8acd8dcSDag-Erling SmørgravNo error
515d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_PROTO
516d8acd8dcSDag-Erling SmørgravProtocol error
517d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_RESOLV
518d8acd8dcSDag-Erling SmørgravResolver error
519d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_SERVER
520d8acd8dcSDag-Erling SmørgravServer error
521d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TEMP
522d8acd8dcSDag-Erling SmørgravTemporary error
523d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TIMEOUT
524d8acd8dcSDag-Erling SmørgravOperation timed out
525d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNAVAIL
526d8acd8dcSDag-Erling SmørgravFile is not available
527d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNKNOWN
528d8acd8dcSDag-Erling SmørgravUnknown error
529d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_URL
530d8acd8dcSDag-Erling SmørgravInvalid URL
531d8acd8dcSDag-Erling Smørgrav.El
532d8acd8dcSDag-Erling Smørgrav.Pp
533d8acd8dcSDag-Erling SmørgravThe accompanying error message includes a protocol-specific error code
5341a0a9345SRuslan Ermilovand message, e.g.\& "File is not available (404 Not Found)"
5354ca1ab94SDag-Erling Smørgrav.Sh ENVIRONMENT
5363a5146d9SRuslan Ermilov.Bl -tag -width ".Ev FETCH_BIND_ADDRESS"
537c42cb9d9SDag-Erling Smørgrav.It Ev FETCH_BIND_ADDRESS
538c42cb9d9SDag-Erling SmørgravSpecifies a hostname or IP address to which sockets used for outgoing
539c42cb9d9SDag-Erling Smørgravconnections will be bound.
540659e0d5eSDag-Erling Smørgrav.It Ev FTP_LOGIN
541659e0d5eSDag-Erling SmørgravDefault FTP login if none was provided in the URL.
54291c51046SDag-Erling Smørgrav.It Ev FTP_PASSIVE_MODE
543ecd18c96SDag-Erling SmørgravIf set to
5446c81eb52SDag-Erling Smørgrav.Ql no ,
545ecd18c96SDag-Erling Smørgravforces the FTP code to use active mode.
546ecd18c96SDag-Erling SmørgravIf set to any other value, forces passive mode even if the application
547ecd18c96SDag-Erling Smørgravrequested active mode.
54891c51046SDag-Erling Smørgrav.It Ev FTP_PASSWORD
54991c51046SDag-Erling SmørgravDefault FTP password if the remote server requests one and none was
55091c51046SDag-Erling Smørgravprovided in the URL.
551bc2a5e68SDag-Erling Smørgrav.It Ev FTP_PROXY
5521df2031cSDag-Erling SmørgravURL of the proxy to use for FTP requests.
5531df2031cSDag-Erling SmørgravThe document part is ignored.
5541df2031cSDag-Erling SmørgravFTP and HTTP proxies are supported; if no scheme is specified, FTP is
5551df2031cSDag-Erling Smørgravassumed.
5561df2031cSDag-Erling SmørgravIf the proxy is an FTP proxy,
557e0a9ca38SDag-Erling Smørgrav.Nm libfetch
558e0a9ca38SDag-Erling Smørgravwill send
559e0a9ca38SDag-Erling Smørgrav.Ql user@host
560e0a9ca38SDag-Erling Smørgravas user name to the proxy, where
561e0a9ca38SDag-Erling Smørgrav.Ql user
562e0a9ca38SDag-Erling Smørgravis the real user name, and
563e0a9ca38SDag-Erling Smørgrav.Ql host
564e0a9ca38SDag-Erling Smørgravis the name of the FTP server.
56589d755e1SDag-Erling Smørgrav.Pp
5662e83f638SDag-Erling SmørgravIf this variable is set to an empty string, no proxy will be used for
5672e83f638SDag-Erling SmørgravFTP requests, even if the
5682e83f638SDag-Erling Smørgrav.Ev HTTP_PROXY
5692e83f638SDag-Erling Smørgravvariable is set.
5704cee73c8SDag-Erling Smørgrav.It Ev ftp_proxy
5714cee73c8SDag-Erling SmørgravSame as
5724cee73c8SDag-Erling Smørgrav.Ev FTP_PROXY ,
5734cee73c8SDag-Erling Smørgravfor compatibility.
5741453595fSDag-Erling Smørgrav.It Ev HTTP_ACCEPT
5751453595fSDag-Erling SmørgravSpecifies the value of the
5761453595fSDag-Erling Smørgrav.Va Accept
5771453595fSDag-Erling Smørgravheader for HTTP requests.
5781453595fSDag-Erling SmørgravIf empty, no
5791453595fSDag-Erling Smørgrav.Va Accept
5801453595fSDag-Erling Smørgravheader is sent.
5811453595fSDag-Erling SmørgravThe default is
5821453595fSDag-Erling Smørgrav.Dq */* .
58398f5573fSDag-Erling Smørgrav.It Ev HTTP_AUTH
58489d755e1SDag-Erling SmørgravSpecifies HTTP authorization parameters as a colon-separated list of
58589d755e1SDag-Erling Smørgravitems.
58698f5573fSDag-Erling SmørgravThe first and second item are the authorization scheme and realm
58798f5573fSDag-Erling Smørgravrespectively; further items are scheme-dependent.
58878122aacSDag-Erling SmørgravCurrently, the
58978122aacSDag-Erling Smørgrav.Dq basic
59078122aacSDag-Erling Smørgravand
59178122aacSDag-Erling Smørgrav.Dq digest
59278122aacSDag-Erling Smørgravauthorization methods are supported.
59389d755e1SDag-Erling Smørgrav.Pp
59478122aacSDag-Erling SmørgravBoth methods require two parameters: the user name and
59598f5573fSDag-Erling Smørgravpassword, in that order.
59689d755e1SDag-Erling Smørgrav.Pp
59789d755e1SDag-Erling SmørgravThis variable is only used if the server requires authorization and
59889d755e1SDag-Erling Smørgravno user name or password was specified in the URL.
599bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY
6001df2031cSDag-Erling SmørgravURL of the proxy to use for HTTP requests.
6011df2031cSDag-Erling SmørgravThe document part is ignored.
6021df2031cSDag-Erling SmørgravOnly HTTP proxies are supported for HTTP requests.
603bc2a5e68SDag-Erling SmørgravIf no port number is specified, the default is 3128.
60489d755e1SDag-Erling Smørgrav.Pp
6051df2031cSDag-Erling SmørgravNote that this proxy will also be used for FTP documents, unless the
606e0a9ca38SDag-Erling Smørgrav.Ev FTP_PROXY
607e0a9ca38SDag-Erling Smørgravvariable is set.
6084cee73c8SDag-Erling Smørgrav.It Ev http_proxy
6094cee73c8SDag-Erling SmørgravSame as
6104cee73c8SDag-Erling Smørgrav.Ev HTTP_PROXY ,
6114cee73c8SDag-Erling Smørgravfor compatibility.
612bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY_AUTH
61398f5573fSDag-Erling SmørgravSpecifies authorization parameters for the HTTP proxy in the same
614e0a9ca38SDag-Erling Smørgravformat as the
615e0a9ca38SDag-Erling Smørgrav.Ev HTTP_AUTH
616e0a9ca38SDag-Erling Smørgravvariable.
61789d755e1SDag-Erling Smørgrav.Pp
6181df2031cSDag-Erling SmørgravThis variable is used if and only if connected to an HTTP proxy, and
6191df2031cSDag-Erling Smørgravis ignored if a user and/or a password were specified in the proxy
6201df2031cSDag-Erling SmørgravURL.
621d5216a4fSDag-Erling Smørgrav.It Ev HTTP_REFERER
62257bd0fc6SJens SchweikhardtSpecifies the referrer URL to use for HTTP requests.
623d5216a4fSDag-Erling SmørgravIf set to
624d5216a4fSDag-Erling Smørgrav.Dq auto ,
62557bd0fc6SJens Schweikhardtthe document URL will be used as referrer URL.
6266a0cf64bSDag-Erling Smørgrav.It Ev HTTP_USER_AGENT
6276a0cf64bSDag-Erling SmørgravSpecifies the User-Agent string to use for HTTP requests.
6286a0cf64bSDag-Erling SmørgravThis can be useful when working with HTTP origin or proxy servers that
629a7e16a9dSRuslan Ermilovdifferentiate between user agents.
630c257f99eSDag-Erling SmørgravIf defined but empty, no User-Agent header is sent.
6310ab4a51eSDag-Erling Smørgrav.It Ev NETRC
6320ab4a51eSDag-Erling SmørgravSpecifies a file to use instead of
6330ab4a51eSDag-Erling Smørgrav.Pa ~/.netrc
6340ab4a51eSDag-Erling Smørgravto look up login names and passwords for FTP sites.
6350ab4a51eSDag-Erling SmørgravSee
6360ab4a51eSDag-Erling Smørgrav.Xr ftp 1
6370ab4a51eSDag-Erling Smørgravfor a description of the file format.
6380ab4a51eSDag-Erling SmørgravThis feature is experimental.
639e99ace35SDag-Erling Smørgrav.It Ev NO_PROXY
640e99ace35SDag-Erling SmørgravEither a single asterisk, which disables the use of proxies
641e99ace35SDag-Erling Smørgravaltogether, or a comma- or whitespace-separated list of hosts for
642e99ace35SDag-Erling Smørgravwhich proxies should not be used.
643e99ace35SDag-Erling Smørgrav.It Ev no_proxy
644e99ace35SDag-Erling SmørgravSame as
645e99ace35SDag-Erling Smørgrav.Ev NO_PROXY ,
646e99ace35SDag-Erling Smørgravfor compatibility.
64776720765SDag-Erling Smørgrav.It Ev SSL_ALLOW_SSL3
64876720765SDag-Erling SmørgravAllow SSL version 3 when negotiating the connection (not recommended).
649dcd47379SDag-Erling Smørgrav.It Ev SSL_CA_CERT_FILE
650dcd47379SDag-Erling SmørgravCA certificate bundle containing trusted CA certificates.
651dcd47379SDag-Erling SmørgravDefault value:
652dcd47379SDag-Erling Smørgrav.Pa /etc/ssl/cert.pem .
653dcd47379SDag-Erling Smørgrav.It Ev SSL_CA_CERT_PATH
654dcd47379SDag-Erling SmørgravPath containing trusted CA hashes.
655dcd47379SDag-Erling Smørgrav.It Ev SSL_CLIENT_CERT_FILE
656dcd47379SDag-Erling SmørgravPEM encoded client certificate/key which will be used in
657dcd47379SDag-Erling Smørgravclient certificate authentication.
658dcd47379SDag-Erling Smørgrav.It Ev SSL_CLIENT_KEY_FILE
659dcd47379SDag-Erling SmørgravPEM encoded client key in case key and client certificate
660dcd47379SDag-Erling Smørgravare stored separately.
661dcd47379SDag-Erling Smørgrav.It Ev SSL_CRL_FILE
662dcd47379SDag-Erling SmørgravFile containing certificate revocation list.
663dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_TLS1
66476720765SDag-Erling SmørgravDo not allow TLS version 1.0 when negotiating the connection.
66576720765SDag-Erling Smørgrav.It Ev SSL_NO_TLS1_1
66676720765SDag-Erling SmørgravDo not allow TLS version 1.1 when negotiating the connection.
66776720765SDag-Erling Smørgrav.It Ev SSL_NO_TLS1_2
66876720765SDag-Erling SmørgravDo not allow TLS version 1.2 when negotiating the connection.
669dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_VERIFY_HOSTNAME
670dcd47379SDag-Erling SmørgravIf set, do not verify that the hostname matches the subject of the
671dcd47379SDag-Erling Smørgravcertificate presented by the server.
672dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_VERIFY_PEER
673dcd47379SDag-Erling SmørgravIf set, do not verify the peer certificate against trusted CAs.
674bc2a5e68SDag-Erling Smørgrav.El
6750315901cSTom Rhodes.Sh EXAMPLES
6760315901cSTom RhodesTo access a proxy server on
6770315901cSTom Rhodes.Pa proxy.example.com
6780315901cSTom Rhodesport 8080, set the
6790315901cSTom Rhodes.Ev HTTP_PROXY
6800315901cSTom Rhodesenvironment variable in a manner similar to this:
6810315901cSTom Rhodes.Pp
6820315901cSTom Rhodes.Dl HTTP_PROXY=http://proxy.example.com:8080
6830315901cSTom Rhodes.Pp
6840315901cSTom RhodesIf the proxy server requires authentication, there are
6850315901cSTom Rhodestwo options available for passing the authentication data.
6860315901cSTom RhodesThe first method is by using the proxy URL:
6870315901cSTom Rhodes.Pp
6880315901cSTom Rhodes.Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080
6890315901cSTom Rhodes.Pp
6900315901cSTom RhodesThe second method is by using the
6910315901cSTom Rhodes.Ev HTTP_PROXY_AUTH
6920315901cSTom Rhodesenvironment variable:
6930315901cSTom Rhodes.Bd -literal -offset indent
6940315901cSTom RhodesHTTP_PROXY=http://proxy.example.com:8080
6950315901cSTom RhodesHTTP_PROXY_AUTH=basic:*:<user>:<pwd>
6960315901cSTom Rhodes.Ed
697e99ace35SDag-Erling Smørgrav.Pp
698e99ace35SDag-Erling SmørgravTo disable the use of a proxy for an HTTP server running on the local
699e99ace35SDag-Erling Smørgravhost, define
700e99ace35SDag-Erling Smørgrav.Ev NO_PROXY
701e99ace35SDag-Erling Smørgravas follows:
702e99ace35SDag-Erling Smørgrav.Bd -literal -offset indent
703e99ace35SDag-Erling SmørgravNO_PROXY=localhost,127.0.0.1
704e99ace35SDag-Erling Smørgrav.Ed
705dcd47379SDag-Erling Smørgrav.Pp
706dcd47379SDag-Erling SmørgravAccess HTTPS website without any certificate verification whatsoever:
707dcd47379SDag-Erling Smørgrav.Bd -literal -offset indent
708dcd47379SDag-Erling SmørgravSSL_NO_VERIFY_PEER=1
709dcd47379SDag-Erling SmørgravSSL_NO_VERIFY_HOSTNAME=1
710dcd47379SDag-Erling Smørgrav.Ed
711dcd47379SDag-Erling Smørgrav.Pp
712dcd47379SDag-Erling SmørgravAccess HTTPS website using client certificate based authentication
713dcd47379SDag-Erling Smørgravand a private CA:
714dcd47379SDag-Erling Smørgrav.Bd -literal -offset indent
715dcd47379SDag-Erling SmørgravSSL_CLIENT_CERT_FILE=/path/to/client.pem
716dcd47379SDag-Erling SmørgravSSL_CA_CERT_FILE=/path/to/myca.pem
717dcd47379SDag-Erling Smørgrav.Ed
7184ca1ab94SDag-Erling Smørgrav.Sh SEE ALSO
7194ca1ab94SDag-Erling Smørgrav.Xr fetch 1 ,
720f5f109a0SDag-Erling Smørgrav.Xr ftpio 3 ,
721c86c6f74SDag-Erling Smørgrav.Xr ip 4
722c86c6f74SDag-Erling Smørgrav.Rs
723c86c6f74SDag-Erling Smørgrav.%A J. Postel
724c86c6f74SDag-Erling Smørgrav.%A J. K. Reynolds
725c86c6f74SDag-Erling Smørgrav.%D October 1985
726c86c6f74SDag-Erling Smørgrav.%B File Transfer Protocol
727c86c6f74SDag-Erling Smørgrav.%O RFC959
728c86c6f74SDag-Erling Smørgrav.Re
729c86c6f74SDag-Erling Smørgrav.Rs
730c86c6f74SDag-Erling Smørgrav.%A P. Deutsch
731c86c6f74SDag-Erling Smørgrav.%A A. Emtage
732c86c6f74SDag-Erling Smørgrav.%A A. Marine.
733c86c6f74SDag-Erling Smørgrav.%D May 1994
734c86c6f74SDag-Erling Smørgrav.%T How to Use Anonymous FTP
735c86c6f74SDag-Erling Smørgrav.%O RFC1635
73698849115SRuslan Ermilov.Re
7374ca1ab94SDag-Erling Smørgrav.Rs
7380f5fcaa3SSheldon Hearn.%A T. Berners-Lee
7390f5fcaa3SSheldon Hearn.%A L. Masinter
7400f5fcaa3SSheldon Hearn.%A M. McCahill
7414ca1ab94SDag-Erling Smørgrav.%D December 1994
7424ca1ab94SDag-Erling Smørgrav.%T Uniform Resource Locators (URL)
7434ca1ab94SDag-Erling Smørgrav.%O RFC1738
7444ca1ab94SDag-Erling Smørgrav.Re
7454ca1ab94SDag-Erling Smørgrav.Rs
7460f5fcaa3SSheldon Hearn.%A R. Fielding
7470f5fcaa3SSheldon Hearn.%A J. Gettys
7480f5fcaa3SSheldon Hearn.%A J. Mogul
7490f5fcaa3SSheldon Hearn.%A H. Frystyk
75006b533d3SDag-Erling Smørgrav.%A L. Masinter
75106b533d3SDag-Erling Smørgrav.%A P. Leach
7520f5fcaa3SSheldon Hearn.%A T. Berners-Lee
753d5c24aa8SBill Fenner.%D January 1999
7544ca1ab94SDag-Erling Smørgrav.%B Hypertext Transfer Protocol -- HTTP/1.1
75506b533d3SDag-Erling Smørgrav.%O RFC2616
75606b533d3SDag-Erling Smørgrav.Re
75706b533d3SDag-Erling Smørgrav.Rs
75806b533d3SDag-Erling Smørgrav.%A J. Franks
75906b533d3SDag-Erling Smørgrav.%A P. Hallam-Baker
76006b533d3SDag-Erling Smørgrav.%A J. Hostetler
76106b533d3SDag-Erling Smørgrav.%A S. Lawrence
76206b533d3SDag-Erling Smørgrav.%A P. Leach
76306b533d3SDag-Erling Smørgrav.%A A. Luotonen
76406b533d3SDag-Erling Smørgrav.%A L. Stewart
76506b533d3SDag-Erling Smørgrav.%D June 1999
76606b533d3SDag-Erling Smørgrav.%B HTTP Authentication: Basic and Digest Access Authentication
76706b533d3SDag-Erling Smørgrav.%O RFC2617
7684ca1ab94SDag-Erling Smørgrav.Re
7694ca1ab94SDag-Erling Smørgrav.Sh HISTORY
7704ca1ab94SDag-Erling SmørgravThe
7714ca1ab94SDag-Erling Smørgrav.Nm fetch
7724ca1ab94SDag-Erling Smørgravlibrary first appeared in
7734ca1ab94SDag-Erling Smørgrav.Fx 3.0 .
7744ca1ab94SDag-Erling Smørgrav.Sh AUTHORS
775725ab628SRuslan Ermilov.An -nosplit
7764ca1ab94SDag-Erling SmørgravThe
7774ca1ab94SDag-Erling Smørgrav.Nm fetch
7784ca1ab94SDag-Erling Smørgravlibrary was mostly written by
7796cfac37bSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org
78078122aacSDag-Erling Smørgravwith numerous suggestions and contributions from
7816cfac37bSBaptiste Daroussin.An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org ,
7826cfac37bSBaptiste Daroussin.An Eugene Skepner Aq Mt eu@qub.com ,
7836cfac37bSBaptiste Daroussin.An Hajimu Umemoto Aq Mt ume@FreeBSD.org ,
7846cfac37bSBaptiste Daroussin.An Henry Whincup Aq Mt henry@techiebod.com ,
7856cfac37bSBaptiste Daroussin.An Jukka A. Ukkonen Aq Mt jau@iki.fi ,
7866cfac37bSBaptiste Daroussin.An Jean-Fran\(,cois Dockes Aq Mt jf@dockes.org ,
7876cfac37bSBaptiste Daroussin.An Michael Gmelin Aq Mt freebsd@grem.de
78878122aacSDag-Erling Smørgravand others.
789d8acd8dcSDag-Erling SmørgravIt replaces the older
7904ca1ab94SDag-Erling Smørgrav.Nm ftpio
791d8acd8dcSDag-Erling Smørgravlibrary written by
7926cfac37bSBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
793d8acd8dcSDag-Erling Smørgravand
7946cfac37bSBaptiste Daroussin.An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org .
7954ca1ab94SDag-Erling Smørgrav.Pp
7964ca1ab94SDag-Erling SmørgravThis manual page was written by
7976cfac37bSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org
798dcd47379SDag-Erling Smørgravand
7996cfac37bSBaptiste Daroussin.An Michael Gmelin Aq Mt freebsd@grem.de .
8004ca1ab94SDag-Erling Smørgrav.Sh BUGS
801c6ff3a1bSSheldon HearnSome parts of the library are not yet implemented.
802c6ff3a1bSSheldon HearnThe most notable
803d8acd8dcSDag-Erling Smørgravexamples of this are
804d8acd8dcSDag-Erling Smørgrav.Fn fetchPutHTTP ,
805ce71b736SDag-Erling Smørgrav.Fn fetchListHTTP ,
80615efcd39SAlexey Zelkin.Fn fetchListFTP
807d8acd8dcSDag-Erling Smørgravand FTP proxy support.
808d8acd8dcSDag-Erling Smørgrav.Pp
80936a142c4SRuslan ErmilovThere is no way to select a proxy at run-time other than setting the
810db5f8cebSDag-Erling Smørgrav.Ev HTTP_PROXY
811db5f8cebSDag-Erling Smørgravor
812db5f8cebSDag-Erling Smørgrav.Ev FTP_PROXY
813c6ff3a1bSSheldon Hearnenvironment variables as appropriate.
81498f5573fSDag-Erling Smørgrav.Pp
815842a95ccSDag-Erling Smørgrav.Nm libfetch
81698f5573fSDag-Erling Smørgravdoes not understand or obey 305 (Use Proxy) replies.
81798f5573fSDag-Erling Smørgrav.Pp
818842a95ccSDag-Erling SmørgravError numbers are unique only within a certain context; the error
819842a95ccSDag-Erling Smørgravcodes used for FTP and HTTP overlap, as do those used for resolver and
820c6ff3a1bSSheldon Hearnsystem errors.
821c6ff3a1bSSheldon HearnFor instance, error code 202 means "Command not
822842a95ccSDag-Erling Smørgravimplemented, superfluous at this site" in an FTP context and
823842a95ccSDag-Erling Smørgrav"Accepted" in an HTTP context.
824842a95ccSDag-Erling Smørgrav.Pp
825f5f109a0SDag-Erling Smørgrav.Fn fetchStatFTP
826f5f109a0SDag-Erling Smørgravdoes not check that the result of an MDTM command is a valid date.
827f5f109a0SDag-Erling Smørgrav.Pp
828dcd47379SDag-Erling SmørgravIn case password protected keys are used for client certificate based
829dcd47379SDag-Erling Smørgravauthentication the user is prompted for the password on each and every
830dcd47379SDag-Erling Smørgravfetch operation.
831dcd47379SDag-Erling Smørgrav.Pp
8321a5faa10SDag-Erling SmørgravThe man page is incomplete, poorly written and produces badly
8331a5faa10SDag-Erling Smørgravformatted text.
834db5f8cebSDag-Erling Smørgrav.Pp
835ba101983SDag-Erling SmørgravThe error reporting mechanism is unsatisfactory.
836ba101983SDag-Erling Smørgrav.Pp
837ba101983SDag-Erling SmørgravSome parts of the code are not fully reentrant.
838