OSSL_HTTP_transfer.3ossl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OSSL_HTTP_TRANSFER 3ossl"
  136. .TH OSSL_HTTP_TRANSFER 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. OSSL_HTTP_open,
  143. OSSL_HTTP_bio_cb_t,
  144. OSSL_HTTP_proxy_connect,
  145. OSSL_HTTP_set1_request,
  146. OSSL_HTTP_exchange,
  147. OSSL_HTTP_get,
  148. OSSL_HTTP_transfer,
  149. OSSL_HTTP_close
  150. \&\- HTTP client high\-level functions
  151. .SH "SYNOPSIS"
  152. .IX Header "SYNOPSIS"
  153. .Vb 1
  154. \& #include <openssl/http.h>
  155. \&
  156. \& typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg,
  157. \& int connect, int detail);
  158. \& OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port,
  159. \& const char *proxy, const char *no_proxy,
  160. \& int use_ssl, BIO *bio, BIO *rbio,
  161. \& OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
  162. \& int buf_size, int overall_timeout);
  163. \& int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port,
  164. \& const char *proxyuser, const char *proxypass,
  165. \& int timeout, BIO *bio_err, const char *prog);
  166. \& int OSSL_HTTP_set1_request(OSSL_HTTP_REQ_CTX *rctx, const char *path,
  167. \& const STACK_OF(CONF_VALUE) *headers,
  168. \& const char *content_type, BIO *req,
  169. \& const char *expected_content_type, int expect_asn1,
  170. \& size_t max_resp_len, int timeout, int keep_alive);
  171. \& BIO *OSSL_HTTP_exchange(OSSL_HTTP_REQ_CTX *rctx, char **redirection_url);
  172. \& BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
  173. \& BIO *bio, BIO *rbio,
  174. \& OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
  175. \& int buf_size, const STACK_OF(CONF_VALUE) *headers,
  176. \& const char *expected_content_type, int expect_asn1,
  177. \& size_t max_resp_len, int timeout);
  178. \& BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx,
  179. \& const char *server, const char *port,
  180. \& const char *path, int use_ssl,
  181. \& const char *proxy, const char *no_proxy,
  182. \& BIO *bio, BIO *rbio,
  183. \& OSSL_HTTP_bio_cb_t bio_update_fn, void *arg,
  184. \& int buf_size, const STACK_OF(CONF_VALUE) *headers,
  185. \& const char *content_type, BIO *req,
  186. \& const char *expected_content_type, int expect_asn1,
  187. \& size_t max_resp_len, int timeout, int keep_alive);
  188. \& int OSSL_HTTP_close(OSSL_HTTP_REQ_CTX *rctx, int ok);
  189. .Ve
  190. .SH "DESCRIPTION"
  191. .IX Header "DESCRIPTION"
  192. \&\fBOSSL_HTTP_open()\fR initiates an \s-1HTTP\s0 session using the \fIbio\fR argument if not
  193. \&\s-1NULL,\s0 else by connecting to a given \fIserver\fR optionally via a \fIproxy\fR.
  194. .PP
  195. Typically the OpenSSL build supports sockets and the \fIbio\fR parameter is \s-1NULL.\s0
  196. In this case \fIrbio\fR must be \s-1NULL\s0 as well and the \fIserver\fR must be non-NULL.
  197. The function creates a network \s-1BIO\s0 internally using \fBBIO_new_connect\fR\|(3)
  198. for connecting to the given server and the optionally given \fIport\fR,
  199. defaulting to 80 for \s-1HTTP\s0 or 443 for \s-1HTTPS.\s0
  200. Then this internal \s-1BIO\s0 is used for setting up a connection
  201. and for exchanging one or more request and response.
  202. If \fIbio\fR is given and \fIrbio\fR is \s-1NULL\s0 then this \fIbio\fR is used instead.
  203. If both \fIbio\fR and \fIrbio\fR are given (which may be memory BIOs for instance)
  204. then no explicit connection is set up, but
  205. \&\fIbio\fR is used for writing requests and \fIrbio\fR for reading responses.
  206. As soon as the client has flushed \fIbio\fR the server must be ready to provide
  207. a response or indicate a waiting condition via \fIrbio\fR.
  208. .PP
  209. If \fIbio\fR is given, it is an error to provide \fIproxy\fR or \fIno_proxy\fR arguments,
  210. while \fIserver\fR and \fIport\fR arguments may be given to support diagnostic output.
  211. If \fIbio\fR is \s-1NULL\s0 the optional \fIproxy\fR parameter can be used to set an
  212. \&\s-1HTTP\s0(S) proxy to use (unless overridden by \*(L"no_proxy\*(R" settings).
  213. If \s-1TLS\s0 is not used this defaults to the environment variable \f(CW\*(C`http_proxy\*(C'\fR
  214. if set, else \f(CW\*(C`HTTP_PROXY\*(C'\fR.
  215. If \fIuse_ssl\fR != 0 it defaults to \f(CW\*(C`https_proxy\*(C'\fR if set, else \f(CW\*(C`HTTPS_PROXY\*(C'\fR.
  216. An empty proxy string \f(CW""\fR forbids using a proxy.
  217. Else the format is
  218. \&\f(CW\*(C`[http[s]://][userinfo@]host[:port][/path][?query][#fragment]\*(C'\fR,
  219. where any userinfo, path, query, and fragment given is ignored.
  220. The default proxy port number is 80, or 443 in case \*(L"https:\*(R" is given.
  221. The \s-1HTTP\s0 client functions connect via the given proxy unless the \fIserver\fR
  222. is found in the optional list \fIno_proxy\fR of proxy hostnames (if not \s-1NULL\s0;
  223. default is the environment variable \f(CW\*(C`no_proxy\*(C'\fR if set, else \f(CW\*(C`NO_PROXY\*(C'\fR).
  224. Proxying plain \s-1HTTP\s0 is supported directly,
  225. while using a proxy for \s-1HTTPS\s0 connections requires a suitable callback function
  226. such as \fBOSSL_HTTP_proxy_connect()\fR, described below.
  227. .PP
  228. If \fIuse_ssl\fR is nonzero a \s-1TLS\s0 connection is requested
  229. and the \fIbio_update_fn\fR parameter must be provided.
  230. .PP
  231. The parameter \fIbio_update_fn\fR, which is optional if \fIuse_ssl\fR is 0,
  232. may be used to modify the connection \s-1BIO\s0 used by the \s-1HTTP\s0 client,
  233. but cannot be used when both \fIbio\fR and \fIrbio\fR are given.
  234. \&\fIbio_update_fn\fR is a \s-1BIO\s0 connect/disconnect callback function with prototype
  235. .PP
  236. .Vb 1
  237. \& BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, int detail)
  238. .Ve
  239. .PP
  240. The callback function may modify the \s-1BIO\s0 provided in the \fIbio\fR argument,
  241. whereby it may use an optional custom defined argument \fIarg\fR,
  242. which can for instance point to an \fB\s-1SSL_CTX\s0\fR structure.
  243. During connection establishment, just after calling \fBBIO_do_connect_retry()\fR, the
  244. callback function is invoked with the \fIconnect\fR argument being 1 and
  245. \&\fIdetail\fR being 1 if \fIuse_ssl\fR is nonzero (i.e., \s-1HTTPS\s0 is requested), else 0.
  246. On disconnect \fIconnect\fR is 0 and \fIdetail\fR is 1 if no error occurred, else 0.
  247. For instance, on connect the callback may push an \s-1SSL BIO\s0 to implement \s-1HTTPS\s0;
  248. after disconnect it may do some diagnostic output and pop and free the \s-1SSL BIO.\s0
  249. .PP
  250. The callback function must return either the potentially modified \s-1BIO\s0 \fIbio\fR
  251. or \s-1NULL\s0 to indicate failure, in which case it should not modify the \s-1BIO.\s0
  252. .PP
  253. Here is a simple example that supports \s-1TLS\s0 connections (but not via a proxy):
  254. .PP
  255. .Vb 5
  256. \& BIO *http_tls_cb(BIO *bio, void *arg, int connect, int detail)
  257. \& {
  258. \& if (connect && detail) { /* connecting with TLS */
  259. \& SSL_CTX *ctx = (SSL_CTX *)arg;
  260. \& BIO *sbio = BIO_new_ssl(ctx, 1);
  261. \&
  262. \& bio = sbio != NULL ? BIO_push(sbio, bio) : NULL;
  263. \& } else if (!connect) { /* disconnecting */
  264. \& BIO *hbio;
  265. \&
  266. \& if (!detail) { /* an error has occurred */
  267. \& /* optionally add diagnostics here */
  268. \& }
  269. \& BIO_ssl_shutdown(bio);
  270. \& hbio = BIO_pop(bio);
  271. \& BIO_free(bio); /* SSL BIO */
  272. \& bio = hbio;
  273. \& }
  274. \& return bio;
  275. \& }
  276. .Ve
  277. .PP
  278. After disconnect the modified \s-1BIO\s0 will be deallocated using \fBBIO_free_all()\fR.
  279. The optional callback function argument \fIarg\fR is not consumed,
  280. so must be freed by the caller when not needed any more.
  281. .PP
  282. The \fIbuf_size\fR parameter specifies the response header maximum line length.
  283. A value <= 0 means that the \fB\s-1OSSL_HTTP_DEFAULT_MAX_LINE_LEN\s0\fR (4KiB) is used.
  284. \&\fIbuf_size\fR is also used as the number of content bytes that are read at a time.
  285. .PP
  286. If the \fIoverall_timeout\fR parameter is > 0 this indicates the maximum number of
  287. seconds the overall \s-1HTTP\s0 transfer (i.e., connection setup if needed,
  288. sending requests, and receiving responses) is allowed to take until completion.
  289. A value <= 0 enables waiting indefinitely, i.e., no timeout.
  290. .PP
  291. \&\fBOSSL_HTTP_proxy_connect()\fR may be used by an above \s-1BIO\s0 connect callback function
  292. to set up an \s-1SSL/TLS\s0 connection via an \s-1HTTPS\s0 proxy.
  293. It promotes the given \s-1BIO\s0 \fIbio\fR representing a connection
  294. pre-established with a \s-1TLS\s0 proxy using the \s-1HTTP CONNECT\s0 method,
  295. optionally using proxy client credentials \fIproxyuser\fR and \fIproxypass\fR,
  296. to connect with \s-1TLS\s0 protection ultimately to \fIserver\fR and \fIport\fR.
  297. If the \fIport\fR argument is \s-1NULL\s0 or the empty string it defaults to \*(L"443\*(R".
  298. If the \fItimeout\fR parameter is > 0 this indicates the maximum number of
  299. seconds the connection setup is allowed to take.
  300. A value <= 0 enables waiting indefinitely, i.e., no timeout.
  301. Since this function is typically called by applications such as
  302. \&\fBopenssl\-s_client\fR\|(1) it uses the \fIbio_err\fR and \fIprog\fR parameters (unless
  303. \&\s-1NULL\s0) to print additional diagnostic information in a user-oriented way.
  304. .PP
  305. \&\fBOSSL_HTTP_set1_request()\fR sets up in \fIrctx\fR the request header and content data
  306. and expectations on the response using the following parameters.
  307. If <rctx> indicates using a proxy for \s-1HTTP\s0 (but not \s-1HTTPS\s0), the server host
  308. (and optionally port) needs to be placed in the header; thus it must be present
  309. in \fIrctx\fR.
  310. For backward compatibility, the server (and optional port) may also be given in
  311. the \fIpath\fR argument beginning with \f(CW\*(C`http://\*(C'\fR (thus giving an absoluteURI).
  312. If \fIpath\fR is \s-1NULL\s0 it defaults to \*(L"/\*(R".
  313. If \fIreq\fR is \s-1NULL\s0 the \s-1HTTP GET\s0 method will be used to send the request
  314. else \s-1HTTP POST\s0 with the contents of \fIreq\fR and optional \fIcontent_type\fR, where
  315. the length of the data in \fIreq\fR does not need to be determined in advance: the
  316. \&\s-1BIO\s0 will be read on-the-fly while sending the request, which supports streaming.
  317. The optional list \fIheaders\fR may contain additional custom \s-1HTTP\s0 header lines.
  318. .PP
  319. If the \fIexpected_content_type\fR argument is not \s-1NULL,\s0
  320. the client will check that the specified content-type string
  321. is included in the \s-1HTTP\s0 header of the response and return an error if not.
  322. In the content-type header line the specified string should be present either
  323. as a whole, or in case the specified string does not include a \f(CW\*(C`;\*(C'\fR character,
  324. it is sufficient that the specified string appears as a prefix
  325. in the header line, followed by a \f(CW\*(C`;\*(C'\fR character and any further text.
  326. For instance, if \fIexpected_content_type\fR specifies \f(CW\*(C`text/html\*(C'\fR,
  327. this is matched by \f(CW\*(C`text/html\*(C'\fR, \f(CW\*(C`text/html; charset=UTF\-8\*(C'\fR, etc.
  328. .PP
  329. If the \fIexpect_asn1\fR parameter is nonzero,
  330. a structure in \s-1ASN.1\s0 encoding will be expected as response content.
  331. The \fImax_resp_len\fR parameter specifies the maximum allowed
  332. response content length, where the value 0 indicates no limit.
  333. If the \fItimeout\fR parameter is > 0 this indicates the maximum number of seconds
  334. the subsequent \s-1HTTP\s0 transfer (sending the request and receiving a response)
  335. is allowed to take.
  336. A value of 0 enables waiting indefinitely, i.e., no timeout.
  337. A value < 0 indicates that the \fIoverall_timeout\fR parameter value given
  338. when opening the \s-1HTTP\s0 transfer will be used instead.
  339. If \fIkeep_alive\fR is 0 the connection is not kept open
  340. after receiving a response, which is the default behavior for \s-1HTTP 1.0.\s0
  341. If the value is 1 or 2 then a persistent connection is requested.
  342. If the value is 2 then a persistent connection is required,
  343. i.e., an error occurs in case the server does not grant it.
  344. .PP
  345. \&\fBOSSL_HTTP_exchange()\fR exchanges any form of \s-1HTTP\s0 request and response
  346. as specified by \fIrctx\fR, which must include both connection and request data,
  347. typically set up using \fBOSSL_HTTP_open()\fR and \fBOSSL_HTTP_set1_request()\fR.
  348. It implements the core of the functions described below.
  349. If the \s-1HTTP\s0 method is \s-1GET\s0 and \fIredirection_url\fR
  350. is not \s-1NULL\s0 the latter pointer is used to provide any new location that
  351. the server may return with \s-1HTTP\s0 code 301 (\s-1MOVED_PERMANENTLY\s0) or 302 (\s-1FOUND\s0).
  352. In this case the function returns \s-1NULL\s0 and the caller is
  353. responsible for deallocating the \s-1URL\s0 with \fBOPENSSL_free\fR\|(3).
  354. If the response header contains one or more \*(L"Content-Length\*(R" header lines and/or
  355. an \s-1ASN\s0.1\-encoded response is expected, which should include a total length,
  356. the length indications received are checked for consistency
  357. and for not exceeding any given maximum response length.
  358. If an \s-1ASN\s0.1\-encoded response is expected, the function returns on success
  359. the contents buffered in a memory \s-1BIO,\s0 which does not support streaming.
  360. Otherwise it returns directly the read \s-1BIO\s0 that holds the response contents,
  361. which allows a response of indefinite length and may support streaming.
  362. The caller is responsible for freeing the \s-1BIO\s0 pointer obtained.
  363. .PP
  364. \&\fBOSSL_HTTP_get()\fR uses \s-1HTTP GET\s0 to obtain data from \fIbio\fR if non-NULL,
  365. else from the server contained in the \fIurl\fR, and returns it as a \s-1BIO.\s0
  366. It supports redirection via \s-1HTTP\s0 status code 301 or 302. It is meant for
  367. transfers with a single round trip, so does not support persistent connections.
  368. If \fIbio\fR is non-NULL, any host and port components in the \fIurl\fR are not used
  369. for connecting but the hostname is used, as usual, for the \f(CW\*(C`Host\*(C'\fR header.
  370. Any userinfo and fragment components in the \fIurl\fR are ignored.
  371. Any query component is handled as part of the path component.
  372. If the scheme component of the \fIurl\fR is \f(CW\*(C`https\*(C'\fR a \s-1TLS\s0 connection is requested
  373. and the \fIbio_update_fn\fR, as described for \fBOSSL_HTTP_open()\fR, must be provided.
  374. Also the remaining parameters are interpreted as described for \fBOSSL_HTTP_open()\fR
  375. and \fBOSSL_HTTP_set1_request()\fR, respectively.
  376. The caller is responsible for freeing the \s-1BIO\s0 pointer obtained.
  377. .PP
  378. \&\fBOSSL_HTTP_transfer()\fR exchanges an \s-1HTTP\s0 request and response
  379. over a connection managed via \fIprctx\fR without supporting redirection.
  380. It combines \fBOSSL_HTTP_open()\fR, \fBOSSL_HTTP_set1_request()\fR, \fBOSSL_HTTP_exchange()\fR,
  381. and \fBOSSL_HTTP_close()\fR.
  382. If \fIprctx\fR is not \s-1NULL\s0 it reuses any open connection represented by a non-NULL
  383. \&\fI*prctx\fR. It keeps the connection open if a persistent connection is requested
  384. or required and this was granted by the server, else it closes the connection
  385. and assigns \s-1NULL\s0 to \fI*prctx\fR.
  386. The remaining parameters are interpreted as described for \fBOSSL_HTTP_open()\fR
  387. and \fBOSSL_HTTP_set1_request()\fR, respectively.
  388. The caller is responsible for freeing the \s-1BIO\s0 pointer obtained.
  389. .PP
  390. \&\fBOSSL_HTTP_close()\fR closes the connection and releases \fIrctx\fR.
  391. The \fIok\fR parameter is passed to any \s-1BIO\s0 update function
  392. given during setup as described above for \fBOSSL_HTTP_open()\fR.
  393. It must be 1 if no error occurred during the \s-1HTTP\s0 transfer and 0 otherwise.
  394. .SH "NOTES"
  395. .IX Header "NOTES"
  396. The names of the environment variables used by this implementation:
  397. \&\f(CW\*(C`http_proxy\*(C'\fR, \f(CW\*(C`HTTP_PROXY\*(C'\fR, \f(CW\*(C`https_proxy\*(C'\fR, \f(CW\*(C`HTTPS_PROXY\*(C'\fR, \f(CW\*(C`no_proxy\*(C'\fR, and
  398. \&\f(CW\*(C`NO_PROXY\*(C'\fR, have been chosen for maximal compatibility with
  399. other \s-1HTTP\s0 client implementations such as wget, curl, and git.
  400. .PP
  401. When built with tracing enabled, \fBOSSL_HTTP_transfer()\fR and all functions using it
  402. may be traced using \fB\s-1OSSL_TRACE_CATEGORY_HTTP\s0\fR.
  403. See also \fBOSSL_trace_enabled\fR\|(3) and \*(L"\s-1ENVIRONMENT\*(R"\s0 in \fBopenssl\fR\|(1).
  404. .SH "RETURN VALUES"
  405. .IX Header "RETURN VALUES"
  406. \&\fBOSSL_HTTP_open()\fR returns on success a \fB\s-1OSSL_HTTP_REQ_CTX\s0\fR, else \s-1NULL.\s0
  407. .PP
  408. \&\fBOSSL_HTTP_proxy_connect()\fR and \fBOSSL_HTTP_set1_request()\fR
  409. return 1 on success, 0 on error.
  410. .PP
  411. On success, \fBOSSL_HTTP_exchange()\fR, \fBOSSL_HTTP_get()\fR, and \fBOSSL_HTTP_transfer()\fR
  412. return a memory \s-1BIO\s0 that buffers all the data received if an \s-1ASN\s0.1\-encoded
  413. response is expected, otherwise a \s-1BIO\s0 that may support streaming.
  414. The \s-1BIO\s0 must be freed by the caller.
  415. On failure, they return \s-1NULL.\s0
  416. Failure conditions include connection/transfer timeout, parse errors, etc.
  417. The caller is responsible for freeing the \s-1BIO\s0 pointer obtained.
  418. .PP
  419. \&\fBOSSL_HTTP_close()\fR returns 0 if anything went wrong while disconnecting, else 1.
  420. .SH "SEE ALSO"
  421. .IX Header "SEE ALSO"
  422. \&\fBOSSL_HTTP_parse_url\fR\|(3), \fBBIO_new_connect\fR\|(3),
  423. \&\fBASN1_item_i2d_mem_bio\fR\|(3), \fBASN1_item_d2i_bio\fR\|(3),
  424. \&\fBOSSL_HTTP_is_alive\fR\|(3),
  425. \&\fBOSSL_trace_enabled\fR\|(3)
  426. .SH "HISTORY"
  427. .IX Header "HISTORY"
  428. All the functions described here were added in OpenSSL 3.0.
  429. .SH "COPYRIGHT"
  430. .IX Header "COPYRIGHT"
  431. Copyright 2019\-2023 The OpenSSL Project Authors. All Rights Reserved.
  432. .PP
  433. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  434. this file except in compliance with the License. You can obtain a copy
  435. in the file \s-1LICENSE\s0 in the source distribution or at
  436. <https://www.openssl.org/source/license.html>.