VirtualBox

source: vbox/trunk/include/iprt/http.h@ 74334

Last change on this file since 74334 was 74250, checked in by vboxsync, 6 years ago

IRPT/rest,http: Use header callbacks for capturing header values in responses. Removed [P]FNCREATEINSTANCE as it isn't needed any more (and it didn't work like expected for RTCRestString). Some HTTP header callback updates. bugref:9167

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.1 KB
Line 
1/* $Id: http.h 74250 2018-09-13 16:33:17Z vboxsync $ */
2/** @file
3 * IPRT - Simple HTTP/HTTPS Client API.
4 */
5
6/*
7 * Copyright (C) 2012-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___iprt_http_h
28#define ___iprt_http_h
29
30#include <iprt/types.h>
31
32RT_C_DECLS_BEGIN
33
34/** @defgroup grp_rt_http RTHttp - Simple HTTP/HTTPS Client API
35 * @ingroup grp_rt
36 * @{
37 */
38
39/** @todo the following three definitions may move the iprt/types.h later. */
40/** HTTP/HTTPS client handle. */
41typedef R3PTRTYPE(struct RTHTTPINTERNAL *) RTHTTP;
42/** Pointer to a HTTP/HTTPS client handle. */
43typedef RTHTTP *PRTHTTP;
44/** Nil HTTP/HTTPS client handle. */
45#define NIL_RTHTTP ((RTHTTP)0)
46
47
48/**
49 * Creates a HTTP client instance.
50 *
51 * @returns IPRT status code.
52 * @param phHttp Where to store the HTTP handle.
53 */
54RTR3DECL(int) RTHttpCreate(PRTHTTP phHttp);
55
56/**
57 * Resets a HTTP client instance.
58 *
59 * @returns IPRT status code.
60 * @param hHttp Handle to the HTTP interface.
61 */
62RTR3DECL(int) RTHttpReset(RTHTTP hHttp);
63
64/**
65 * Destroys a HTTP client instance.
66 *
67 * @returns IPRT status code.
68 * @param hHttp Handle to the HTTP interface.
69 */
70RTR3DECL(int) RTHttpDestroy(RTHTTP hHttp);
71
72
73/**
74 * Retrieve the redir location for 301 responses.
75 *
76 * @param hHttp Handle to the HTTP interface.
77 * @param ppszRedirLocation Where to store the string. To be freed with
78 * RTStrFree().
79 */
80RTR3DECL(int) RTHttpGetRedirLocation(RTHTTP hHttp, char **ppszRedirLocation);
81
82/**
83 * Perform a simple blocking HTTP GET request.
84 *
85 * This is a just a convenient wrapper around RTHttpGetBinary that returns a
86 * different type and sheds a parameter.
87 *
88 * @returns iprt status code.
89 *
90 * @param hHttp The HTTP client handle.
91 * @param pszUrl URL.
92 * @param ppszNotUtf8 Where to return the pointer to the HTTP response.
93 * The string is of course zero terminated. Use
94 * RTHttpFreeReponseText to free.
95 *
96 * @remarks BIG FAT WARNING!
97 *
98 * This function does not guarantee the that returned string is valid UTF-8 or
99 * any other kind of text encoding!
100 *
101 * The caller must determine and validate the string encoding _before_
102 * passing it along to functions that expect UTF-8!
103 *
104 * Also, this function does not guarantee that the returned string
105 * doesn't have embedded zeros and provides the caller no way of
106 * finding out! If you are worried about the response from the HTTPD
107 * containing embedded zero's, use RTHttpGetBinary instead.
108 */
109RTR3DECL(int) RTHttpGetText(RTHTTP hHttp, const char *pszUrl, char **ppszNotUtf8);
110
111/**
112 * Perform a simple blocking HTTP HEAD request.
113 *
114 * This is a just a convenient wrapper around RTHttpGetBinary that returns a
115 * different type and sheds a parameter.
116 *
117 * @returns iprt status code.
118 *
119 * @param hHttp The HTTP client handle.
120 * @param pszUrl URL.
121 * @param ppszNotUtf8 Where to return the pointer to the HTTP response.
122 * The string is of course zero terminated. Use
123 * RTHttpFreeReponseText to free.
124 *
125 * @remarks BIG FAT WARNING!
126 *
127 * This function does not guarantee the that returned string is valid UTF-8 or
128 * any other kind of text encoding!
129 *
130 * The caller must determine and validate the string encoding _before_
131 * passing it along to functions that expect UTF-8!
132 *
133 * Also, this function does not guarantee that the returned string
134 * doesn't have embedded zeros and provides the caller no way of
135 * finding out! If you are worried about the response from the HTTPD
136 * containing embedded zero's, use RTHttpGetHeaderBinary instead.
137 */
138RTR3DECL(int) RTHttpGetHeaderText(RTHTTP hHttp, const char *pszUrl, char **ppszNotUtf8);
139
140/**
141 * Frees memory returned by RTHttpGetText.
142 *
143 * @param pszNotUtf8 What RTHttpGetText returned.
144 */
145RTR3DECL(void) RTHttpFreeResponseText(char *pszNotUtf8);
146
147/**
148 * Perform a simple blocking HTTP GET request.
149 *
150 * @returns iprt status code.
151 *
152 * @param hHttp The HTTP client handle.
153 * @param pszUrl The URL.
154 * @param ppvResponse Where to store the HTTP response data. Use
155 * RTHttpFreeResponse to free.
156 * @param pcb Size of the returned buffer.
157 */
158RTR3DECL(int) RTHttpGetBinary(RTHTTP hHttp, const char *pszUrl, void **ppvResponse, size_t *pcb);
159
160/**
161 * Perform a simple blocking HTTP HEAD request.
162 *
163 * @returns iprt status code.
164 *
165 * @param hHttp The HTTP client handle.
166 * @param pszUrl The URL.
167 * @param ppvResponse Where to store the HTTP response data. Use
168 * RTHttpFreeResponse to free.
169 * @param pcb Size of the returned buffer.
170 */
171RTR3DECL(int) RTHttpGetHeaderBinary(RTHTTP hHttp, const char *pszUrl, void **ppvResponse, size_t *pcb);
172
173/**
174 * Frees memory returned by RTHttpGetBinary.
175 *
176 * @param pvResponse What RTHttpGetBinary returned.
177 */
178RTR3DECL(void) RTHttpFreeResponse(void *pvResponse);
179
180/**
181 * Perform a simple blocking HTTP request, writing the output to a file.
182 *
183 * @returns iprt status code.
184 *
185 * @param hHttp The HTTP client handle.
186 * @param pszUrl The URL.
187 * @param pszDstFile The destination file name.
188 */
189RTR3DECL(int) RTHttpGetFile(RTHTTP hHttp, const char *pszUrl, const char *pszDstFile);
190
191/** HTTP methods. */
192typedef enum RTHTTPMETHOD
193{
194 RTHTTPMETHOD_INVALID = 0,
195 RTHTTPMETHOD_GET,
196 RTHTTPMETHOD_PUT,
197 RTHTTPMETHOD_POST,
198 RTHTTPMETHOD_PATCH,
199 RTHTTPMETHOD_DELETE,
200 RTHTTPMETHOD_HEAD,
201 RTHTTPMETHOD_OPTIONS,
202 RTHTTPMETHOD_TRACE,
203 RTHTTPMETHOD_END,
204 RTHTTPMETHOD_32BIT_HACK = 0x7fffffff
205} RTHTTPMETHOD;
206
207/**
208 * Returns the name of the HTTP method.
209 * @returns Read only string.
210 * @param enmMethod The HTTP method to name.
211 */
212RTR3DECL(const char *) RTHttpMethodName(RTHTTPMETHOD enmMethod);
213
214/**
215 * Performs generic blocking HTTP request, optionally returning the body and headers.
216 *
217 * @returns IPRT status code.
218 * @param hHttp The HTTP client handle.
219 * @param pszUrl The URL.
220 * @param enmMethod The HTTP method for the request.
221 * @param pvReqBody Pointer to the request body. NULL if none.
222 * @param cbReqBody Size of the request body. Zero if none.
223 * @param puHttpStatus Where to return the HTTP status code. Optional.
224 * @param ppvHeaders Where to return the headers. Optional.
225 * @param pcbHeaders Where to return the header size.
226 * @param ppvBody Where to return the body. Optional.
227 * @param pcbBody Where to return the body size.
228 */
229RTR3DECL(int) RTHttpPerform(RTHTTP hHttp, const char *pszUrl, RTHTTPMETHOD enmMethod, void const *pvReqBody, size_t cbReqBody,
230 uint32_t *puHttpStatus, void **ppvHeaders, size_t *pcbHeaders, void **ppvBody, size_t *pcbBody);
231
232
233/**
234 * Abort a pending HTTP request. A blocking RTHttpGet() call will return with
235 * VERR_HTTP_ABORTED. It may take some time (current cURL implementation needs
236 * up to 1 second) before the request is aborted.
237 *
238 * @returns iprt status code.
239 *
240 * @param hHttp The HTTP client handle.
241 */
242RTR3DECL(int) RTHttpAbort(RTHTTP hHttp);
243
244/**
245 * Tells the HTTP interface to use the system proxy configuration.
246 *
247 * @returns iprt status code.
248 * @param hHttp The HTTP client handle.
249 */
250RTR3DECL(int) RTHttpUseSystemProxySettings(RTHTTP hHttp);
251
252/**
253 * Specify proxy settings.
254 *
255 * @returns iprt status code.
256 *
257 * @param hHttp The HTTP client handle.
258 * @param pszProxyUrl URL of the proxy server.
259 * @param uPort port number of the proxy, use 0 for not specifying a port.
260 * @param pszProxyUser Username, pass NULL for no authentication.
261 * @param pszProxyPwd Password, pass NULL for no authentication.
262 *
263 * @todo This API does not allow specifying the type of proxy server... We're
264 * currently assuming it's a HTTP proxy.
265 */
266RTR3DECL(int) RTHttpSetProxy(RTHTTP hHttp, const char *pszProxyUrl, uint32_t uPort,
267 const char *pszProxyUser, const char *pszProxyPwd);
268
269/**
270 * Set follow redirects (3xx)
271 *
272 * @returns iprt status code.
273 *
274 * @param hHttp The HTTP client handle.
275 * @param cMaxRedirects Max number of redirects to follow. Zero if no
276 * redirects should be followed but instead returned
277 * to caller.
278 */
279RTR3DECL(int) RTHttpSetFollowRedirects(RTHTTP hHttp, uint32_t cMaxRedirects);
280
281/**
282 * Set custom raw headers.
283 *
284 * @returns iprt status code.
285 *
286 * @param hHttp The HTTP client handle.
287 * @param cHeaders Number of custom headers.
288 * @param papszHeaders Array of headers in form "foo: bar".
289 */
290RTR3DECL(int) RTHttpSetHeaders(RTHTTP hHttp, size_t cHeaders, const char * const *papszHeaders);
291
292/** @name RTHTTPADDHDR_F_XXX - Flags for RTHttpAddRawHeader and RTHttpAddHeader
293 * @{ */
294#define RTHTTPADDHDR_F_BACK UINT32_C(0) /**< Append the header. */
295#define RTHTTPADDHDR_F_FRONT UINT32_C(1) /**< Prepend the header. */
296/** @} */
297
298/**
299 * Adds a raw header.
300 *
301 * @returns IPRT status code.
302 * @param hHttp The HTTP client handle.
303 * @param pszHeader Header string on the form "foo: bar".
304 * @param fFlags RTHTTPADDHDR_F_FRONT or RTHTTPADDHDR_F_BACK.
305 */
306RTR3DECL(int) RTHttpAddRawHeader(RTHTTP hHttp, const char *pszHeader, uint32_t fFlags);
307
308/**
309 * Adds a header field and value.
310 *
311 * @returns IPRT status code.
312 * @param hHttp The HTTP client handle.
313 * @param pszField The header field name.
314 * @param pszValue The header field value.
315 * @param cchValue The value length or RTSTR_MAX.
316 * @param fFlags Only RTHTTPADDHDR_F_FRONT or RTHTTPADDHDR_F_BACK,
317 * may be extended with encoding controlling flags if
318 * needed later.
319 */
320RTR3DECL(int) RTHttpAddHeader(RTHTTP hHttp, const char *pszField, const char *pszValue, size_t cchValue, uint32_t fFlags);
321
322/**
323 * Gets a header previously added using RTHttpSetHeaders, RTHttpAppendRawHeader
324 * or RTHttpAppendHeader.
325 *
326 * @returns Pointer to the header value on if found, otherwise NULL.
327 * @param hHttp The HTTP client handle.
328 * @param pszField The field name (no colon).
329 * @param cchField The length of the field name or RTSTR_MAX.
330 */
331RTR3DECL(const char *) RTHttpGetHeader(RTHTTP hHttp, const char *pszField, size_t cchField);
332
333/**
334 * Gets the number of headers specified by RTHttpAddHeader, RTHttpAddRawHeader or RTHttpSetHeaders.
335 *
336 * @returns Number of headers.
337 * @param hHttp The HTTP client handle.
338 * @note This can be slow and is only really intended for test cases and debugging!
339 */
340RTR3DECL(size_t) RTHttpGetHeaderCount(RTHTTP hHttp);
341
342/**
343 * Gets a header by ordinal.
344 *
345 * Can be used together with RTHttpGetHeaderCount by test case and debug code to
346 * iterate headers specified by RTHttpAddHeader, RTHttpAddRawHeader or RTHttpSetHeaders.
347 *
348 * @returns The header string ("field: value").
349 * @param hHttp The HTTP client handle.
350 * @param iOrdinal The number of the header to get.
351 * @note This can be slow and is only really intended for test cases and debugging!
352 */
353RTR3DECL(const char *) RTHttpGetByOrdinal(RTHTTP hHttp, size_t iOrdinal);
354
355/**
356 * Sign all headers present according to pending "Signing HTTP Messages" RFC.
357 *
358 * Currently hardcoded RSA-SHA-256 algorithm choice.
359 *
360 * @returns IPRT status code.
361 * @param hHttp The HTTP client handle.
362 * @param enmMethod The HTTP method that will be used for the request.
363 * @param pszUrl The target URL for the request.
364 * @param hKey The RSA key to use when signing.
365 * @param pszKeyId The key ID string corresponding to @a hKey.
366 * @param fFlags Reserved for future, MBZ.
367 *
368 * @note Caller is responsible for making all desired fields are present before
369 * making the call.
370 *
371 * @remarks Latest RFC draft at the time of writing:
372 * https://tools.ietf.org/html/draft-cavage-http-signatures-10
373 */
374RTR3DECL(int) RTHttpSignHeaders(RTHTTP hHttp, RTHTTPMETHOD enmMethod, const char *pszUrl,
375 RTCRKEY hKey, const char *pszKeyId, uint32_t fFlags);
376
377/**
378 * Tells the HTTP client instance to gather system CA certificates into a
379 * temporary file and use it for HTTPS connections.
380 *
381 * This will be called automatically if a 'https' URL is presented and
382 * RTHttpSetCaFile hasn't been called yet.
383 *
384 * @returns IPRT status code.
385 * @param hHttp The HTTP client handle.
386 * @param pErrInfo Where to store additional error/warning information.
387 * Optional.
388 */
389RTR3DECL(int) RTHttpUseTemporaryCaFile(RTHTTP hHttp, PRTERRINFO pErrInfo);
390
391/**
392 * Set a custom certification authority file, containing root certificates.
393 *
394 * @returns iprt status code.
395 *
396 * @param hHttp The HTTP client handle.
397 * @param pszCAFile File name containing root certificates.
398 *
399 * @remarks For portable HTTPS support, use RTHttpGatherCaCertsInFile and pass
400 */
401RTR3DECL(int) RTHttpSetCAFile(RTHTTP hHttp, const char *pszCAFile);
402
403/**
404 * Gathers certificates into a cryptographic (certificate) store
405 *
406 * This is a just a combination of RTHttpGatherCaCertsInStore and
407 * RTCrStoreCertExportAsPem.
408 *
409 * @returns IPRT status code.
410 * @param hStore The certificate store to gather the certificates
411 * in.
412 * @param fFlags RTHTTPGATHERCACERT_F_XXX.
413 * @param pErrInfo Where to store additional error/warning information.
414 * Optional.
415 */
416RTR3DECL(int) RTHttpGatherCaCertsInStore(RTCRSTORE hStore, uint32_t fFlags, PRTERRINFO pErrInfo);
417
418/**
419 * Gathers certificates into a file that can be used with RTHttpSetCAFile.
420 *
421 * This is a just a combination of RTHttpGatherCaCertsInStore and
422 * RTCrStoreCertExportAsPem.
423 *
424 * @returns IPRT status code.
425 * @param pszCaFile The output file.
426 * @param fFlags RTHTTPGATHERCACERT_F_XXX.
427 * @param pErrInfo Where to store additional error/warning information.
428 * Optional.
429 */
430RTR3DECL(int) RTHttpGatherCaCertsInFile(const char *pszCaFile, uint32_t fFlags, PRTERRINFO pErrInfo);
431
432/**
433 * Callback function to be called during RTHttpGet*().
434 *
435 * Register it using RTHttpSetDownloadProgressCallback().
436 *
437 * @param hHttp The HTTP client handle.
438 * @param pvUser The user parameter specified when registering the callback.
439 * @param cbDowloadTotal The content-length value, if available.
440 * Warning! Not entirely clear what it will be if
441 * unavailable, probably 0.
442 * @param cbDowloaded How much was downloaded thus far.
443 */
444typedef DECLCALLBACK(void) FNRTHTTPDOWNLDPROGRCALLBACK(RTHTTP hHttp, void *pvUser, uint64_t cbDownloadTotal, uint64_t cbDownloaded);
445/** Pointer to a download progress callback. */
446typedef FNRTHTTPDOWNLDPROGRCALLBACK *PFNRTHTTPDOWNLDPROGRCALLBACK;
447
448/**
449 * Set the callback function which is called during (GET)
450 *
451 * @returns IPRT status code.
452 * @param hHttp The HTTP client handle.
453 * @param pfnCallback Progress function to be called. Set it to
454 * NULL to disable the callback.
455 * @param pvUser Convenience pointer for the callback function.
456 */
457RTR3DECL(int) RTHttpSetDownloadProgressCallback(RTHTTP hHttp, PFNRTHTTPDOWNLDPROGRCALLBACK pfnCallback, void *pvUser);
458
459/**
460 * Callback function for receiving body data.
461 *
462 * @returns IPRT status code.
463 * @param hHttp The HTTP client handle.
464 * @param pvBuf Pointer to buffer with body bytes.
465 * @param cbBuf Number of bytes in the buffer.
466 * @param uHttpStatus The HTTP status code.
467 * @param offContent The byte offset corresponding to the start of @a pvBuf.
468 * @param cbContent The content length field value, UINT64_MAX if not available.
469 * @param pvUser The user parameter.
470 *
471 * @note The @a offContent parameter does not imply random access or anthing
472 * like that, it is just a convenience provided by the caller. The
473 * value is the sum of the previous @a cbBuf values.
474 */
475typedef DECLCALLBACK(int) FNRTHTTPDOWNLOADCALLBACK(RTHTTP hHttp, void const *pvBuf, size_t cbBuf, uint32_t uHttpStatus,
476 uint64_t offContent, uint64_t cbContent, void *pvUser);
477/** Pointer to a download data receiver callback. */
478typedef FNRTHTTPDOWNLOADCALLBACK *PFNRTHTTPDOWNLOADCALLBACK;
479
480/**
481 * Set the callback function for downloading data (HTTP GET).
482 *
483 * @returns IPRT status code.
484 * @param hHttp The HTTP client handle.
485 * @param fFlags RTHTTPDOWNLOAD_F_XXX.
486 * @param pfnCallback The callback function. Pass NULL to reset the callback.
487 * @param pvUser Convenience pointer for the callback function.
488 *
489 * @remarks There can only be one download callback, so it is not possible to
490 * call this method for different status codes. Only the last one
491 * with be honored.
492 *
493 * @note This only works reliably with RTHttpPerform at the moment.
494 */
495RTR3DECL(int) RTHttpSetDownloadCallback(RTHTTP hHttp, uint32_t fFlags, PFNRTHTTPDOWNLOADCALLBACK pfnCallback, void *pvUser);
496
497/** @name RTHTTPDOWNLOAD_F_XXX */
498/** The lower 10 bits gives the HTTP status required by the callback.
499 * For all other status codes, any body data will be returned via the
500 * RTHttpPerform ppvBody/pcbBody return parameters. */
501#define RTHTTPDOWNLOAD_F_ONLY_STATUS_MASK UINT32_C(0x000003ff)
502/** Callback requires no special HTTP status. */
503#define RTHTTPDOWNLOAD_F_ANY_STATUS UINT32_C(0x000003ff)
504/** @} */
505
506
507/**
508 * Callback function for producing body data for uploading.
509 *
510 * @returns IPRT status code.
511 * @param hHttp The HTTP client handle.
512 * @param pvBuf Where to put the data to upload
513 * @param cbBuf Max number of bytes to provide.
514 * @param offContent The byte offset corresponding to the start of @a pvBuf.
515 * @param pcbActual Actual number of bytes provided.
516 * @param pvUser The user parameter.
517 *
518 * @note The @a offContent parameter does not imply random access or anthing
519 * like that, it is just a convenience provided by the caller. The
520 * value is the sum of the previously returned @a *pcbActual values.
521 */
522typedef DECLCALLBACK(int) FNRTHTTPUPLOADCALLBACK(RTHTTP hHttp, void *pvBuf, size_t cbBuf, uint64_t offContent,
523 size_t *pcbActual, void *pvUser);
524/** Pointer to an upload data producer callback. */
525typedef FNRTHTTPUPLOADCALLBACK *PFNRTHTTPUPLOADCALLBACK;
526
527/**
528 * Set the callback function for providing upload data (HTTP PUT / POST).
529 *
530 * @returns IPRT status code.
531 * @param hHttp The HTTP client handle.
532 * @param cbContent The content length, UINT64_MAX if not know or specified separately.
533 * @param pfnCallback The callback function. Pass NULL to reset the callback.
534 * @param pvUser Convenience pointer for the callback function.
535 *
536 * @note This only works reliably with RTHttpPerform at the moment.
537 */
538RTR3DECL(int) RTHttpSetUploadCallback(RTHTTP hHttp, uint64_t cbContent, PFNRTHTTPUPLOADCALLBACK pfnCallback, void *pvUser);
539
540
541/**
542 * Callback for consuming header fields.
543 *
544 * @returns IPRT status code.
545 * @param hHttp The HTTP client handle.
546 * @param uMatchWord Match word constructed by RTHTTP_MAKE_HDR_MATCH_WORD
547 * @param pchField The field name (not zero terminated).
548 * Not necessarily valid UTF-8!
549 * @param cchField The length of the field.
550 * @param pchValue The field value (not zero terminated).
551 * Not necessarily valid UTF-8!
552 * @param cchValue The length of the value.
553 * @param pvUser The user parameter.
554 *
555 * @remarks This is called with two fictitious header fields too:
556 * - ':http-status-line' -- the HTTP/{version} {status-code} stuff.
557 * - ':end-of-headers' -- marks the end of header callbacks.
558 */
559typedef DECLCALLBACK(int) FNRTHTTPHEADERCALLBACK(RTHTTP hHttp, uint32_t uMatchWord, const char *pchField, size_t cchField,
560 const char *pchValue, size_t cchValue, void *pvUser);
561/** Pointer to a header field consumer callback. */
562typedef FNRTHTTPHEADERCALLBACK *PFNRTHTTPHEADERCALLBACK;
563
564/**
565 * Forms a fast header match word.
566 *
567 * @returns Fast header match word.
568 * @param a_cchField The length of the header field name.
569 * @param a_chLower1 The first character in the name, lowercased.
570 * @param a_chLower2 The second character in the name, lowercased.
571 * @param a_chLower3 The third character in the name, lowercased.
572 */
573#define RTHTTP_MAKE_HDR_MATCH_WORD(a_cchField, a_chLower1, a_chLower2, a_chLower3) \
574 RT_MAKE_U32_FROM_U8(a_cchField, a_chLower1, a_chLower2, a_chLower3)
575
576/**
577 * Set the callback function for processing header fields in the response.
578 *
579 * @returns IPRT status code.
580 * @param hHttp The HTTP client handle.
581 * @param pfnCallback The callback function. Pass NULL to reset the callback.
582 * @param pvUser Convenience pointer for the callback function.
583 *
584 * @note This only works reliably with RTHttpPerform at the moment.
585 */
586RTR3DECL(int) RTHttpSetHeaderCallback(RTHTTP hHttp, PFNRTHTTPHEADERCALLBACK pfnCallback, void *pvUser);
587
588
589/** @name thin wrappers for setting one or a few related curl options
590 * @remarks Temporary. Will not be included in the 6.0 release!
591 * @{ */
592typedef size_t FNRTHTTPREADCALLBACKRAW(void *pbDst, size_t cbItem, size_t cItems, void *pvUser);
593typedef FNRTHTTPREADCALLBACKRAW *PFNRTHTTPREADCALLBACKRAW;
594#define RT_HTTP_READCALLBACK_ABORT 0x10000000 /* CURL_READFUNC_ABORT */
595RTR3DECL(int) RTHttpRawSetReadCallback(RTHTTP hHttp, PFNRTHTTPREADCALLBACKRAW pfnRead, void *pvUser);
596
597typedef size_t FNRTHTTPWRITECALLBACKRAW(char *pbSrc, size_t cbItem, size_t cItems, void *pvUser);
598typedef FNRTHTTPWRITECALLBACKRAW *PFNRTHTTPWRITECALLBACKRAW;
599RTR3DECL(int) RTHttpRawSetWriteCallback(RTHTTP hHttp, PFNRTHTTPWRITECALLBACKRAW pfnWrite, void *pvUser);
600RTR3DECL(int) RTHttpRawSetWriteHeaderCallback(RTHTTP hHttp, PFNRTHTTPWRITECALLBACKRAW pfnWrite, void *pvUser);
601
602RTR3DECL(int) RTHttpRawSetUrl(RTHTTP hHttp, const char *pszUrl);
603
604RTR3DECL(int) RTHttpRawSetGet(RTHTTP hHttp);
605RTR3DECL(int) RTHttpRawSetHead(RTHTTP hHttp);
606RTR3DECL(int) RTHttpRawSetPost(RTHTTP hHttp);
607RTR3DECL(int) RTHttpRawSetPut(RTHTTP hHttp);
608RTR3DECL(int) RTHttpRawSetDelete(RTHTTP hHttp);
609RTR3DECL(int) RTHttpRawSetCustomRequest(RTHTTP hHttp, const char *pszVerb);
610
611RTR3DECL(int) RTHttpRawSetPostFields(RTHTTP hHttp, const void *pv, size_t cb);
612RTR3DECL(int) RTHttpRawSetInfileSize(RTHTTP hHttp, RTFOFF cb);
613
614RTR3DECL(int) RTHttpRawSetVerbose(RTHTTP hHttp, bool fValue);
615RTR3DECL(int) RTHttpRawSetTimeout(RTHTTP hHttp, long sec);
616
617RTR3DECL(int) RTHttpRawPerform(RTHTTP hHttp);
618
619RTR3DECL(int) RTHttpRawGetResponseCode(RTHTTP hHttp, long *plCode);
620/** @} */
621
622/** @} */
623
624RT_C_DECLS_END
625
626#endif
627
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette