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.\" 27*2821a749SDag-Erling Smørgrav.Dd October 7, 2023 284ca1ab94SDag-Erling Smørgrav.Dt FETCH 3 294ca1ab94SDag-Erling Smørgrav.Os 304ca1ab94SDag-Erling Smørgrav.Sh NAME 319a964d6aSDag-Erling Smørgrav.Nm fetchMakeURL , 3260245e42SDag-Erling Smørgrav.Nm fetchParseURL , 3360245e42SDag-Erling Smørgrav.Nm fetchFreeURL , 341a5faa10SDag-Erling Smørgrav.Nm fetchXGetURL , 354ca1ab94SDag-Erling Smørgrav.Nm fetchGetURL , 364ca1ab94SDag-Erling Smørgrav.Nm fetchPutURL , 37d8acd8dcSDag-Erling Smørgrav.Nm fetchStatURL , 38ce71b736SDag-Erling Smørgrav.Nm fetchListURL , 391a5faa10SDag-Erling Smørgrav.Nm fetchXGet , 40db5f8cebSDag-Erling Smørgrav.Nm fetchGet , 41db5f8cebSDag-Erling Smørgrav.Nm fetchPut , 42d8acd8dcSDag-Erling Smørgrav.Nm fetchStat , 43ce71b736SDag-Erling Smørgrav.Nm fetchList , 441a5faa10SDag-Erling Smørgrav.Nm fetchXGetFile , 454ca1ab94SDag-Erling Smørgrav.Nm fetchGetFile , 464ca1ab94SDag-Erling Smørgrav.Nm fetchPutFile , 47d8acd8dcSDag-Erling Smørgrav.Nm fetchStatFile , 48ce71b736SDag-Erling Smørgrav.Nm fetchListFile , 491a5faa10SDag-Erling Smørgrav.Nm fetchXGetHTTP , 504ca1ab94SDag-Erling Smørgrav.Nm fetchGetHTTP , 514ca1ab94SDag-Erling Smørgrav.Nm fetchPutHTTP , 52d8acd8dcSDag-Erling Smørgrav.Nm fetchStatHTTP , 53ce71b736SDag-Erling Smørgrav.Nm fetchListHTTP , 54f4e05cc5SMark Johnston.Nm fetchReqHTTP , 551a5faa10SDag-Erling Smørgrav.Nm fetchXGetFTP , 564ca1ab94SDag-Erling Smørgrav.Nm fetchGetFTP , 5715efcd39SAlexey Zelkin.Nm fetchPutFTP , 5815efcd39SAlexey Zelkin.Nm fetchStatFTP , 5915efcd39SAlexey Zelkin.Nm fetchListFTP 6015efcd39SAlexey Zelkin.Nd file transfer functions 6115efcd39SAlexey Zelkin.Sh LIBRARY 6215efcd39SAlexey Zelkin.Lb libfetch 634ca1ab94SDag-Erling Smørgrav.Sh SYNOPSIS 6432eef9aeSRuslan Ermilov.In sys/param.h 6532eef9aeSRuslan Ermilov.In stdio.h 6632eef9aeSRuslan Ermilov.In fetch.h 6760245e42SDag-Erling Smørgrav.Ft struct url * 6838c7e4a6SArchie Cobbs.Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd" 699a964d6aSDag-Erling Smørgrav.Ft struct url * 7038c7e4a6SArchie Cobbs.Fn fetchParseURL "const char *URL" 7160245e42SDag-Erling Smørgrav.Ft void 7238c7e4a6SArchie Cobbs.Fn fetchFreeURL "struct url *u" 73db5f8cebSDag-Erling Smørgrav.Ft FILE * 7438c7e4a6SArchie Cobbs.Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags" 751a5faa10SDag-Erling Smørgrav.Ft FILE * 7638c7e4a6SArchie Cobbs.Fn fetchGetURL "const char *URL" "const char *flags" 77db5f8cebSDag-Erling Smørgrav.Ft FILE * 7838c7e4a6SArchie Cobbs.Fn fetchPutURL "const char *URL" "const char *flags" 79d8acd8dcSDag-Erling Smørgrav.Ft int 8038c7e4a6SArchie Cobbs.Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags" 81ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 8238c7e4a6SArchie Cobbs.Fn fetchListURL "const char *URL" "const char *flags" 834ca1ab94SDag-Erling Smørgrav.Ft FILE * 8438c7e4a6SArchie Cobbs.Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags" 851a5faa10SDag-Erling Smørgrav.Ft FILE * 8638c7e4a6SArchie Cobbs.Fn fetchGet "struct url *u" "const char *flags" 87db5f8cebSDag-Erling Smørgrav.Ft FILE * 8838c7e4a6SArchie Cobbs.Fn fetchPut "struct url *u" "const char *flags" 89d8acd8dcSDag-Erling Smørgrav.Ft int 9038c7e4a6SArchie Cobbs.Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags" 91ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 9238c7e4a6SArchie Cobbs.Fn fetchList "struct url *u" "const char *flags" 93db5f8cebSDag-Erling Smørgrav.Ft FILE * 9438c7e4a6SArchie Cobbs.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags" 951a5faa10SDag-Erling Smørgrav.Ft FILE * 9638c7e4a6SArchie Cobbs.Fn fetchGetFile "struct url *u" "const char *flags" 974ca1ab94SDag-Erling Smørgrav.Ft FILE * 9838c7e4a6SArchie Cobbs.Fn fetchPutFile "struct url *u" "const char *flags" 99d8acd8dcSDag-Erling Smørgrav.Ft int 10038c7e4a6SArchie Cobbs.Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags" 101ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 10238c7e4a6SArchie Cobbs.Fn fetchListFile "struct url *u" "const char *flags" 1034ca1ab94SDag-Erling Smørgrav.Ft FILE * 10438c7e4a6SArchie Cobbs.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags" 1051a5faa10SDag-Erling Smørgrav.Ft FILE * 10638c7e4a6SArchie Cobbs.Fn fetchGetHTTP "struct url *u" "const char *flags" 1074ca1ab94SDag-Erling Smørgrav.Ft FILE * 10838c7e4a6SArchie Cobbs.Fn fetchPutHTTP "struct url *u" "const char *flags" 109d8acd8dcSDag-Erling Smørgrav.Ft int 11038c7e4a6SArchie Cobbs.Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags" 111ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 11238c7e4a6SArchie Cobbs.Fn fetchListHTTP "struct url *u" "const char *flags" 1134ca1ab94SDag-Erling Smørgrav.Ft FILE * 114f4e05cc5SMark Johnston.Fn fetchReqHTTP "struct url *u" "const char *method" "const char *flags" "const char *content_type" "const char *body" 115f4e05cc5SMark Johnston.Ft FILE * 11638c7e4a6SArchie Cobbs.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags" 1171a5faa10SDag-Erling Smørgrav.Ft FILE * 11838c7e4a6SArchie Cobbs.Fn fetchGetFTP "struct url *u" "const char *flags" 1194ca1ab94SDag-Erling Smørgrav.Ft FILE * 12038c7e4a6SArchie Cobbs.Fn fetchPutFTP "struct url *u" "const char *flags" 121d8acd8dcSDag-Erling Smørgrav.Ft int 12238c7e4a6SArchie Cobbs.Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags" 123ce71b736SDag-Erling Smørgrav.Ft struct url_ent * 12438c7e4a6SArchie Cobbs.Fn fetchListFTP "struct url *u" "const char *flags" 1254ca1ab94SDag-Erling Smørgrav.Sh DESCRIPTION 1264ca1ab94SDag-Erling SmørgravThese functions implement a high-level library for retrieving and 1274ca1ab94SDag-Erling Smørgravuploading files using Uniform Resource Locators (URLs). 1284ca1ab94SDag-Erling Smørgrav.Pp 12960245e42SDag-Erling Smørgrav.Fn fetchParseURL 13060245e42SDag-Erling Smørgravtakes a URL in the form of a null-terminated string and splits it into 13160245e42SDag-Erling Smørgravits components function according to the Common Internet Scheme Syntax 1329364c532SDag-Erling Smørgravdetailed in RFC1738. 1339364c532SDag-Erling SmørgravA regular expression which produces this syntax is: 13460245e42SDag-Erling Smørgrav.Bd -literal 13560245e42SDag-Erling Smørgrav <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)? 13660245e42SDag-Erling Smørgrav.Ed 13760245e42SDag-Erling Smørgrav.Pp 1381df2031cSDag-Erling SmørgravIf the URL does not seem to begin with a scheme name, the following 1391df2031cSDag-Erling Smørgravsyntax is assumed: 1401df2031cSDag-Erling Smørgrav.Bd -literal 1411df2031cSDag-Erling Smørgrav ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)? 1421df2031cSDag-Erling Smørgrav.Ed 1431df2031cSDag-Erling Smørgrav.Pp 14460245e42SDag-Erling SmørgravNote that some components of the URL are not necessarily relevant to 14560245e42SDag-Erling Smørgravall URL schemes. 1461df2031cSDag-Erling SmørgravFor instance, the file scheme only needs the <scheme> and <document> 1471df2031cSDag-Erling Smørgravcomponents. 14860245e42SDag-Erling Smørgrav.Pp 1499a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL 1509a964d6aSDag-Erling Smørgravand 15140ac2845SDag-Erling Smørgrav.Fn fetchParseURL 1529a964d6aSDag-Erling Smørgravreturn a pointer to a 153a7e16a9dSRuslan Ermilov.Vt url 15440ac2845SDag-Erling Smørgravstructure, which is defined as follows in 155fe08efe6SRuslan Ermilov.In fetch.h : 15640ac2845SDag-Erling Smørgrav.Bd -literal 15740ac2845SDag-Erling Smørgrav#define URL_SCHEMELEN 16 15840ac2845SDag-Erling Smørgrav#define URL_USERLEN 256 15940ac2845SDag-Erling Smørgrav#define URL_PWDLEN 256 16040ac2845SDag-Erling Smørgrav 16140ac2845SDag-Erling Smørgravstruct url { 16240ac2845SDag-Erling Smørgrav char scheme[URL_SCHEMELEN+1]; 16340ac2845SDag-Erling Smørgrav char user[URL_USERLEN+1]; 16440ac2845SDag-Erling Smørgrav char pwd[URL_PWDLEN+1]; 16540ac2845SDag-Erling Smørgrav char host[MAXHOSTNAMELEN+1]; 16640ac2845SDag-Erling Smørgrav int port; 16740ac2845SDag-Erling Smørgrav char *doc; 16840ac2845SDag-Erling Smørgrav off_t offset; 16940ac2845SDag-Erling Smørgrav size_t length; 1707f92799fSMurray Stokely time_t ims_time; 17140ac2845SDag-Erling Smørgrav}; 17240ac2845SDag-Erling Smørgrav.Ed 17340ac2845SDag-Erling Smørgrav.Pp 1747f92799fSMurray StokelyThe 1757f92799fSMurray Stokely.Va ims_time 1767f92799fSMurray Stokelyfield stores the time value for 1777f92799fSMurray Stokely.Li If-Modified-Since 1787f92799fSMurray StokelyHTTP requests. 1797f92799fSMurray Stokely.Pp 18060245e42SDag-Erling SmørgravThe pointer returned by 1819a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL 1829a964d6aSDag-Erling Smørgravor 18360245e42SDag-Erling Smørgrav.Fn fetchParseURL 18460245e42SDag-Erling Smørgravshould be freed using 18560245e42SDag-Erling Smørgrav.Fn fetchFreeURL . 18660245e42SDag-Erling Smørgrav.Pp 1871a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL , 1881a5faa10SDag-Erling Smørgrav.Fn fetchGetURL , 189db5f8cebSDag-Erling Smørgravand 190db5f8cebSDag-Erling Smørgrav.Fn fetchPutURL 191db5f8cebSDag-Erling Smørgravconstitute the recommended interface to the 192db5f8cebSDag-Erling Smørgrav.Nm fetch 193c6ff3a1bSSheldon Hearnlibrary. 194c6ff3a1bSSheldon HearnThey examine the URL passed to them to determine the transfer 195db5f8cebSDag-Erling Smørgravmethod, and call the appropriate lower-level functions to perform the 196c6ff3a1bSSheldon Hearnactual transfer. 1971a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL 1981a5faa10SDag-Erling Smørgravalso returns the remote document's metadata in the 199a7e16a9dSRuslan Ermilov.Vt url_stat 2001a5faa10SDag-Erling Smørgravstructure pointed to by the 2011a5faa10SDag-Erling Smørgrav.Fa us 2021a5faa10SDag-Erling Smørgravargument. 2031a5faa10SDag-Erling Smørgrav.Pp 204c6ff3a1bSSheldon HearnThe 205db5f8cebSDag-Erling Smørgrav.Fa flags 206c6ff3a1bSSheldon Hearnargument is a string of characters which specify transfer options. 207c6ff3a1bSSheldon HearnThe 208db5f8cebSDag-Erling Smørgravmeaning of the individual flags is scheme-dependent, and is detailed 209db5f8cebSDag-Erling Smørgravin the appropriate section below. 210db5f8cebSDag-Erling Smørgrav.Pp 211d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL 212d8acd8dcSDag-Erling Smørgravattempts to obtain the requested document's metadata and fill in the 2135e75e35cSDima Dorfmanstructure pointed to by its second argument. 214c6ff3a1bSSheldon HearnThe 215a7e16a9dSRuslan Ermilov.Vt url_stat 216d8acd8dcSDag-Erling Smørgravstructure is defined as follows in 217fe08efe6SRuslan Ermilov.In fetch.h : 218d8acd8dcSDag-Erling Smørgrav.Bd -literal 219d8acd8dcSDag-Erling Smørgravstruct url_stat { 220d8acd8dcSDag-Erling Smørgrav off_t size; 2215aea254fSDag-Erling Smørgrav time_t atime; 2225aea254fSDag-Erling Smørgrav time_t mtime; 223d8acd8dcSDag-Erling Smørgrav}; 224d8acd8dcSDag-Erling Smørgrav.Ed 225d8acd8dcSDag-Erling Smørgrav.Pp 22640ac2845SDag-Erling SmørgravIf the size could not be obtained from the server, the 22740ac2845SDag-Erling Smørgrav.Fa size 22840ac2845SDag-Erling Smørgravfield is set to -1. 22940ac2845SDag-Erling SmørgravIf the modification time could not be obtained from the server, the 23040ac2845SDag-Erling Smørgrav.Fa mtime 23140ac2845SDag-Erling Smørgravfield is set to the epoch. 23240ac2845SDag-Erling SmørgravIf the access time could not be obtained from the server, the 23340ac2845SDag-Erling Smørgrav.Fa atime 23440ac2845SDag-Erling Smørgravfield is set to the modification time. 23540ac2845SDag-Erling Smørgrav.Pp 236ce71b736SDag-Erling Smørgrav.Fn fetchListURL 237ce71b736SDag-Erling Smørgravattempts to list the contents of the directory pointed to by the URL 238c6ff3a1bSSheldon Hearnprovided. 239c6ff3a1bSSheldon HearnIf successful, it returns a malloced array of 240a7e16a9dSRuslan Ermilov.Vt url_ent 241c6ff3a1bSSheldon Hearnstructures. 242c6ff3a1bSSheldon HearnThe 243a7e16a9dSRuslan Ermilov.Vt url_ent 244ce71b736SDag-Erling Smørgravstructure is defined as follows in 245fe08efe6SRuslan Ermilov.In fetch.h : 246ce71b736SDag-Erling Smørgrav.Bd -literal 247ce71b736SDag-Erling Smørgravstruct url_ent { 248e97f516cSDag-Erling Smørgrav char name[PATH_MAX]; 249ce71b736SDag-Erling Smørgrav struct url_stat stat; 250ce71b736SDag-Erling Smørgrav}; 251ce71b736SDag-Erling Smørgrav.Ed 252ce71b736SDag-Erling Smørgrav.Pp 253ce71b736SDag-Erling SmørgravThe list is terminated by an entry with an empty name. 254ce71b736SDag-Erling Smørgrav.Pp 255ce71b736SDag-Erling SmørgravThe pointer returned by 256ce71b736SDag-Erling Smørgrav.Fn fetchListURL 257ce71b736SDag-Erling Smørgravshould be freed using 258ce71b736SDag-Erling Smørgrav.Fn free . 259ce71b736SDag-Erling Smørgrav.Pp 2601a5faa10SDag-Erling Smørgrav.Fn fetchXGet , 261d8acd8dcSDag-Erling Smørgrav.Fn fetchGet , 262db5f8cebSDag-Erling Smørgrav.Fn fetchPut 2634ca1ab94SDag-Erling Smørgravand 264d8acd8dcSDag-Erling Smørgrav.Fn fetchStat 265d8acd8dcSDag-Erling Smørgravare similar to 2661a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL , 267d8acd8dcSDag-Erling Smørgrav.Fn fetchGetURL , 268d8acd8dcSDag-Erling Smørgrav.Fn fetchPutURL 269d8acd8dcSDag-Erling Smørgravand 270d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL , 271db5f8cebSDag-Erling Smørgravexcept that they expect a pre-parsed URL in the form of a pointer to 272d8acd8dcSDag-Erling Smørgrava 273a7e16a9dSRuslan Ermilov.Vt struct url 274d8acd8dcSDag-Erling Smørgravrather than a string. 2754ca1ab94SDag-Erling Smørgrav.Pp 2764ca1ab94SDag-Erling SmørgravAll of the 2771a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX , 2784ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX 2794ca1ab94SDag-Erling Smørgravand 2804ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX 2814ca1ab94SDag-Erling Smørgravfunctions return a pointer to a stream which can be used to read or 282c6ff3a1bSSheldon Hearnwrite data from or to the requested document, respectively. 283c6ff3a1bSSheldon HearnNote that 2844ca1ab94SDag-Erling Smørgravalthough the implementation details of the individual access methods 2854ca1ab94SDag-Erling Smørgravvary, it can generally be assumed that a stream returned by one of the 2861a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX 2871a5faa10SDag-Erling Smørgravor 2884ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX 2894ca1ab94SDag-Erling Smørgravfunctions is read-only, and that a stream returned by one of the 2904ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX 2914ca1ab94SDag-Erling Smørgravfunctions is write-only. 2924ca1ab94SDag-Erling Smørgrav.Sh FILE SCHEME 2931a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile , 2944ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile 2954ca1ab94SDag-Erling Smørgravand 2964ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile 2974ca1ab94SDag-Erling Smørgravprovide access to documents which are files in a locally mounted file 298c6ff3a1bSSheldon Hearnsystem. 299c6ff3a1bSSheldon HearnOnly the <document> component of the URL is used. 3004ca1ab94SDag-Erling Smørgrav.Pp 3011a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile 3021a5faa10SDag-Erling Smørgravand 3034ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile 3041a5faa10SDag-Erling Smørgravdo not accept any flags. 3054ca1ab94SDag-Erling Smørgrav.Pp 3064ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile 3074ca1ab94SDag-Erling Smørgravaccepts the 308a7e16a9dSRuslan Ermilov.Ql a 309c6ff3a1bSSheldon Hearn(append to file) flag. 310c6ff3a1bSSheldon HearnIf that flag is specified, the data written to 3114ca1ab94SDag-Erling Smørgravthe stream returned by 3124ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile 3134ca1ab94SDag-Erling Smørgravwill be appended to the previous contents of the file, instead of 3144ca1ab94SDag-Erling Smørgravreplacing them. 3154ca1ab94SDag-Erling Smørgrav.Sh FTP SCHEME 3161a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP , 3174ca1ab94SDag-Erling Smørgrav.Fn fetchGetFTP 3184ca1ab94SDag-Erling Smørgravand 3194ca1ab94SDag-Erling Smørgrav.Fn fetchPutFTP 3204ca1ab94SDag-Erling Smørgravimplement the FTP protocol as described in RFC959. 3214ca1ab94SDag-Erling Smørgrav.Pp 3224ca1ab94SDag-Erling SmørgravIf the 323ecd18c96SDag-Erling Smørgrav.Ql P 324ecd18c96SDag-Erling Smørgrav(not passive) flag is specified, an active (rather than passive) 325ecd18c96SDag-Erling Smørgravconnection will be attempted. 326ecd18c96SDag-Erling Smørgrav.Pp 327ecd18c96SDag-Erling SmørgravThe 328a7e16a9dSRuslan Ermilov.Ql p 329ecd18c96SDag-Erling Smørgravflag is supported for compatibility with earlier versions where active 330ecd18c96SDag-Erling Smørgravconnections were the default. 331ecd18c96SDag-Erling SmørgravIt has precedence over the 332ecd18c96SDag-Erling Smørgrav.Ql P 333ecd18c96SDag-Erling Smørgravflag, so if both are specified, 334ecd18c96SDag-Erling Smørgrav.Nm 335ecd18c96SDag-Erling Smørgravwill use a passive connection. 3364ca1ab94SDag-Erling Smørgrav.Pp 337f5f109a0SDag-Erling SmørgravIf the 338a7e16a9dSRuslan Ermilov.Ql l 339d5f175ceSDag-Erling Smørgrav(low) flag is specified, data sockets will be allocated in the low (or 340d5c24aa8SBill Fennerdefault) port range instead of the high port range (see 341f5f109a0SDag-Erling Smørgrav.Xr ip 4 ) . 342f5f109a0SDag-Erling Smørgrav.Pp 343f5f109a0SDag-Erling SmørgravIf the 344a7e16a9dSRuslan Ermilov.Ql d 345f5f109a0SDag-Erling Smørgrav(direct) flag is specified, 3461a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP , 347f5f109a0SDag-Erling Smørgrav.Fn fetchGetFTP 348f5f109a0SDag-Erling Smørgravand 349f5f109a0SDag-Erling Smørgrav.Fn fetchPutFTP 350f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined. 351f5f109a0SDag-Erling Smørgrav.Pp 3524ca1ab94SDag-Erling SmørgravIf no user name or password is given, the 3534ca1ab94SDag-Erling Smørgrav.Nm fetch 354c86c6f74SDag-Erling Smørgravlibrary will attempt an anonymous login, with user name "anonymous" 355c86c6f74SDag-Erling Smørgravand password "anonymous@<hostname>". 3564ca1ab94SDag-Erling Smørgrav.Sh HTTP SCHEME 3574ca1ab94SDag-Erling SmørgravThe 3581a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP , 359f4e05cc5SMark Johnston.Fn fetchGetHTTP , 3604ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP 361f4e05cc5SMark Johnstonand 362f4e05cc5SMark Johnston.Fn fetchReqHTTP 363c6ff3a1bSSheldon Hearnfunctions implement the HTTP/1.1 protocol. 36436a142c4SRuslan ErmilovWith a little luck, there is 36506b533d3SDag-Erling Smørgraveven a chance that they comply with RFC2616 and RFC2617. 3664ca1ab94SDag-Erling Smørgrav.Pp 367f5f109a0SDag-Erling SmørgravIf the 368a7e16a9dSRuslan Ermilov.Ql d 369f5f109a0SDag-Erling Smørgrav(direct) flag is specified, 3701a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP , 371f5f109a0SDag-Erling Smørgrav.Fn fetchGetHTTP 372f5f109a0SDag-Erling Smørgravand 373f5f109a0SDag-Erling Smørgrav.Fn fetchPutHTTP 374f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined. 375f5f109a0SDag-Erling Smørgrav.Pp 3767f92799fSMurray StokelyIf the 3777f92799fSMurray Stokely.Ql i 3787f92799fSMurray Stokely(if-modified-since) flag is specified, and 3797f92799fSMurray Stokelythe 3807f92799fSMurray Stokely.Va ims_time 3817f92799fSMurray Stokelyfield is set in 3827f92799fSMurray Stokely.Vt "struct url" , 3837f92799fSMurray Stokelythen 3847f92799fSMurray Stokely.Fn fetchXGetHTTP 3857f92799fSMurray Stokelyand 3867f92799fSMurray Stokely.Fn fetchGetHTTP 3877f92799fSMurray Stokelywill send a conditional 3887f92799fSMurray Stokely.Li If-Modified-Since 3897f92799fSMurray StokelyHTTP header to only fetch the content if it is newer than 3907f92799fSMurray Stokely.Va ims_time . 3917f92799fSMurray Stokely.Pp 392f4e05cc5SMark JohnstonThe function 393f4e05cc5SMark Johnston.Fn fetchReqHTTP 394f4e05cc5SMark Johnstoncan be used to make requests with an arbitrary HTTP verb, 395f4e05cc5SMark Johnstonincluding POST, DELETE, CONNECT, OPTIONS, TRACE or PATCH. 396f4e05cc5SMark JohnstonThis can be done by setting the argument 397f4e05cc5SMark Johnston.Fa method 398f4e05cc5SMark Johnstonto the intended verb, such as 399f4e05cc5SMark Johnston.Ql POST , 400f4e05cc5SMark Johnstonand 401f4e05cc5SMark Johnston.Fa body 402f4e05cc5SMark Johnstonto the content. 403f4e05cc5SMark Johnston.Pp 4044ca1ab94SDag-Erling SmørgravSince there seems to be no good way of implementing the HTTP PUT 4054ca1ab94SDag-Erling Smørgravmethod in a manner consistent with the rest of the 4064ca1ab94SDag-Erling Smørgrav.Nm fetch 4074ca1ab94SDag-Erling Smørgravlibrary, 4084ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP 4094ca1ab94SDag-Erling Smørgravis currently unimplemented. 410dcd47379SDag-Erling Smørgrav.Sh HTTPS SCHEME 411dcd47379SDag-Erling SmørgravBased on HTTP SCHEME. 412dcd47379SDag-Erling SmørgravThe CA bundle used for peer verification can be changed by setting the 413dcd47379SDag-Erling Smørgravenvironment variables 414dcd47379SDag-Erling Smørgrav.Ev SSL_CA_CERT_FILE 415dcd47379SDag-Erling Smørgravto point to a concatenated bundle of trusted certificates and 416dcd47379SDag-Erling Smørgrav.Ev SSL_CA_CERT_PATH 417dcd47379SDag-Erling Smørgravto point to a directory containing hashes of trusted CAs (see 418dcd47379SDag-Erling Smørgrav.Xr verify 1 ) . 419dcd47379SDag-Erling Smørgrav.Pp 420dcd47379SDag-Erling SmørgravA certificate revocation list (CRL) can be used by setting the 421dcd47379SDag-Erling Smørgravenvironment variable 422dcd47379SDag-Erling Smørgrav.Ev SSL_CRL_FILE 423dcd47379SDag-Erling Smørgrav(see 424dcd47379SDag-Erling Smørgrav.Xr crl 1 ) . 425dcd47379SDag-Erling Smørgrav.Pp 426dcd47379SDag-Erling SmørgravPeer verification can be disabled by setting the environment variable 427dcd47379SDag-Erling Smørgrav.Ev SSL_NO_VERIFY_PEER . 428dcd47379SDag-Erling SmørgravNote that this also disables CRL checking. 429dcd47379SDag-Erling Smørgrav.Pp 430dcd47379SDag-Erling SmørgravBy default the service identity is verified according to the rules 431dcd47379SDag-Erling Smørgravdetailed in RFC6125 (also known as hostname verification). 432dcd47379SDag-Erling SmørgravThis feature can be disabled by setting the environment variable 433dcd47379SDag-Erling Smørgrav.Ev SSL_NO_VERIFY_HOSTNAME . 434dcd47379SDag-Erling Smørgrav.Pp 435dcd47379SDag-Erling SmørgravClient certificate based authentication is supported. 436dcd47379SDag-Erling SmørgravThe environment variable 437dcd47379SDag-Erling Smørgrav.Ev SSL_CLIENT_CERT_FILE 438dcd47379SDag-Erling Smørgravshould be set to point to a file containing key and client certificate 4391ec923fdSMichael Gmelinto be used in PEM format. 4401ec923fdSMichael GmelinWhen a PEM-format key is in a separate file from the client certificate, 4411ec923fdSMichael Gmelinthe environment variable 442dcd47379SDag-Erling Smørgrav.Ev SSL_CLIENT_KEY_FILE 4431ec923fdSMichael Gmelincan be set to point to the key file. 444dcd47379SDag-Erling SmørgravIn case the key uses a password, the user will be prompted on standard 445ed5e7fb1SJens Schweikhardtinput. 446dcd47379SDag-Erling Smørgrav.Pp 447dcd47379SDag-Erling SmørgravBy default 448dcd47379SDag-Erling Smørgrav.Nm libfetch 44976720765SDag-Erling Smørgravallows TLSv1 and newer when negotiating the connecting with the remote 450dcd47379SDag-Erling Smørgravpeer. 45176720765SDag-Erling SmørgravYou can change this behavior by setting the 45276720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1 , 45376720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1_1 and 45476720765SDag-Erling Smørgrav.Ev SSL_NO_TLS1_2 455fe85238eSJung-uk Kimenvironment variables to disable TLS 1.0, 1.1 and 1.2 respectively. 45606b533d3SDag-Erling Smørgrav.Sh AUTHENTICATION 45706b533d3SDag-Erling SmørgravApart from setting the appropriate environment variables and 45806b533d3SDag-Erling Smørgravspecifying the user name and password in the URL or the 459a7e16a9dSRuslan Ermilov.Vt struct url , 46006b533d3SDag-Erling Smørgravthe calling program has the option of defining an authentication 46106b533d3SDag-Erling Smørgravfunction with the following prototype: 46206b533d3SDag-Erling Smørgrav.Pp 46306b533d3SDag-Erling Smørgrav.Ft int 46406b533d3SDag-Erling Smørgrav.Fn myAuthMethod "struct url *u" 46506b533d3SDag-Erling Smørgrav.Pp 46606b533d3SDag-Erling SmørgravThe callback function should fill in the 46706b533d3SDag-Erling Smørgrav.Fa user 46806b533d3SDag-Erling Smørgravand 46906b533d3SDag-Erling Smørgrav.Fa pwd 47006b533d3SDag-Erling Smørgravfields in the provided 471a7e16a9dSRuslan Ermilov.Vt struct url 47206b533d3SDag-Erling Smørgravand return 0 on success, or any other value to indicate failure. 47306b533d3SDag-Erling Smørgrav.Pp 47406b533d3SDag-Erling SmørgravTo register the authentication callback, simply set 475a7e16a9dSRuslan Ermilov.Va fetchAuthMethod 47606b533d3SDag-Erling Smørgravto point at it. 47706b533d3SDag-Erling SmørgravThe callback will be used whenever a site requires authentication and 4780227791bSRuslan Ermilovthe appropriate environment variables are not set. 47906b533d3SDag-Erling Smørgrav.Pp 48006b533d3SDag-Erling SmørgravThis interface is experimental and may be subject to change. 4814ca1ab94SDag-Erling Smørgrav.Sh RETURN VALUES 4824ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL 4834ca1ab94SDag-Erling Smørgravreturns a pointer to a 484a7e16a9dSRuslan Ermilov.Vt struct url 485c6ff3a1bSSheldon Hearncontaining the individual components of the URL. 486c6ff3a1bSSheldon HearnIf it is 4874ca1ab94SDag-Erling Smørgravunable to allocate memory, or the URL is syntactically incorrect, 4884ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL 4894ca1ab94SDag-Erling Smørgravreturns a NULL pointer. 4904ca1ab94SDag-Erling Smørgrav.Pp 491d8acd8dcSDag-Erling SmørgravThe 492d8acd8dcSDag-Erling Smørgrav.Fn fetchStat 493d8acd8dcSDag-Erling Smørgravfunctions return 0 on success and -1 on failure. 494d8acd8dcSDag-Erling Smørgrav.Pp 4954ca1ab94SDag-Erling SmørgravAll other functions return a stream pointer which may be used to 496d8acd8dcSDag-Erling Smørgravaccess the requested document, or NULL if an error occurred. 497d8acd8dcSDag-Erling Smørgrav.Pp 498ba101983SDag-Erling SmørgravThe following error codes are defined in 499fe08efe6SRuslan Ermilov.In fetch.h : 50015efcd39SAlexey Zelkin.Bl -tag -width 18n 501d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_ABORT 502d8acd8dcSDag-Erling SmørgravOperation aborted 503d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_AUTH 504d8acd8dcSDag-Erling SmørgravAuthentication failed 505d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_DOWN 506d8acd8dcSDag-Erling SmørgravService unavailable 507d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_EXISTS 508d8acd8dcSDag-Erling SmørgravFile exists 509d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_FULL 510d8acd8dcSDag-Erling SmørgravFile system full 511d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_INFO 512d8acd8dcSDag-Erling SmørgravInformational response 513d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MEMORY 514d8acd8dcSDag-Erling SmørgravInsufficient memory 515d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MOVED 516d8acd8dcSDag-Erling SmørgravFile has moved 517d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_NETWORK 518d8acd8dcSDag-Erling SmørgravNetwork error 519d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_OK 520d8acd8dcSDag-Erling SmørgravNo error 521d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_PROTO 522d8acd8dcSDag-Erling SmørgravProtocol error 523d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_RESOLV 524d8acd8dcSDag-Erling SmørgravResolver error 525d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_SERVER 526d8acd8dcSDag-Erling SmørgravServer error 527d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TEMP 528d8acd8dcSDag-Erling SmørgravTemporary error 529d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TIMEOUT 530d8acd8dcSDag-Erling SmørgravOperation timed out 531d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNAVAIL 532d8acd8dcSDag-Erling SmørgravFile is not available 533d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNKNOWN 534d8acd8dcSDag-Erling SmørgravUnknown error 535d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_URL 536d8acd8dcSDag-Erling SmørgravInvalid URL 537d8acd8dcSDag-Erling Smørgrav.El 538d8acd8dcSDag-Erling Smørgrav.Pp 539d8acd8dcSDag-Erling SmørgravThe accompanying error message includes a protocol-specific error code 5401ec923fdSMichael Gmelinand message, like "File is not available (404 Not Found)" 5414ca1ab94SDag-Erling Smørgrav.Sh ENVIRONMENT 5423a5146d9SRuslan Ermilov.Bl -tag -width ".Ev FETCH_BIND_ADDRESS" 543c42cb9d9SDag-Erling Smørgrav.It Ev FETCH_BIND_ADDRESS 544c42cb9d9SDag-Erling SmørgravSpecifies a hostname or IP address to which sockets used for outgoing 545c42cb9d9SDag-Erling Smørgravconnections will be bound. 546659e0d5eSDag-Erling Smørgrav.It Ev FTP_LOGIN 547659e0d5eSDag-Erling SmørgravDefault FTP login if none was provided in the URL. 54891c51046SDag-Erling Smørgrav.It Ev FTP_PASSIVE_MODE 549ecd18c96SDag-Erling SmørgravIf set to 5506c81eb52SDag-Erling Smørgrav.Ql no , 551ecd18c96SDag-Erling Smørgravforces the FTP code to use active mode. 552ecd18c96SDag-Erling SmørgravIf set to any other value, forces passive mode even if the application 553ecd18c96SDag-Erling Smørgravrequested active mode. 55491c51046SDag-Erling Smørgrav.It Ev FTP_PASSWORD 55591c51046SDag-Erling SmørgravDefault FTP password if the remote server requests one and none was 55691c51046SDag-Erling Smørgravprovided in the URL. 557bc2a5e68SDag-Erling Smørgrav.It Ev FTP_PROXY 5581df2031cSDag-Erling SmørgravURL of the proxy to use for FTP requests. 5591df2031cSDag-Erling SmørgravThe document part is ignored. 5601df2031cSDag-Erling SmørgravFTP and HTTP proxies are supported; if no scheme is specified, FTP is 5611df2031cSDag-Erling Smørgravassumed. 5621df2031cSDag-Erling SmørgravIf the proxy is an FTP proxy, 563e0a9ca38SDag-Erling Smørgrav.Nm libfetch 564e0a9ca38SDag-Erling Smørgravwill send 565e0a9ca38SDag-Erling Smørgrav.Ql user@host 566e0a9ca38SDag-Erling Smørgravas user name to the proxy, where 567e0a9ca38SDag-Erling Smørgrav.Ql user 568e0a9ca38SDag-Erling Smørgravis the real user name, and 569e0a9ca38SDag-Erling Smørgrav.Ql host 570e0a9ca38SDag-Erling Smørgravis the name of the FTP server. 57189d755e1SDag-Erling Smørgrav.Pp 5722e83f638SDag-Erling SmørgravIf this variable is set to an empty string, no proxy will be used for 5732e83f638SDag-Erling SmørgravFTP requests, even if the 5742e83f638SDag-Erling Smørgrav.Ev HTTP_PROXY 5752e83f638SDag-Erling Smørgravvariable is set. 5764cee73c8SDag-Erling Smørgrav.It Ev ftp_proxy 5774cee73c8SDag-Erling SmørgravSame as 5784cee73c8SDag-Erling Smørgrav.Ev FTP_PROXY , 5794cee73c8SDag-Erling Smørgravfor compatibility. 5801453595fSDag-Erling Smørgrav.It Ev HTTP_ACCEPT 5811453595fSDag-Erling SmørgravSpecifies the value of the 5821453595fSDag-Erling Smørgrav.Va Accept 5831453595fSDag-Erling Smørgravheader for HTTP requests. 5841453595fSDag-Erling SmørgravIf empty, no 5851453595fSDag-Erling Smørgrav.Va Accept 5861453595fSDag-Erling Smørgravheader is sent. 5871453595fSDag-Erling SmørgravThe default is 5881453595fSDag-Erling Smørgrav.Dq */* . 58998f5573fSDag-Erling Smørgrav.It Ev HTTP_AUTH 59089d755e1SDag-Erling SmørgravSpecifies HTTP authorization parameters as a colon-separated list of 59189d755e1SDag-Erling Smørgravitems. 59298f5573fSDag-Erling SmørgravThe first and second item are the authorization scheme and realm 59398f5573fSDag-Erling Smørgravrespectively; further items are scheme-dependent. 59478122aacSDag-Erling SmørgravCurrently, the 59578122aacSDag-Erling Smørgrav.Dq basic 59678122aacSDag-Erling Smørgravand 59778122aacSDag-Erling Smørgrav.Dq digest 59878122aacSDag-Erling Smørgravauthorization methods are supported. 59989d755e1SDag-Erling Smørgrav.Pp 60078122aacSDag-Erling SmørgravBoth methods require two parameters: the user name and 60198f5573fSDag-Erling Smørgravpassword, in that order. 60289d755e1SDag-Erling Smørgrav.Pp 60389d755e1SDag-Erling SmørgravThis variable is only used if the server requires authorization and 60489d755e1SDag-Erling Smørgravno user name or password was specified in the URL. 605bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY 6061df2031cSDag-Erling SmørgravURL of the proxy to use for HTTP requests. 6071df2031cSDag-Erling SmørgravThe document part is ignored. 6081df2031cSDag-Erling SmørgravOnly HTTP proxies are supported for HTTP requests. 609bc2a5e68SDag-Erling SmørgravIf no port number is specified, the default is 3128. 61089d755e1SDag-Erling Smørgrav.Pp 6111df2031cSDag-Erling SmørgravNote that this proxy will also be used for FTP documents, unless the 612e0a9ca38SDag-Erling Smørgrav.Ev FTP_PROXY 613e0a9ca38SDag-Erling Smørgravvariable is set. 6144cee73c8SDag-Erling Smørgrav.It Ev http_proxy 6154cee73c8SDag-Erling SmørgravSame as 6164cee73c8SDag-Erling Smørgrav.Ev HTTP_PROXY , 6174cee73c8SDag-Erling Smørgravfor compatibility. 618bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY_AUTH 61998f5573fSDag-Erling SmørgravSpecifies authorization parameters for the HTTP proxy in the same 620e0a9ca38SDag-Erling Smørgravformat as the 621e0a9ca38SDag-Erling Smørgrav.Ev HTTP_AUTH 622e0a9ca38SDag-Erling Smørgravvariable. 62389d755e1SDag-Erling Smørgrav.Pp 6241df2031cSDag-Erling SmørgravThis variable is used if and only if connected to an HTTP proxy, and 6251df2031cSDag-Erling Smørgravis ignored if a user and/or a password were specified in the proxy 6261df2031cSDag-Erling SmørgravURL. 627d5216a4fSDag-Erling Smørgrav.It Ev HTTP_REFERER 62857bd0fc6SJens SchweikhardtSpecifies the referrer URL to use for HTTP requests. 629d5216a4fSDag-Erling SmørgravIf set to 630d5216a4fSDag-Erling Smørgrav.Dq auto , 63157bd0fc6SJens Schweikhardtthe document URL will be used as referrer URL. 6326a0cf64bSDag-Erling Smørgrav.It Ev HTTP_USER_AGENT 6336a0cf64bSDag-Erling SmørgravSpecifies the User-Agent string to use for HTTP requests. 6346a0cf64bSDag-Erling SmørgravThis can be useful when working with HTTP origin or proxy servers that 635a7e16a9dSRuslan Ermilovdifferentiate between user agents. 636c257f99eSDag-Erling SmørgravIf defined but empty, no User-Agent header is sent. 6370ab4a51eSDag-Erling Smørgrav.It Ev NETRC 6380ab4a51eSDag-Erling SmørgravSpecifies a file to use instead of 6390ab4a51eSDag-Erling Smørgrav.Pa ~/.netrc 6404d8b056eSDag-Erling Smørgravto look up login names and passwords for FTP and HTTP sites as well as 6414d8b056eSDag-Erling SmørgravHTTP proxies. 6420ab4a51eSDag-Erling SmørgravSee 6430ab4a51eSDag-Erling Smørgrav.Xr ftp 1 6440ab4a51eSDag-Erling Smørgravfor a description of the file format. 645e99ace35SDag-Erling Smørgrav.It Ev NO_PROXY 646e99ace35SDag-Erling SmørgravEither a single asterisk, which disables the use of proxies 647e99ace35SDag-Erling Smørgravaltogether, or a comma- or whitespace-separated list of hosts for 648e99ace35SDag-Erling Smørgravwhich proxies should not be used. 649e99ace35SDag-Erling Smørgrav.It Ev no_proxy 650e99ace35SDag-Erling SmørgravSame as 651e99ace35SDag-Erling Smørgrav.Ev NO_PROXY , 652e99ace35SDag-Erling Smørgravfor compatibility. 653c44be5aaSKyle Evans.It Ev SOCKS5_PROXY 654c44be5aaSKyle EvansUses SOCKS version 5 to make connection. 655c44be5aaSKyle EvansThe format must be the IP or hostname followed by a colon for the port. 656c44be5aaSKyle EvansIPv6 addresses must enclose the address in brackets. 657c44be5aaSKyle EvansIf no port is specified, the default is 1080. 658c44be5aaSKyle EvansThis setting will supercede a connection to an 659c44be5aaSKyle Evans.Ev HTTP_PROXY . 660dcd47379SDag-Erling Smørgrav.It Ev SSL_CA_CERT_FILE 661dcd47379SDag-Erling SmørgravCA certificate bundle containing trusted CA certificates. 6621ec923fdSMichael GmelinDefault value: See HTTPS SCHEME above. 663dcd47379SDag-Erling Smørgrav.It Ev SSL_CA_CERT_PATH 664dcd47379SDag-Erling SmørgravPath containing trusted CA hashes. 665dcd47379SDag-Erling Smørgrav.It Ev SSL_CLIENT_CERT_FILE 666dcd47379SDag-Erling SmørgravPEM encoded client certificate/key which will be used in 667dcd47379SDag-Erling Smørgravclient certificate authentication. 668dcd47379SDag-Erling Smørgrav.It Ev SSL_CLIENT_KEY_FILE 669dcd47379SDag-Erling SmørgravPEM encoded client key in case key and client certificate 670dcd47379SDag-Erling Smørgravare stored separately. 671dcd47379SDag-Erling Smørgrav.It Ev SSL_CRL_FILE 672dcd47379SDag-Erling SmørgravFile containing certificate revocation list. 673dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_TLS1 67476720765SDag-Erling SmørgravDo not allow TLS version 1.0 when negotiating the connection. 67576720765SDag-Erling Smørgrav.It Ev SSL_NO_TLS1_1 67676720765SDag-Erling SmørgravDo not allow TLS version 1.1 when negotiating the connection. 67776720765SDag-Erling Smørgrav.It Ev SSL_NO_TLS1_2 67876720765SDag-Erling SmørgravDo not allow TLS version 1.2 when negotiating the connection. 679dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_VERIFY_HOSTNAME 680dcd47379SDag-Erling SmørgravIf set, do not verify that the hostname matches the subject of the 681dcd47379SDag-Erling Smørgravcertificate presented by the server. 682dcd47379SDag-Erling Smørgrav.It Ev SSL_NO_VERIFY_PEER 683dcd47379SDag-Erling SmørgravIf set, do not verify the peer certificate against trusted CAs. 684bc2a5e68SDag-Erling Smørgrav.El 6850315901cSTom Rhodes.Sh EXAMPLES 6860315901cSTom RhodesTo access a proxy server on 6870315901cSTom Rhodes.Pa proxy.example.com 6880315901cSTom Rhodesport 8080, set the 6890315901cSTom Rhodes.Ev HTTP_PROXY 6900315901cSTom Rhodesenvironment variable in a manner similar to this: 6910315901cSTom Rhodes.Pp 6920315901cSTom Rhodes.Dl HTTP_PROXY=http://proxy.example.com:8080 6930315901cSTom Rhodes.Pp 6940315901cSTom RhodesIf the proxy server requires authentication, there are 6950315901cSTom Rhodestwo options available for passing the authentication data. 6960315901cSTom RhodesThe first method is by using the proxy URL: 6970315901cSTom Rhodes.Pp 6980315901cSTom Rhodes.Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080 6990315901cSTom Rhodes.Pp 7000315901cSTom RhodesThe second method is by using the 7010315901cSTom Rhodes.Ev HTTP_PROXY_AUTH 7020315901cSTom Rhodesenvironment variable: 7030315901cSTom Rhodes.Bd -literal -offset indent 7040315901cSTom RhodesHTTP_PROXY=http://proxy.example.com:8080 7050315901cSTom RhodesHTTP_PROXY_AUTH=basic:*:<user>:<pwd> 7060315901cSTom Rhodes.Ed 707e99ace35SDag-Erling Smørgrav.Pp 708e99ace35SDag-Erling SmørgravTo disable the use of a proxy for an HTTP server running on the local 709e99ace35SDag-Erling Smørgravhost, define 710e99ace35SDag-Erling Smørgrav.Ev NO_PROXY 711e99ace35SDag-Erling Smørgravas follows: 712e99ace35SDag-Erling Smørgrav.Bd -literal -offset indent 713e99ace35SDag-Erling SmørgravNO_PROXY=localhost,127.0.0.1 714e99ace35SDag-Erling Smørgrav.Ed 715dcd47379SDag-Erling Smørgrav.Pp 716c44be5aaSKyle EvansTo use a SOCKS5 proxy, set the 717c44be5aaSKyle Evans.Ev SOCKS5_PROXY 718c44be5aaSKyle Evansenvironment variable to a 719c44be5aaSKyle Evansvalid host or IP followed by an optional colon and the port. 720c44be5aaSKyle EvansIPv6 addresses must be enclosed in brackets. 721c44be5aaSKyle EvansThe following are examples of valid settings: 722c44be5aaSKyle Evans.Bd -literal -offset indent 723c44be5aaSKyle EvansSOCKS5_PROXY=proxy.example.com 724c44be5aaSKyle EvansSOCKS5_PROXY=proxy.example.com:1080 725c44be5aaSKyle EvansSOCKS5_PROXY=192.0.2.0 726c44be5aaSKyle EvansSOCKS5_PROXY=198.51.100.0:1080 727c44be5aaSKyle EvansSOCKS5_PROXY=[2001:db8::1] 728c44be5aaSKyle EvansSOCKS5_PROXY=[2001:db8::2]:1080 729c44be5aaSKyle Evans.Ed 730c44be5aaSKyle Evans.Pp 731dcd47379SDag-Erling SmørgravAccess HTTPS website without any certificate verification whatsoever: 732dcd47379SDag-Erling Smørgrav.Bd -literal -offset indent 733dcd47379SDag-Erling SmørgravSSL_NO_VERIFY_PEER=1 734dcd47379SDag-Erling SmørgravSSL_NO_VERIFY_HOSTNAME=1 735dcd47379SDag-Erling Smørgrav.Ed 736dcd47379SDag-Erling Smørgrav.Pp 737dcd47379SDag-Erling SmørgravAccess HTTPS website using client certificate based authentication 738dcd47379SDag-Erling Smørgravand a private CA: 739dcd47379SDag-Erling Smørgrav.Bd -literal -offset indent 740dcd47379SDag-Erling SmørgravSSL_CLIENT_CERT_FILE=/path/to/client.pem 741dcd47379SDag-Erling SmørgravSSL_CA_CERT_FILE=/path/to/myca.pem 742dcd47379SDag-Erling Smørgrav.Ed 7434ca1ab94SDag-Erling Smørgrav.Sh SEE ALSO 7444ca1ab94SDag-Erling Smørgrav.Xr fetch 1 , 745c86c6f74SDag-Erling Smørgrav.Xr ip 4 746c86c6f74SDag-Erling Smørgrav.Rs 747c86c6f74SDag-Erling Smørgrav.%A J. Postel 748c86c6f74SDag-Erling Smørgrav.%A J. K. Reynolds 749c86c6f74SDag-Erling Smørgrav.%D October 1985 750c86c6f74SDag-Erling Smørgrav.%B File Transfer Protocol 751c86c6f74SDag-Erling Smørgrav.%O RFC959 752c86c6f74SDag-Erling Smørgrav.Re 753c86c6f74SDag-Erling Smørgrav.Rs 754c86c6f74SDag-Erling Smørgrav.%A P. Deutsch 755c86c6f74SDag-Erling Smørgrav.%A A. Emtage 756c86c6f74SDag-Erling Smørgrav.%A A. Marine. 757c86c6f74SDag-Erling Smørgrav.%D May 1994 758c86c6f74SDag-Erling Smørgrav.%T How to Use Anonymous FTP 759c86c6f74SDag-Erling Smørgrav.%O RFC1635 76098849115SRuslan Ermilov.Re 7614ca1ab94SDag-Erling Smørgrav.Rs 7620f5fcaa3SSheldon Hearn.%A T. Berners-Lee 7630f5fcaa3SSheldon Hearn.%A L. Masinter 7640f5fcaa3SSheldon Hearn.%A M. McCahill 7654ca1ab94SDag-Erling Smørgrav.%D December 1994 7664ca1ab94SDag-Erling Smørgrav.%T Uniform Resource Locators (URL) 7674ca1ab94SDag-Erling Smørgrav.%O RFC1738 7684ca1ab94SDag-Erling Smørgrav.Re 7694ca1ab94SDag-Erling Smørgrav.Rs 7700f5fcaa3SSheldon Hearn.%A R. Fielding 7710f5fcaa3SSheldon Hearn.%A J. Gettys 7720f5fcaa3SSheldon Hearn.%A J. Mogul 7730f5fcaa3SSheldon Hearn.%A H. Frystyk 77406b533d3SDag-Erling Smørgrav.%A L. Masinter 77506b533d3SDag-Erling Smørgrav.%A P. Leach 7760f5fcaa3SSheldon Hearn.%A T. Berners-Lee 777d5c24aa8SBill Fenner.%D January 1999 7784ca1ab94SDag-Erling Smørgrav.%B Hypertext Transfer Protocol -- HTTP/1.1 77906b533d3SDag-Erling Smørgrav.%O RFC2616 78006b533d3SDag-Erling Smørgrav.Re 78106b533d3SDag-Erling Smørgrav.Rs 78206b533d3SDag-Erling Smørgrav.%A J. Franks 78306b533d3SDag-Erling Smørgrav.%A P. Hallam-Baker 78406b533d3SDag-Erling Smørgrav.%A J. Hostetler 78506b533d3SDag-Erling Smørgrav.%A S. Lawrence 78606b533d3SDag-Erling Smørgrav.%A P. Leach 78706b533d3SDag-Erling Smørgrav.%A A. Luotonen 78806b533d3SDag-Erling Smørgrav.%A L. Stewart 78906b533d3SDag-Erling Smørgrav.%D June 1999 79006b533d3SDag-Erling Smørgrav.%B HTTP Authentication: Basic and Digest Access Authentication 79106b533d3SDag-Erling Smørgrav.%O RFC2617 7924ca1ab94SDag-Erling Smørgrav.Re 7934ca1ab94SDag-Erling Smørgrav.Sh HISTORY 7944ca1ab94SDag-Erling SmørgravThe 7954ca1ab94SDag-Erling Smørgrav.Nm fetch 7964ca1ab94SDag-Erling Smørgravlibrary first appeared in 7974ca1ab94SDag-Erling Smørgrav.Fx 3.0 . 7984ca1ab94SDag-Erling Smørgrav.Sh AUTHORS 799725ab628SRuslan Ermilov.An -nosplit 8004ca1ab94SDag-Erling SmørgravThe 8014ca1ab94SDag-Erling Smørgrav.Nm fetch 8024ca1ab94SDag-Erling Smørgravlibrary was mostly written by 8036cfac37bSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org 80478122aacSDag-Erling Smørgravwith numerous suggestions and contributions from 8056cfac37bSBaptiste Daroussin.An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org , 8066cfac37bSBaptiste Daroussin.An Eugene Skepner Aq Mt eu@qub.com , 8076cfac37bSBaptiste Daroussin.An Hajimu Umemoto Aq Mt ume@FreeBSD.org , 8086cfac37bSBaptiste Daroussin.An Henry Whincup Aq Mt henry@techiebod.com , 8096cfac37bSBaptiste Daroussin.An Jukka A. Ukkonen Aq Mt jau@iki.fi , 8106cfac37bSBaptiste Daroussin.An Jean-Fran\(,cois Dockes Aq Mt jf@dockes.org , 8116cfac37bSBaptiste Daroussin.An Michael Gmelin Aq Mt freebsd@grem.de 81278122aacSDag-Erling Smørgravand others. 813d8acd8dcSDag-Erling SmørgravIt replaces the older 8144ca1ab94SDag-Erling Smørgrav.Nm ftpio 815d8acd8dcSDag-Erling Smørgravlibrary written by 8166cfac37bSBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org 817d8acd8dcSDag-Erling Smørgravand 8186cfac37bSBaptiste Daroussin.An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org . 8194ca1ab94SDag-Erling Smørgrav.Pp 8204ca1ab94SDag-Erling SmørgravThis manual page was written by 8216cfac37bSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org 822dcd47379SDag-Erling Smørgravand 8236cfac37bSBaptiste Daroussin.An Michael Gmelin Aq Mt freebsd@grem.de . 8244ca1ab94SDag-Erling Smørgrav.Sh BUGS 825c6ff3a1bSSheldon HearnSome parts of the library are not yet implemented. 826c6ff3a1bSSheldon HearnThe most notable 827d8acd8dcSDag-Erling Smørgravexamples of this are 828d8acd8dcSDag-Erling Smørgrav.Fn fetchPutHTTP , 829ce71b736SDag-Erling Smørgrav.Fn fetchListHTTP , 83015efcd39SAlexey Zelkin.Fn fetchListFTP 831d8acd8dcSDag-Erling Smørgravand FTP proxy support. 832d8acd8dcSDag-Erling Smørgrav.Pp 83336a142c4SRuslan ErmilovThere is no way to select a proxy at run-time other than setting the 834db5f8cebSDag-Erling Smørgrav.Ev HTTP_PROXY 835db5f8cebSDag-Erling Smørgravor 836db5f8cebSDag-Erling Smørgrav.Ev FTP_PROXY 837c6ff3a1bSSheldon Hearnenvironment variables as appropriate. 83898f5573fSDag-Erling Smørgrav.Pp 839842a95ccSDag-Erling Smørgrav.Nm libfetch 84098f5573fSDag-Erling Smørgravdoes not understand or obey 305 (Use Proxy) replies. 84198f5573fSDag-Erling Smørgrav.Pp 842842a95ccSDag-Erling SmørgravError numbers are unique only within a certain context; the error 843842a95ccSDag-Erling Smørgravcodes used for FTP and HTTP overlap, as do those used for resolver and 844c6ff3a1bSSheldon Hearnsystem errors. 845c6ff3a1bSSheldon HearnFor instance, error code 202 means "Command not 846842a95ccSDag-Erling Smørgravimplemented, superfluous at this site" in an FTP context and 847842a95ccSDag-Erling Smørgrav"Accepted" in an HTTP context. 848842a95ccSDag-Erling Smørgrav.Pp 849f5f109a0SDag-Erling Smørgrav.Fn fetchStatFTP 850f5f109a0SDag-Erling Smørgravdoes not check that the result of an MDTM command is a valid date. 851f5f109a0SDag-Erling Smørgrav.Pp 852dcd47379SDag-Erling SmørgravIn case password protected keys are used for client certificate based 853dcd47379SDag-Erling Smørgravauthentication the user is prompted for the password on each and every 854dcd47379SDag-Erling Smørgravfetch operation. 855dcd47379SDag-Erling Smørgrav.Pp 8561a5faa10SDag-Erling SmørgravThe man page is incomplete, poorly written and produces badly 8571a5faa10SDag-Erling Smørgravformatted text. 858db5f8cebSDag-Erling Smørgrav.Pp 859ba101983SDag-Erling SmørgravThe error reporting mechanism is unsatisfactory. 860ba101983SDag-Erling Smørgrav.Pp 861ba101983SDag-Erling SmørgravSome parts of the code are not fully reentrant. 862