12cbbf9daSDag-Erling Smørgrav.\"- 21453595fSDag-Erling Smørgrav.\" Copyright (c) 1998-2013 Dag-Erling Smørgrav 31ec923fdSMichael Gmelin.\" Copyright (c) 2013-2016 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.\" 29f4e05cc5SMark Johnston.Dd August 28, 2019 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 , 56f4e05cc5SMark Johnston.Nm fetchReqHTTP , 571a5faa10SDag-Erling Smørgrav.Nm fetchXGetFTP , 584ca1ab94SDag-Erling Smørgrav.Nm fetchGetFTP , 5915efcd39SAlexey Zelkin.Nm fetchPutFTP , 6015efcd39SAlexey Zelkin.Nm fetchStatFTP , 6115efcd39SAlexey Zelkin.Nm fetchListFTP 6215efcd39SAlexey Zelkin.Nd file transfer functions 6315efcd39SAlexey Zelkin.Sh LIBRARY 6415efcd39SAlexey Zelkin.Lb libfetch 654ca1ab94SDag-Erling Smørgrav.Sh SYNOPSIS 6632eef9aeSRuslan Ermilov.In sys/param.h 6732eef9aeSRuslan Ermilov.In stdio.h 6832eef9aeSRuslan Ermilov.In fetch.h 6960245e42SDag-Erling Smørgrav.Ft struct url * 7038c7e4a6SArchie Cobbs.Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd" 719a964d6aSDag-Erling Smørgrav.Ft struct url * 7238c7e4a6SArchie Cobbs.Fn fetchParseURL "const char *URL" 7360245e42SDag-Erling Smørgrav.Ft void 7438c7e4a6SArchie Cobbs.Fn fetchFreeURL "struct url *u" 75db5f8cebSDag-Erling Smørgrav.Ft FILE * 7638c7e4a6SArchie Cobbs.Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags" 771a5faa10SDag-Erling Smørgrav.Ft FILE * 7838c7e4a6SArchie Cobbs.Fn fetchGetURL "const char *URL" "const char *flags" 79db5f8cebSDag-Erling Smørgrav.Ft FILE * 8038c7e4a6SArchie Cobbs.Fn fetchPutURL "const char *URL" "const char *flags" 81d8acd8dcSDag-Erling Smørgrav.Ft int 8238c7e4a6SArchie Cobbs.Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags" 83ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 8438c7e4a6SArchie Cobbs.Fn fetchListURL "const char *URL" "const char *flags" 854ca1ab94SDag-Erling Smørgrav.Ft FILE * 8638c7e4a6SArchie Cobbs.Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags" 871a5faa10SDag-Erling Smørgrav.Ft FILE * 8838c7e4a6SArchie Cobbs.Fn fetchGet "struct url *u" "const char *flags" 89db5f8cebSDag-Erling Smørgrav.Ft FILE * 9038c7e4a6SArchie Cobbs.Fn fetchPut "struct url *u" "const char *flags" 91d8acd8dcSDag-Erling Smørgrav.Ft int 9238c7e4a6SArchie Cobbs.Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags" 93ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 9438c7e4a6SArchie Cobbs.Fn fetchList "struct url *u" "const char *flags" 95db5f8cebSDag-Erling Smørgrav.Ft FILE * 9638c7e4a6SArchie Cobbs.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags" 971a5faa10SDag-Erling Smørgrav.Ft FILE * 9838c7e4a6SArchie Cobbs.Fn fetchGetFile "struct url *u" "const char *flags" 994ca1ab94SDag-Erling Smørgrav.Ft FILE * 10038c7e4a6SArchie Cobbs.Fn fetchPutFile "struct url *u" "const char *flags" 101d8acd8dcSDag-Erling Smørgrav.Ft int 10238c7e4a6SArchie Cobbs.Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags" 103ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 10438c7e4a6SArchie Cobbs.Fn fetchListFile "struct url *u" "const char *flags" 1054ca1ab94SDag-Erling Smørgrav.Ft FILE * 10638c7e4a6SArchie Cobbs.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags" 1071a5faa10SDag-Erling Smørgrav.Ft FILE * 10838c7e4a6SArchie Cobbs.Fn fetchGetHTTP "struct url *u" "const char *flags" 1094ca1ab94SDag-Erling Smørgrav.Ft FILE * 11038c7e4a6SArchie Cobbs.Fn fetchPutHTTP "struct url *u" "const char *flags" 111d8acd8dcSDag-Erling Smørgrav.Ft int 11238c7e4a6SArchie Cobbs.Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags" 113ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 11438c7e4a6SArchie Cobbs.Fn fetchListHTTP "struct url *u" "const char *flags" 1154ca1ab94SDag-Erling Smørgrav.Ft FILE * 116f4e05cc5SMark Johnston.Fn fetchReqHTTP "struct url *u" "const char *method" "const char *flags" "const char *content_type" "const char *body" 117f4e05cc5SMark Johnston.Ft FILE * 11838c7e4a6SArchie Cobbs.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags" 1191a5faa10SDag-Erling Smørgrav.Ft FILE * 12038c7e4a6SArchie Cobbs.Fn fetchGetFTP "struct url *u" "const char *flags" 1214ca1ab94SDag-Erling Smørgrav.Ft FILE * 12238c7e4a6SArchie Cobbs.Fn fetchPutFTP "struct url *u" "const char *flags" 123d8acd8dcSDag-Erling Smørgrav.Ft int 12438c7e4a6SArchie Cobbs.Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags" 125ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 12638c7e4a6SArchie Cobbs.Fn fetchListFTP "struct url *u" "const char *flags" 1274ca1ab94SDag-Erling Smørgrav.Sh DESCRIPTION 1284ca1ab94SDag-Erling SmørgravThese functions implement a high-level library for retrieving and 1294ca1ab94SDag-Erling Smørgravuploading files using Uniform Resource Locators (URLs). 1304ca1ab94SDag-Erling Smørgrav.Pp 13160245e42SDag-Erling Smørgrav.Fn fetchParseURL 13260245e42SDag-Erling Smørgravtakes a URL in the form of a null-terminated string and splits it into 13360245e42SDag-Erling Smørgravits components function according to the Common Internet Scheme Syntax 1349364c532SDag-Erling Smørgravdetailed in RFC1738. 1359364c532SDag-Erling SmørgravA regular expression which produces this syntax is: 13660245e42SDag-Erling Smørgrav.Bd -literal 13760245e42SDag-Erling Smørgrav <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)? 13860245e42SDag-Erling Smørgrav.Ed 13960245e42SDag-Erling Smørgrav.Pp 1401df2031cSDag-Erling SmørgravIf the URL does not seem to begin with a scheme name, the following 1411df2031cSDag-Erling Smørgravsyntax is assumed: 1421df2031cSDag-Erling Smørgrav.Bd -literal 1431df2031cSDag-Erling Smørgrav ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)? 1441df2031cSDag-Erling Smørgrav.Ed 1451df2031cSDag-Erling Smørgrav.Pp 14660245e42SDag-Erling SmørgravNote that some components of the URL are not necessarily relevant to 14760245e42SDag-Erling Smørgravall URL schemes. 1481df2031cSDag-Erling SmørgravFor instance, the file scheme only needs the <scheme> and <document> 1491df2031cSDag-Erling Smørgravcomponents. 15060245e42SDag-Erling Smørgrav.Pp 1519a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL 1529a964d6aSDag-Erling Smørgravand 15340ac2845SDag-Erling Smørgrav.Fn fetchParseURL 1549a964d6aSDag-Erling Smørgravreturn a pointer to a 155a7e16a9dSRuslan Ermilov.Vt url 15640ac2845SDag-Erling Smørgravstructure, which is defined as follows in 157fe08efe6SRuslan Ermilov.In fetch.h : 15840ac2845SDag-Erling Smørgrav.Bd -literal 15940ac2845SDag-Erling Smørgrav#define URL_SCHEMELEN 16 16040ac2845SDag-Erling Smørgrav#define URL_USERLEN 256 16140ac2845SDag-Erling Smørgrav#define URL_PWDLEN 256 16240ac2845SDag-Erling Smørgrav 16340ac2845SDag-Erling Smørgravstruct url { 16440ac2845SDag-Erling Smørgrav char scheme[URL_SCHEMELEN+1]; 16540ac2845SDag-Erling Smørgrav char user[URL_USERLEN+1]; 16640ac2845SDag-Erling Smørgrav char pwd[URL_PWDLEN+1]; 16740ac2845SDag-Erling Smørgrav char host[MAXHOSTNAMELEN+1]; 16840ac2845SDag-Erling Smørgrav int port; 16940ac2845SDag-Erling Smørgrav char *doc; 17040ac2845SDag-Erling Smørgrav off_t offset; 17140ac2845SDag-Erling Smørgrav size_t length; 1727f92799fSMurray Stokely time_t ims_time; 17340ac2845SDag-Erling Smørgrav}; 17440ac2845SDag-Erling Smørgrav.Ed 17540ac2845SDag-Erling Smørgrav.Pp 1767f92799fSMurray StokelyThe 1777f92799fSMurray Stokely.Va ims_time 1787f92799fSMurray Stokelyfield stores the time value for 1797f92799fSMurray Stokely.Li If-Modified-Since 1807f92799fSMurray StokelyHTTP requests. 1817f92799fSMurray Stokely.Pp 18260245e42SDag-Erling SmørgravThe pointer returned by 1839a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL 1849a964d6aSDag-Erling Smørgravor 18560245e42SDag-Erling Smørgrav.Fn fetchParseURL 18660245e42SDag-Erling Smørgravshould be freed using 18760245e42SDag-Erling Smørgrav.Fn fetchFreeURL . 18860245e42SDag-Erling Smørgrav.Pp 1891a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL , 1901a5faa10SDag-Erling Smørgrav.Fn fetchGetURL , 191db5f8cebSDag-Erling Smørgravand 192db5f8cebSDag-Erling Smørgrav.Fn fetchPutURL 193db5f8cebSDag-Erling Smørgravconstitute the recommended interface to the 194db5f8cebSDag-Erling Smørgrav.Nm fetch 195c6ff3a1bSSheldon Hearnlibrary. 196c6ff3a1bSSheldon HearnThey examine the URL passed to them to determine the transfer 197db5f8cebSDag-Erling Smørgravmethod, and call the appropriate lower-level functions to perform the 198c6ff3a1bSSheldon Hearnactual transfer. 1991a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL 2001a5faa10SDag-Erling Smørgravalso returns the remote document's metadata in the 201a7e16a9dSRuslan Ermilov.Vt url_stat 2021a5faa10SDag-Erling Smørgravstructure pointed to by the 2031a5faa10SDag-Erling Smørgrav.Fa us 2041a5faa10SDag-Erling Smørgravargument. 2051a5faa10SDag-Erling Smørgrav.Pp 206c6ff3a1bSSheldon HearnThe 207db5f8cebSDag-Erling Smørgrav.Fa flags 208c6ff3a1bSSheldon Hearnargument is a string of characters which specify transfer options. 209c6ff3a1bSSheldon HearnThe 210db5f8cebSDag-Erling Smørgravmeaning of the individual flags is scheme-dependent, and is detailed 211db5f8cebSDag-Erling Smørgravin the appropriate section below. 212db5f8cebSDag-Erling Smørgrav.Pp 213d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL 214d8acd8dcSDag-Erling Smørgravattempts to obtain the requested document's metadata and fill in the 2155e75e35cSDima Dorfmanstructure pointed to by its second argument. 216c6ff3a1bSSheldon HearnThe 217a7e16a9dSRuslan Ermilov.Vt url_stat 218d8acd8dcSDag-Erling Smørgravstructure is defined as follows in 219fe08efe6SRuslan Ermilov.In fetch.h : 220d8acd8dcSDag-Erling Smørgrav.Bd -literal 221d8acd8dcSDag-Erling Smørgravstruct url_stat { 222d8acd8dcSDag-Erling Smørgrav off_t size; 2235aea254fSDag-Erling Smørgrav time_t atime; 2245aea254fSDag-Erling Smørgrav time_t mtime; 225d8acd8dcSDag-Erling Smørgrav}; 226d8acd8dcSDag-Erling Smørgrav.Ed 227d8acd8dcSDag-Erling Smørgrav.Pp 22840ac2845SDag-Erling SmørgravIf the size could not be obtained from the server, the 22940ac2845SDag-Erling Smørgrav.Fa size 23040ac2845SDag-Erling Smørgravfield is set to -1. 23140ac2845SDag-Erling SmørgravIf the modification time could not be obtained from the server, the 23240ac2845SDag-Erling Smørgrav.Fa mtime 23340ac2845SDag-Erling Smørgravfield is set to the epoch. 23440ac2845SDag-Erling SmørgravIf the access time could not be obtained from the server, the 23540ac2845SDag-Erling Smørgrav.Fa atime 23640ac2845SDag-Erling Smørgravfield is set to the modification time. 23740ac2845SDag-Erling Smørgrav.Pp 238ce71b736SDag-Erling Smørgrav.Fn fetchListURL 239ce71b736SDag-Erling Smørgravattempts to list the contents of the directory pointed to by the URL 240c6ff3a1bSSheldon Hearnprovided. 241c6ff3a1bSSheldon HearnIf successful, it returns a malloced array of 242a7e16a9dSRuslan Ermilov.Vt url_ent 243c6ff3a1bSSheldon Hearnstructures. 244c6ff3a1bSSheldon HearnThe 245a7e16a9dSRuslan Ermilov.Vt url_ent 246ce71b736SDag-Erling Smørgravstructure is defined as follows in 247fe08efe6SRuslan Ermilov.In fetch.h : 248ce71b736SDag-Erling Smørgrav.Bd -literal 249ce71b736SDag-Erling Smørgravstruct url_ent { 250e97f516cSDag-Erling Smørgrav char name[PATH_MAX]; 251ce71b736SDag-Erling Smørgrav struct url_stat stat; 252ce71b736SDag-Erling Smørgrav}; 253ce71b736SDag-Erling Smørgrav.Ed 254ce71b736SDag-Erling Smørgrav.Pp 255ce71b736SDag-Erling SmørgravThe list is terminated by an entry with an empty name. 256ce71b736SDag-Erling Smørgrav.Pp 257ce71b736SDag-Erling SmørgravThe pointer returned by 258ce71b736SDag-Erling Smørgrav.Fn fetchListURL 259ce71b736SDag-Erling Smørgravshould be freed using 260ce71b736SDag-Erling Smørgrav.Fn free . 261ce71b736SDag-Erling Smørgrav.Pp 2621a5faa10SDag-Erling Smørgrav.Fn fetchXGet , 263d8acd8dcSDag-Erling Smørgrav.Fn fetchGet , 264db5f8cebSDag-Erling Smørgrav.Fn fetchPut 2654ca1ab94SDag-Erling Smørgravand 266d8acd8dcSDag-Erling Smørgrav.Fn fetchStat 267d8acd8dcSDag-Erling Smørgravare similar to 2681a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL , 269d8acd8dcSDag-Erling Smørgrav.Fn fetchGetURL , 270d8acd8dcSDag-Erling Smørgrav.Fn fetchPutURL 271d8acd8dcSDag-Erling Smørgravand 272d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL , 273db5f8cebSDag-Erling Smørgravexcept that they expect a pre-parsed URL in the form of a pointer to 274d8acd8dcSDag-Erling Smørgrava 275a7e16a9dSRuslan Ermilov.Vt struct url 276d8acd8dcSDag-Erling Smørgravrather than a string. 2774ca1ab94SDag-Erling Smørgrav.Pp 2784ca1ab94SDag-Erling SmørgravAll of the 2791a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX , 2804ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX 2814ca1ab94SDag-Erling Smørgravand 2824ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX 2834ca1ab94SDag-Erling Smørgravfunctions return a pointer to a stream which can be used to read or 284c6ff3a1bSSheldon Hearnwrite data from or to the requested document, respectively. 285c6ff3a1bSSheldon HearnNote that 2864ca1ab94SDag-Erling Smørgravalthough the implementation details of the individual access methods 2874ca1ab94SDag-Erling Smørgravvary, it can generally be assumed that a stream returned by one of the 2881a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX 2891a5faa10SDag-Erling Smørgravor 2904ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX 2914ca1ab94SDag-Erling Smørgravfunctions is read-only, and that a stream returned by one of the 2924ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX 2934ca1ab94SDag-Erling Smørgravfunctions is write-only. 2944ca1ab94SDag-Erling Smørgrav.Sh FILE SCHEME 2951a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile , 2964ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile 2974ca1ab94SDag-Erling Smørgravand 2984ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile 2994ca1ab94SDag-Erling Smørgravprovide access to documents which are files in a locally mounted file 300c6ff3a1bSSheldon Hearnsystem. 301c6ff3a1bSSheldon HearnOnly the <document> component of the URL is used. 3024ca1ab94SDag-Erling Smørgrav.Pp 3031a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile 3041a5faa10SDag-Erling Smørgravand 3054ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile 3061a5faa10SDag-Erling Smørgravdo not accept any flags. 3074ca1ab94SDag-Erling Smørgrav.Pp 3084ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile 3094ca1ab94SDag-Erling Smørgravaccepts the 310a7e16a9dSRuslan Ermilov.Ql a 311c6ff3a1bSSheldon Hearn(append to file) flag. 312c6ff3a1bSSheldon HearnIf that flag is specified, the data written to 3134ca1ab94SDag-Erling Smørgravthe stream returned by 3144ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile 3154ca1ab94SDag-Erling Smørgravwill be appended to the previous contents of the file, instead of 3164ca1ab94SDag-Erling Smørgravreplacing them. 3174ca1ab94SDag-Erling Smørgrav.Sh FTP SCHEME 3181a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP , 3194ca1ab94SDag-Erling Smørgrav.Fn fetchGetFTP 3204ca1ab94SDag-Erling Smørgravand 3214ca1ab94SDag-Erling Smørgrav.Fn fetchPutFTP 3224ca1ab94SDag-Erling Smørgravimplement the FTP protocol as described in RFC959. 3234ca1ab94SDag-Erling Smørgrav.Pp 3244ca1ab94SDag-Erling SmørgravIf the 325ecd18c96SDag-Erling Smørgrav.Ql P 326ecd18c96SDag-Erling Smørgrav(not passive) flag is specified, an active (rather than passive) 327ecd18c96SDag-Erling Smørgravconnection will be attempted. 328ecd18c96SDag-Erling Smørgrav.Pp 329ecd18c96SDag-Erling SmørgravThe 330a7e16a9dSRuslan Ermilov.Ql p 331ecd18c96SDag-Erling Smørgravflag is supported for compatibility with earlier versions where active 332ecd18c96SDag-Erling Smørgravconnections were the default. 333ecd18c96SDag-Erling SmørgravIt has precedence over the 334ecd18c96SDag-Erling Smørgrav.Ql P 335ecd18c96SDag-Erling Smørgravflag, so if both are specified, 336ecd18c96SDag-Erling Smørgrav.Nm 337ecd18c96SDag-Erling Smørgravwill use a passive connection. 3384ca1ab94SDag-Erling Smørgrav.Pp 339f5f109a0SDag-Erling SmørgravIf the 340a7e16a9dSRuslan Ermilov.Ql l 341d5f175ceSDag-Erling Smørgrav(low) flag is specified, data sockets will be allocated in the low (or 342d5c24aa8SBill Fennerdefault) port range instead of the high port range (see 343f5f109a0SDag-Erling Smørgrav.Xr ip 4 ) . 344f5f109a0SDag-Erling Smørgrav.Pp 345f5f109a0SDag-Erling SmørgravIf the 346a7e16a9dSRuslan Ermilov.Ql d 347f5f109a0SDag-Erling Smørgrav(direct) flag is specified, 3481a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP , 349f5f109a0SDag-Erling Smørgrav.Fn fetchGetFTP 350f5f109a0SDag-Erling Smørgravand 351f5f109a0SDag-Erling Smørgrav.Fn fetchPutFTP 352f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined. 353f5f109a0SDag-Erling Smørgrav.Pp 3544ca1ab94SDag-Erling SmørgravIf no user name or password is given, the 3554ca1ab94SDag-Erling Smørgrav.Nm fetch 356c86c6f74SDag-Erling Smørgravlibrary will attempt an anonymous login, with user name "anonymous" 357c86c6f74SDag-Erling Smørgravand password "anonymous@<hostname>". 3584ca1ab94SDag-Erling Smørgrav.Sh HTTP SCHEME 3594ca1ab94SDag-Erling SmørgravThe 3601a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP , 361f4e05cc5SMark Johnston.Fn fetchGetHTTP , 3624ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP 363f4e05cc5SMark Johnstonand 364f4e05cc5SMark Johnston.Fn fetchReqHTTP 365c6ff3a1bSSheldon Hearnfunctions implement the HTTP/1.1 protocol. 36636a142c4SRuslan ErmilovWith a little luck, there is 36706b533d3SDag-Erling Smørgraveven a chance that they comply with RFC2616 and RFC2617. 3684ca1ab94SDag-Erling Smørgrav.Pp 369f5f109a0SDag-Erling SmørgravIf the 370a7e16a9dSRuslan Ermilov.Ql d 371f5f109a0SDag-Erling Smørgrav(direct) flag is specified, 3721a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP , 373f5f109a0SDag-Erling Smørgrav.Fn fetchGetHTTP 374f5f109a0SDag-Erling Smørgravand 375f5f109a0SDag-Erling Smørgrav.Fn fetchPutHTTP 376f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined. 377f5f109a0SDag-Erling Smørgrav.Pp 3787f92799fSMurray StokelyIf the 3797f92799fSMurray Stokely.Ql i 3807f92799fSMurray Stokely(if-modified-since) flag is specified, and 3817f92799fSMurray Stokelythe 3827f92799fSMurray Stokely.Va ims_time 3837f92799fSMurray Stokelyfield is set in 3847f92799fSMurray Stokely.Vt "struct url" , 3857f92799fSMurray Stokelythen 3867f92799fSMurray Stokely.Fn fetchXGetHTTP 3877f92799fSMurray Stokelyand 3887f92799fSMurray Stokely.Fn fetchGetHTTP 3897f92799fSMurray Stokelywill send a conditional 3907f92799fSMurray Stokely.Li If-Modified-Since 3917f92799fSMurray StokelyHTTP header to only fetch the content if it is newer than 3927f92799fSMurray Stokely.Va ims_time . 3937f92799fSMurray Stokely.Pp 394f4e05cc5SMark JohnstonThe function 395f4e05cc5SMark Johnston.Fn fetchReqHTTP 396f4e05cc5SMark Johnstoncan be used to make requests with an arbitrary HTTP verb, 397f4e05cc5SMark Johnstonincluding POST, DELETE, CONNECT, OPTIONS, TRACE or PATCH. 398f4e05cc5SMark JohnstonThis can be done by setting the argument 399f4e05cc5SMark Johnston.Fa method 400f4e05cc5SMark Johnstonto the intended verb, such as 401f4e05cc5SMark Johnston.Ql POST , 402f4e05cc5SMark Johnstonand 403f4e05cc5SMark Johnston.Fa body 404f4e05cc5SMark Johnstonto the content. 405f4e05cc5SMark Johnston.Pp 4064ca1ab94SDag-Erling SmørgravSince there seems to be no good way of implementing the HTTP PUT 4074ca1ab94SDag-Erling Smørgravmethod in a manner consistent with the rest of the 4084ca1ab94SDag-Erling Smørgrav.Nm fetch 4094ca1ab94SDag-Erling Smørgravlibrary, 4104ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP 4114ca1ab94SDag-Erling Smørgravis currently unimplemented. 412dcd47379SDag-Erling Smørgrav.Sh HTTPS SCHEME 413dcd47379SDag-Erling SmørgravBased on HTTP SCHEME. 414dcd47379SDag-Erling SmørgravBy default the peer is verified using the CA bundle located in 4151ec923fdSMichael Gmelin.Pa /usr/local/etc/ssl/cert.pem . 4161ec923fdSMichael GmelinIf this file does not exist, 4171ec923fdSMichael Gmelin.Pa /etc/ssl/cert.pem 4181ec923fdSMichael Gmelinis used instead. 4191ec923fdSMichael GmelinIf neither file exists, and 4201ec923fdSMichael Gmelin.Ev SSL_CA_CERT_PATH 4211ec923fdSMichael Gmelinhas not been set, 4221ec923fdSMichael GmelinOpenSSL's default CA cert and path settings apply. 4231ec923fdSMichael GmelinThe certificate bundle can contain multiple CA certificates. 424dcd47379SDag-Erling SmørgravA common source of a current CA bundle is 425dcd47379SDag-Erling Smørgrav.Pa \%security/ca_root_nss . 426dcd47379SDag-Erling Smørgrav.Pp 427dcd47379SDag-Erling SmørgravThe CA bundle used for peer verification can be changed by setting the 428dcd47379SDag-Erling Smørgravenvironment variables 429dcd47379SDag-Erling Smørgrav.Ev SSL_CA_CERT_FILE 430dcd47379SDag-Erling Smørgravto point to a concatenated bundle of trusted certificates and 431dcd47379SDag-Erling Smørgrav.Ev SSL_CA_CERT_PATH 432dcd47379SDag-Erling Smørgravto point to a directory containing hashes of trusted CAs (see 433dcd47379SDag-Erling Smørgrav.Xr verify 1 ) . 434dcd47379SDag-Erling Smørgrav.Pp 435dcd47379SDag-Erling SmørgravA certificate revocation list (CRL) can be used by setting the 436dcd47379SDag-Erling Smørgravenvironment variable 437dcd47379SDag-Erling Smørgrav.Ev SSL_CRL_FILE 438dcd47379SDag-Erling Smørgrav(see 439dcd47379SDag-Erling Smørgrav.Xr crl 1 ) . 440dcd47379SDag-Erling Smørgrav.Pp 441dcd47379SDag-Erling SmørgravPeer verification can be disabled by setting the environment variable 442dcd47379SDag-Erling Smørgrav.Ev SSL_NO_VERIFY_PEER . 443dcd47379SDag-Erling SmørgravNote that this also disables CRL checking. 444dcd47379SDag-Erling Smørgrav.Pp 445dcd47379SDag-Erling SmørgravBy default the service identity is verified according to the rules 446dcd47379SDag-Erling Smørgravdetailed in RFC6125 (also known as hostname verification). 447dcd47379SDag-Erling SmørgravThis feature can be disabled by setting the environment variable 448dcd47379SDag-Erling Smørgrav.Ev SSL_NO_VERIFY_HOSTNAME . 449dcd47379SDag-Erling Smørgrav.Pp 450dcd47379SDag-Erling SmørgravClient certificate based authentication is supported. 451dcd47379SDag-Erling SmørgravThe environment variable 452dcd47379SDag-Erling Smørgrav.Ev SSL_CLIENT_CERT_FILE 453dcd47379SDag-Erling Smørgravshould be set to point to a file containing key and client certificate 4541ec923fdSMichael Gmelinto be used in PEM format. 4551ec923fdSMichael GmelinWhen a PEM-format key is in a separate file from the client certificate, 4561ec923fdSMichael Gmelinthe environment variable 457dcd47379SDag-Erling Smørgrav.Ev SSL_CLIENT_KEY_FILE 4581ec923fdSMichael Gmelincan be set to point to the key file. 459dcd47379SDag-Erling SmørgravIn case the key uses a password, the user will be prompted on standard 460dcd47379SDag-Erling Smørgravinput (see 461dcd47379SDag-Erling Smørgrav.Xr PEM 3 ) . 462dcd47379SDag-Erling Smørgrav.Pp 463dcd47379SDag-Erling SmørgravBy default 464dcd47379SDag-Erling Smørgrav.Nm libfetch 46576720765SDag-Erling Smørgravallows TLSv1 and newer when negotiating the connecting with the remote 466dcd47379SDag-Erling Smørgravpeer. 46776720765SDag-Erling SmørgravYou can change this behavior by setting the 46876720765SDag-Erling Smørgrav.Ev SSL_ALLOW_SSL3 46901ed3ca3SJung-uk Kimenvironment variable to allow SSLv3 and 47076720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1 , 47176720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1_1 and 47276720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1_2 47376720765SDag-Erling Smørgravto disable TLS 1.0, 1.1 and 1.2 respectively. 47406b533d3SDag-Erling Smørgrav.Sh AUTHENTICATION 47506b533d3SDag-Erling SmørgravApart from setting the appropriate environment variables and 47606b533d3SDag-Erling Smørgravspecifying the user name and password in the URL or the 477a7e16a9dSRuslan Ermilov.Vt struct url , 47806b533d3SDag-Erling Smørgravthe calling program has the option of defining an authentication 47906b533d3SDag-Erling Smørgravfunction with the following prototype: 48006b533d3SDag-Erling Smørgrav.Pp 48106b533d3SDag-Erling Smørgrav.Ft int 48206b533d3SDag-Erling Smørgrav.Fn myAuthMethod "struct url *u" 48306b533d3SDag-Erling Smørgrav.Pp 48406b533d3SDag-Erling SmørgravThe callback function should fill in the 48506b533d3SDag-Erling Smørgrav.Fa user 48606b533d3SDag-Erling Smørgravand 48706b533d3SDag-Erling Smørgrav.Fa pwd 48806b533d3SDag-Erling Smørgravfields in the provided 489a7e16a9dSRuslan Ermilov.Vt struct url 49006b533d3SDag-Erling Smørgravand return 0 on success, or any other value to indicate failure. 49106b533d3SDag-Erling Smørgrav.Pp 49206b533d3SDag-Erling SmørgravTo register the authentication callback, simply set 493a7e16a9dSRuslan Ermilov.Va fetchAuthMethod 49406b533d3SDag-Erling Smørgravto point at it. 49506b533d3SDag-Erling SmørgravThe callback will be used whenever a site requires authentication and 4960227791bSRuslan Ermilovthe appropriate environment variables are not set. 49706b533d3SDag-Erling Smørgrav.Pp 49806b533d3SDag-Erling SmørgravThis interface is experimental and may be subject to change. 4994ca1ab94SDag-Erling Smørgrav.Sh RETURN VALUES 5004ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL 5014ca1ab94SDag-Erling Smørgravreturns a pointer to a 502a7e16a9dSRuslan Ermilov.Vt struct url 503c6ff3a1bSSheldon Hearncontaining the individual components of the URL. 504c6ff3a1bSSheldon HearnIf it is 5054ca1ab94SDag-Erling Smørgravunable to allocate memory, or the URL is syntactically incorrect, 5064ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL 5074ca1ab94SDag-Erling Smørgravreturns a NULL pointer. 5084ca1ab94SDag-Erling Smørgrav.Pp 509d8acd8dcSDag-Erling SmørgravThe 510d8acd8dcSDag-Erling Smørgrav.Fn fetchStat 511d8acd8dcSDag-Erling Smørgravfunctions return 0 on success and -1 on failure. 512d8acd8dcSDag-Erling Smørgrav.Pp 5134ca1ab94SDag-Erling SmørgravAll other functions return a stream pointer which may be used to 514d8acd8dcSDag-Erling Smørgravaccess the requested document, or NULL if an error occurred. 515d8acd8dcSDag-Erling Smørgrav.Pp 516ba101983SDag-Erling SmørgravThe following error codes are defined in 517fe08efe6SRuslan Ermilov.In fetch.h : 51815efcd39SAlexey Zelkin.Bl -tag -width 18n 519d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_ABORT 520d8acd8dcSDag-Erling SmørgravOperation aborted 521d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_AUTH 522d8acd8dcSDag-Erling SmørgravAuthentication failed 523d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_DOWN 524d8acd8dcSDag-Erling SmørgravService unavailable 525d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_EXISTS 526d8acd8dcSDag-Erling SmørgravFile exists 527d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_FULL 528d8acd8dcSDag-Erling SmørgravFile system full 529d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_INFO 530d8acd8dcSDag-Erling SmørgravInformational response 531d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MEMORY 532d8acd8dcSDag-Erling SmørgravInsufficient memory 533d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MOVED 534d8acd8dcSDag-Erling SmørgravFile has moved 535d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_NETWORK 536d8acd8dcSDag-Erling SmørgravNetwork error 537d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_OK 538d8acd8dcSDag-Erling SmørgravNo error 539d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_PROTO 540d8acd8dcSDag-Erling SmørgravProtocol error 541d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_RESOLV 542d8acd8dcSDag-Erling SmørgravResolver error 543d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_SERVER 544d8acd8dcSDag-Erling SmørgravServer error 545d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TEMP 546d8acd8dcSDag-Erling SmørgravTemporary error 547d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TIMEOUT 548d8acd8dcSDag-Erling SmørgravOperation timed out 549d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNAVAIL 550d8acd8dcSDag-Erling SmørgravFile is not available 551d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNKNOWN 552d8acd8dcSDag-Erling SmørgravUnknown error 553d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_URL 554d8acd8dcSDag-Erling SmørgravInvalid URL 555d8acd8dcSDag-Erling Smørgrav.El 556d8acd8dcSDag-Erling Smørgrav.Pp 557d8acd8dcSDag-Erling SmørgravThe accompanying error message includes a protocol-specific error code 5581ec923fdSMichael Gmelinand message, like "File is not available (404 Not Found)" 5594ca1ab94SDag-Erling Smørgrav.Sh ENVIRONMENT 5603a5146d9SRuslan Ermilov.Bl -tag -width ".Ev FETCH_BIND_ADDRESS" 561c42cb9d9SDag-Erling Smørgrav.It Ev FETCH_BIND_ADDRESS 562c42cb9d9SDag-Erling SmørgravSpecifies a hostname or IP address to which sockets used for outgoing 563c42cb9d9SDag-Erling Smørgravconnections will be bound. 564659e0d5eSDag-Erling Smørgrav.It Ev FTP_LOGIN 565659e0d5eSDag-Erling SmørgravDefault FTP login if none was provided in the URL. 56691c51046SDag-Erling Smørgrav.It Ev FTP_PASSIVE_MODE 567ecd18c96SDag-Erling SmørgravIf set to 5686c81eb52SDag-Erling Smørgrav.Ql no , 569ecd18c96SDag-Erling Smørgravforces the FTP code to use active mode. 570ecd18c96SDag-Erling SmørgravIf set to any other value, forces passive mode even if the application 571ecd18c96SDag-Erling Smørgravrequested active mode. 57291c51046SDag-Erling Smørgrav.It Ev FTP_PASSWORD 57391c51046SDag-Erling SmørgravDefault FTP password if the remote server requests one and none was 57491c51046SDag-Erling Smørgravprovided in the URL. 575bc2a5e68SDag-Erling Smørgrav.It Ev FTP_PROXY 5761df2031cSDag-Erling SmørgravURL of the proxy to use for FTP requests. 5771df2031cSDag-Erling SmørgravThe document part is ignored. 5781df2031cSDag-Erling SmørgravFTP and HTTP proxies are supported; if no scheme is specified, FTP is 5791df2031cSDag-Erling Smørgravassumed. 5801df2031cSDag-Erling SmørgravIf the proxy is an FTP proxy, 581e0a9ca38SDag-Erling Smørgrav.Nm libfetch 582e0a9ca38SDag-Erling Smørgravwill send 583e0a9ca38SDag-Erling Smørgrav.Ql user@host 584e0a9ca38SDag-Erling Smørgravas user name to the proxy, where 585e0a9ca38SDag-Erling Smørgrav.Ql user 586e0a9ca38SDag-Erling Smørgravis the real user name, and 587e0a9ca38SDag-Erling Smørgrav.Ql host 588e0a9ca38SDag-Erling Smørgravis the name of the FTP server. 58989d755e1SDag-Erling Smørgrav.Pp 5902e83f638SDag-Erling SmørgravIf this variable is set to an empty string, no proxy will be used for 5912e83f638SDag-Erling SmørgravFTP requests, even if the 5922e83f638SDag-Erling Smørgrav.Ev HTTP_PROXY 5932e83f638SDag-Erling Smørgravvariable is set. 5944cee73c8SDag-Erling Smørgrav.It Ev ftp_proxy 5954cee73c8SDag-Erling SmørgravSame as 5964cee73c8SDag-Erling Smørgrav.Ev FTP_PROXY , 5974cee73c8SDag-Erling Smørgravfor compatibility. 5981453595fSDag-Erling Smørgrav.It Ev HTTP_ACCEPT 5991453595fSDag-Erling SmørgravSpecifies the value of the 6001453595fSDag-Erling Smørgrav.Va Accept 6011453595fSDag-Erling Smørgravheader for HTTP requests. 6021453595fSDag-Erling SmørgravIf empty, no 6031453595fSDag-Erling Smørgrav.Va Accept 6041453595fSDag-Erling Smørgravheader is sent. 6051453595fSDag-Erling SmørgravThe default is 6061453595fSDag-Erling Smørgrav.Dq */* . 60798f5573fSDag-Erling Smørgrav.It Ev HTTP_AUTH 60889d755e1SDag-Erling SmørgravSpecifies HTTP authorization parameters as a colon-separated list of 60989d755e1SDag-Erling Smørgravitems. 61098f5573fSDag-Erling SmørgravThe first and second item are the authorization scheme and realm 61198f5573fSDag-Erling Smørgravrespectively; further items are scheme-dependent. 61278122aacSDag-Erling SmørgravCurrently, the 61378122aacSDag-Erling Smørgrav.Dq basic 61478122aacSDag-Erling Smørgravand 61578122aacSDag-Erling Smørgrav.Dq digest 61678122aacSDag-Erling Smørgravauthorization methods are supported. 61789d755e1SDag-Erling Smørgrav.Pp 61878122aacSDag-Erling SmørgravBoth methods require two parameters: the user name and 61998f5573fSDag-Erling Smørgravpassword, in that order. 62089d755e1SDag-Erling Smørgrav.Pp 62189d755e1SDag-Erling SmørgravThis variable is only used if the server requires authorization and 62289d755e1SDag-Erling Smørgravno user name or password was specified in the URL. 623bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY 6241df2031cSDag-Erling SmørgravURL of the proxy to use for HTTP requests. 6251df2031cSDag-Erling SmørgravThe document part is ignored. 6261df2031cSDag-Erling SmørgravOnly HTTP proxies are supported for HTTP requests. 627bc2a5e68SDag-Erling SmørgravIf no port number is specified, the default is 3128. 62889d755e1SDag-Erling Smørgrav.Pp 6291df2031cSDag-Erling SmørgravNote that this proxy will also be used for FTP documents, unless the 630e0a9ca38SDag-Erling Smørgrav.Ev FTP_PROXY 631e0a9ca38SDag-Erling Smørgravvariable is set. 6324cee73c8SDag-Erling Smørgrav.It Ev http_proxy 6334cee73c8SDag-Erling SmørgravSame as 6344cee73c8SDag-Erling Smørgrav.Ev HTTP_PROXY , 6354cee73c8SDag-Erling Smørgravfor compatibility. 636bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY_AUTH 63798f5573fSDag-Erling SmørgravSpecifies authorization parameters for the HTTP proxy in the same 638e0a9ca38SDag-Erling Smørgravformat as the 639e0a9ca38SDag-Erling Smørgrav.Ev HTTP_AUTH 640e0a9ca38SDag-Erling Smørgravvariable. 64189d755e1SDag-Erling Smørgrav.Pp 6421df2031cSDag-Erling SmørgravThis variable is used if and only if connected to an HTTP proxy, and 6431df2031cSDag-Erling Smørgravis ignored if a user and/or a password were specified in the proxy 6441df2031cSDag-Erling SmørgravURL. 645d5216a4fSDag-Erling Smørgrav.It Ev HTTP_REFERER 64657bd0fc6SJens SchweikhardtSpecifies the referrer URL to use for HTTP requests. 647d5216a4fSDag-Erling SmørgravIf set to 648d5216a4fSDag-Erling Smørgrav.Dq auto , 64957bd0fc6SJens Schweikhardtthe document URL will be used as referrer URL. 6506a0cf64bSDag-Erling Smørgrav.It Ev HTTP_USER_AGENT 6516a0cf64bSDag-Erling SmørgravSpecifies the User-Agent string to use for HTTP requests. 6526a0cf64bSDag-Erling SmørgravThis can be useful when working with HTTP origin or proxy servers that 653a7e16a9dSRuslan Ermilovdifferentiate between user agents. 654c257f99eSDag-Erling SmørgravIf defined but empty, no User-Agent header is sent. 6550ab4a51eSDag-Erling Smørgrav.It Ev NETRC 6560ab4a51eSDag-Erling SmørgravSpecifies a file to use instead of 6570ab4a51eSDag-Erling Smørgrav.Pa ~/.netrc 6584d8b056eSDag-Erling Smørgravto look up login names and passwords for FTP and HTTP sites as well as 6594d8b056eSDag-Erling SmørgravHTTP proxies. 6600ab4a51eSDag-Erling SmørgravSee 6610ab4a51eSDag-Erling Smørgrav.Xr ftp 1 6620ab4a51eSDag-Erling Smørgravfor a description of the file format. 663e99ace35SDag-Erling Smørgrav.It Ev NO_PROXY 664e99ace35SDag-Erling SmørgravEither a single asterisk, which disables the use of proxies 665e99ace35SDag-Erling Smørgravaltogether, or a comma- or whitespace-separated list of hosts for 666e99ace35SDag-Erling Smørgravwhich proxies should not be used. 667e99ace35SDag-Erling Smørgrav.It Ev no_proxy 668e99ace35SDag-Erling SmørgravSame as 669e99ace35SDag-Erling Smørgrav.Ev NO_PROXY , 670e99ace35SDag-Erling Smørgravfor compatibility. 671*c44be5aaSKyle Evans.It Ev SOCKS5_PROXY 672*c44be5aaSKyle EvansUses SOCKS version 5 to make connection. 673*c44be5aaSKyle EvansThe format must be the IP or hostname followed by a colon for the port. 674*c44be5aaSKyle EvansIPv6 addresses must enclose the address in brackets. 675*c44be5aaSKyle EvansIf no port is specified, the default is 1080. 676*c44be5aaSKyle EvansThis setting will supercede a connection to an 677*c44be5aaSKyle Evans.Ev HTTP_PROXY . 67876720765SDag-Erling Smørgrav.It Ev SSL_ALLOW_SSL3 67976720765SDag-Erling SmørgravAllow SSL version 3 when negotiating the connection (not recommended). 680dcd47379SDag-Erling Smørgrav.It Ev SSL_CA_CERT_FILE 681dcd47379SDag-Erling SmørgravCA certificate bundle containing trusted CA certificates. 6821ec923fdSMichael GmelinDefault value: See HTTPS SCHEME above. 683dcd47379SDag-Erling Smørgrav.It Ev SSL_CA_CERT_PATH 684dcd47379SDag-Erling SmørgravPath containing trusted CA hashes. 685dcd47379SDag-Erling Smørgrav.It Ev SSL_CLIENT_CERT_FILE 686dcd47379SDag-Erling SmørgravPEM encoded client certificate/key which will be used in 687dcd47379SDag-Erling Smørgravclient certificate authentication. 688dcd47379SDag-Erling Smørgrav.It Ev SSL_CLIENT_KEY_FILE 689dcd47379SDag-Erling SmørgravPEM encoded client key in case key and client certificate 690dcd47379SDag-Erling Smørgravare stored separately. 691dcd47379SDag-Erling Smørgrav.It Ev SSL_CRL_FILE 692dcd47379SDag-Erling SmørgravFile containing certificate revocation list. 693dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_TLS1 69476720765SDag-Erling SmørgravDo not allow TLS version 1.0 when negotiating the connection. 69576720765SDag-Erling Smørgrav.It Ev SSL_NO_TLS1_1 69676720765SDag-Erling SmørgravDo not allow TLS version 1.1 when negotiating the connection. 69776720765SDag-Erling Smørgrav.It Ev SSL_NO_TLS1_2 69876720765SDag-Erling SmørgravDo not allow TLS version 1.2 when negotiating the connection. 699dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_VERIFY_HOSTNAME 700dcd47379SDag-Erling SmørgravIf set, do not verify that the hostname matches the subject of the 701dcd47379SDag-Erling Smørgravcertificate presented by the server. 702dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_VERIFY_PEER 703dcd47379SDag-Erling SmørgravIf set, do not verify the peer certificate against trusted CAs. 704bc2a5e68SDag-Erling Smørgrav.El 7050315901cSTom Rhodes.Sh EXAMPLES 7060315901cSTom RhodesTo access a proxy server on 7070315901cSTom Rhodes.Pa proxy.example.com 7080315901cSTom Rhodesport 8080, set the 7090315901cSTom Rhodes.Ev HTTP_PROXY 7100315901cSTom Rhodesenvironment variable in a manner similar to this: 7110315901cSTom Rhodes.Pp 7120315901cSTom Rhodes.Dl HTTP_PROXY=http://proxy.example.com:8080 7130315901cSTom Rhodes.Pp 7140315901cSTom RhodesIf the proxy server requires authentication, there are 7150315901cSTom Rhodestwo options available for passing the authentication data. 7160315901cSTom RhodesThe first method is by using the proxy URL: 7170315901cSTom Rhodes.Pp 7180315901cSTom Rhodes.Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080 7190315901cSTom Rhodes.Pp 7200315901cSTom RhodesThe second method is by using the 7210315901cSTom Rhodes.Ev HTTP_PROXY_AUTH 7220315901cSTom Rhodesenvironment variable: 7230315901cSTom Rhodes.Bd -literal -offset indent 7240315901cSTom RhodesHTTP_PROXY=http://proxy.example.com:8080 7250315901cSTom RhodesHTTP_PROXY_AUTH=basic:*:<user>:<pwd> 7260315901cSTom Rhodes.Ed 727e99ace35SDag-Erling Smørgrav.Pp 728e99ace35SDag-Erling SmørgravTo disable the use of a proxy for an HTTP server running on the local 729e99ace35SDag-Erling Smørgravhost, define 730e99ace35SDag-Erling Smørgrav.Ev NO_PROXY 731e99ace35SDag-Erling Smørgravas follows: 732e99ace35SDag-Erling Smørgrav.Bd -literal -offset indent 733e99ace35SDag-Erling SmørgravNO_PROXY=localhost,127.0.0.1 734e99ace35SDag-Erling Smørgrav.Ed 735dcd47379SDag-Erling Smørgrav.Pp 736*c44be5aaSKyle EvansTo use a SOCKS5 proxy, set the 737*c44be5aaSKyle Evans.Ev SOCKS5_PROXY 738*c44be5aaSKyle Evansenvironment variable to a 739*c44be5aaSKyle Evansvalid host or IP followed by an optional colon and the port. 740*c44be5aaSKyle EvansIPv6 addresses must be enclosed in brackets. 741*c44be5aaSKyle EvansThe following are examples of valid settings: 742*c44be5aaSKyle Evans.Bd -literal -offset indent 743*c44be5aaSKyle EvansSOCKS5_PROXY=proxy.example.com 744*c44be5aaSKyle EvansSOCKS5_PROXY=proxy.example.com:1080 745*c44be5aaSKyle EvansSOCKS5_PROXY=192.0.2.0 746*c44be5aaSKyle EvansSOCKS5_PROXY=198.51.100.0:1080 747*c44be5aaSKyle EvansSOCKS5_PROXY=[2001:db8::1] 748*c44be5aaSKyle EvansSOCKS5_PROXY=[2001:db8::2]:1080 749*c44be5aaSKyle Evans.Ed 750*c44be5aaSKyle Evans.Pp 751dcd47379SDag-Erling SmørgravAccess HTTPS website without any certificate verification whatsoever: 752dcd47379SDag-Erling Smørgrav.Bd -literal -offset indent 753dcd47379SDag-Erling SmørgravSSL_NO_VERIFY_PEER=1 754dcd47379SDag-Erling SmørgravSSL_NO_VERIFY_HOSTNAME=1 755dcd47379SDag-Erling Smørgrav.Ed 756dcd47379SDag-Erling Smørgrav.Pp 757dcd47379SDag-Erling SmørgravAccess HTTPS website using client certificate based authentication 758dcd47379SDag-Erling Smørgravand a private CA: 759dcd47379SDag-Erling Smørgrav.Bd -literal -offset indent 760dcd47379SDag-Erling SmørgravSSL_CLIENT_CERT_FILE=/path/to/client.pem 761dcd47379SDag-Erling SmørgravSSL_CA_CERT_FILE=/path/to/myca.pem 762dcd47379SDag-Erling Smørgrav.Ed 7634ca1ab94SDag-Erling Smørgrav.Sh SEE ALSO 7644ca1ab94SDag-Erling Smørgrav.Xr fetch 1 , 765c86c6f74SDag-Erling Smørgrav.Xr ip 4 766c86c6f74SDag-Erling Smørgrav.Rs 767c86c6f74SDag-Erling Smørgrav.%A J. Postel 768c86c6f74SDag-Erling Smørgrav.%A J. K. Reynolds 769c86c6f74SDag-Erling Smørgrav.%D October 1985 770c86c6f74SDag-Erling Smørgrav.%B File Transfer Protocol 771c86c6f74SDag-Erling Smørgrav.%O RFC959 772c86c6f74SDag-Erling Smørgrav.Re 773c86c6f74SDag-Erling Smørgrav.Rs 774c86c6f74SDag-Erling Smørgrav.%A P. Deutsch 775c86c6f74SDag-Erling Smørgrav.%A A. Emtage 776c86c6f74SDag-Erling Smørgrav.%A A. Marine. 777c86c6f74SDag-Erling Smørgrav.%D May 1994 778c86c6f74SDag-Erling Smørgrav.%T How to Use Anonymous FTP 779c86c6f74SDag-Erling Smørgrav.%O RFC1635 78098849115SRuslan Ermilov.Re 7814ca1ab94SDag-Erling Smørgrav.Rs 7820f5fcaa3SSheldon Hearn.%A T. Berners-Lee 7830f5fcaa3SSheldon Hearn.%A L. Masinter 7840f5fcaa3SSheldon Hearn.%A M. McCahill 7854ca1ab94SDag-Erling Smørgrav.%D December 1994 7864ca1ab94SDag-Erling Smørgrav.%T Uniform Resource Locators (URL) 7874ca1ab94SDag-Erling Smørgrav.%O RFC1738 7884ca1ab94SDag-Erling Smørgrav.Re 7894ca1ab94SDag-Erling Smørgrav.Rs 7900f5fcaa3SSheldon Hearn.%A R. Fielding 7910f5fcaa3SSheldon Hearn.%A J. Gettys 7920f5fcaa3SSheldon Hearn.%A J. Mogul 7930f5fcaa3SSheldon Hearn.%A H. Frystyk 79406b533d3SDag-Erling Smørgrav.%A L. Masinter 79506b533d3SDag-Erling Smørgrav.%A P. Leach 7960f5fcaa3SSheldon Hearn.%A T. Berners-Lee 797d5c24aa8SBill Fenner.%D January 1999 7984ca1ab94SDag-Erling Smørgrav.%B Hypertext Transfer Protocol -- HTTP/1.1 79906b533d3SDag-Erling Smørgrav.%O RFC2616 80006b533d3SDag-Erling Smørgrav.Re 80106b533d3SDag-Erling Smørgrav.Rs 80206b533d3SDag-Erling Smørgrav.%A J. Franks 80306b533d3SDag-Erling Smørgrav.%A P. Hallam-Baker 80406b533d3SDag-Erling Smørgrav.%A J. Hostetler 80506b533d3SDag-Erling Smørgrav.%A S. Lawrence 80606b533d3SDag-Erling Smørgrav.%A P. Leach 80706b533d3SDag-Erling Smørgrav.%A A. Luotonen 80806b533d3SDag-Erling Smørgrav.%A L. Stewart 80906b533d3SDag-Erling Smørgrav.%D June 1999 81006b533d3SDag-Erling Smørgrav.%B HTTP Authentication: Basic and Digest Access Authentication 81106b533d3SDag-Erling Smørgrav.%O RFC2617 8124ca1ab94SDag-Erling Smørgrav.Re 8134ca1ab94SDag-Erling Smørgrav.Sh HISTORY 8144ca1ab94SDag-Erling SmørgravThe 8154ca1ab94SDag-Erling Smørgrav.Nm fetch 8164ca1ab94SDag-Erling Smørgravlibrary first appeared in 8174ca1ab94SDag-Erling Smørgrav.Fx 3.0 . 8184ca1ab94SDag-Erling Smørgrav.Sh AUTHORS 819725ab628SRuslan Ermilov.An -nosplit 8204ca1ab94SDag-Erling SmørgravThe 8214ca1ab94SDag-Erling Smørgrav.Nm fetch 8224ca1ab94SDag-Erling Smørgravlibrary was mostly written by 8236cfac37bSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org 82478122aacSDag-Erling Smørgravwith numerous suggestions and contributions from 8256cfac37bSBaptiste Daroussin.An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org , 8266cfac37bSBaptiste Daroussin.An Eugene Skepner Aq Mt eu@qub.com , 8276cfac37bSBaptiste Daroussin.An Hajimu Umemoto Aq Mt ume@FreeBSD.org , 8286cfac37bSBaptiste Daroussin.An Henry Whincup Aq Mt henry@techiebod.com , 8296cfac37bSBaptiste Daroussin.An Jukka A. Ukkonen Aq Mt jau@iki.fi , 8306cfac37bSBaptiste Daroussin.An Jean-Fran\(,cois Dockes Aq Mt jf@dockes.org , 8316cfac37bSBaptiste Daroussin.An Michael Gmelin Aq Mt freebsd@grem.de 83278122aacSDag-Erling Smørgravand others. 833d8acd8dcSDag-Erling SmørgravIt replaces the older 8344ca1ab94SDag-Erling Smørgrav.Nm ftpio 835d8acd8dcSDag-Erling Smørgravlibrary written by 8366cfac37bSBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org 837d8acd8dcSDag-Erling Smørgravand 8386cfac37bSBaptiste Daroussin.An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org . 8394ca1ab94SDag-Erling Smørgrav.Pp 8404ca1ab94SDag-Erling SmørgravThis manual page was written by 8416cfac37bSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org 842dcd47379SDag-Erling Smørgravand 8436cfac37bSBaptiste Daroussin.An Michael Gmelin Aq Mt freebsd@grem.de . 8444ca1ab94SDag-Erling Smørgrav.Sh BUGS 845c6ff3a1bSSheldon HearnSome parts of the library are not yet implemented. 846c6ff3a1bSSheldon HearnThe most notable 847d8acd8dcSDag-Erling Smørgravexamples of this are 848d8acd8dcSDag-Erling Smørgrav.Fn fetchPutHTTP , 849ce71b736SDag-Erling Smørgrav.Fn fetchListHTTP , 85015efcd39SAlexey Zelkin.Fn fetchListFTP 851d8acd8dcSDag-Erling Smørgravand FTP proxy support. 852d8acd8dcSDag-Erling Smørgrav.Pp 85336a142c4SRuslan ErmilovThere is no way to select a proxy at run-time other than setting the 854db5f8cebSDag-Erling Smørgrav.Ev HTTP_PROXY 855db5f8cebSDag-Erling Smørgravor 856db5f8cebSDag-Erling Smørgrav.Ev FTP_PROXY 857c6ff3a1bSSheldon Hearnenvironment variables as appropriate. 85898f5573fSDag-Erling Smørgrav.Pp 859842a95ccSDag-Erling Smørgrav.Nm libfetch 86098f5573fSDag-Erling Smørgravdoes not understand or obey 305 (Use Proxy) replies. 86198f5573fSDag-Erling Smørgrav.Pp 862842a95ccSDag-Erling SmørgravError numbers are unique only within a certain context; the error 863842a95ccSDag-Erling Smørgravcodes used for FTP and HTTP overlap, as do those used for resolver and 864c6ff3a1bSSheldon Hearnsystem errors. 865c6ff3a1bSSheldon HearnFor instance, error code 202 means "Command not 866842a95ccSDag-Erling Smørgravimplemented, superfluous at this site" in an FTP context and 867842a95ccSDag-Erling Smørgrav"Accepted" in an HTTP context. 868842a95ccSDag-Erling Smørgrav.Pp 869f5f109a0SDag-Erling Smørgrav.Fn fetchStatFTP 870f5f109a0SDag-Erling Smørgravdoes not check that the result of an MDTM command is a valid date. 871f5f109a0SDag-Erling Smørgrav.Pp 872dcd47379SDag-Erling SmørgravIn case password protected keys are used for client certificate based 873dcd47379SDag-Erling Smørgravauthentication the user is prompted for the password on each and every 874dcd47379SDag-Erling Smørgravfetch operation. 875dcd47379SDag-Erling Smørgrav.Pp 8761a5faa10SDag-Erling SmørgravThe man page is incomplete, poorly written and produces badly 8771a5faa10SDag-Erling Smørgravformatted text. 878db5f8cebSDag-Erling Smørgrav.Pp 879ba101983SDag-Erling SmørgravThe error reporting mechanism is unsatisfactory. 880ba101983SDag-Erling Smørgrav.Pp 881ba101983SDag-Erling SmørgravSome parts of the code are not fully reentrant. 882