eae1a4590f9b5f386c4ed40f798f94fca7efeca7
[AGL/documentation.git] / docs / 3_Developer_Guides / 6_AFB_Helper_Guide / 3.7.3_CURL_wrapper.md
1 ---
2 edit_link: ''
3 title: CURL wrapper
4 origin_url: >-
5   https://git.automotivelinux.org/src/libafb-helpers/plain/docs/curl-wrap.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/afb-helpers-function-references-afb-helpers-book.yml -->
9
10 # CURL wrapping functions reference.
11
12 ## int curl_wrap_perform (CURL * curl, char **result, size_t * size)
13
14 Perform the CURL operation for 'curl' and put the result in memory. If 'result'
15 isn't NULL it receives the returned content that then must be freed. If 'size'
16 isn't NULL, it receives the size of the returned content. Note that if not NULL,
17 the real content is one byte greater than the read size and the last byte
18 zero. This facility allows to handle the returned content as a null terminated
19 C-string.
20
21 ## void curl_wrap_do(CURL *curl, void (*callback)(void *closure, int status, CURL *curl, const char *result, size_t size), void *closure)
22
23 Will perform the CURL operation and on success invokes the callback with the
24 result and size of the operation or error on a failure.
25
26 ## int curl_wrap_content_type_is (CURL * curl, const char *value)
27
28 Request `Content-Type` information from the curl session with this function
29
30 Returns non-zero value if the CURL content type match the `value` and 0 otherwize
31
32 ## long curl_wrap_response_code_get(CURL *curl)
33
34 Request the response code to a CURL operation.
35
36 Returns the response code received on success or 0 on failure.
37
38 ## CURL *curl_wrap_prepare_get_url(const char *url)
39
40 Prepare a GET CURL operation on the url given as parameter and Returns the CURL
41 pointer.
42
43 ## CURL *curl_wrap_prepare_get(const char *base, const char *path, const char * const *args)
44
45 Prepare a GET CURL operation on the decomposed url and escape it. The `url` has been
46 decomposed in 3 parts:
47
48 * `base`: representing the FQDN of the url.
49 * `path`: the path to the requested page.
50 * `args`: optionnal array of arguments provided for the GET request.
51
52 Returns the prepared CURL request.
53
54 ## int curl_wrap_add_header(CURL *curl, const char *header)
55
56 Add a header to a CURL operation.
57
58 Returns the prepared CURL request.
59
60 ## int curl_wrap_add_header_value(CURL *curl, const char *name, const char *value)
61
62 Add a tuple `name`, `value` to the header of a CURL operation.
63
64 Returns the prepared CURL request.
65
66 ## CURL *curl_wrap_prepare_post_url_data(const char *url, const char *datatype, const char *data, size_t szdata)
67
68 Prepare a POST CURL operation on the provided `url`.
69
70 * `url`: a HTTP url.
71 * `datatype`: HTTP `Content-Type` to use for the operation.
72 * `data`: data to send.
73 * `szdata`: size of the data to send.
74
75 Returns the prepared CURL request.
76
77 ## CURL *curl_wrap_prepare_post_simple_unescaped(const char *base, const char *path, const char *args)
78
79 Prepare a POST CURL operation on an unescaped `url` with arguments provided as
80 a simple string.
81
82 * `base`: representing the FQDN of the url.
83 * `path`: the path to the requested page.
84 * `args`: optionnals argument for the POST http request.
85
86 Returns the prepared CURL request.
87
88 ## CURL *curl_wrap_prepare_post_simple_escaped(const char *base, const char *path, char *args)
89
90 Prepare a POST CURL operation on an escaped `url` with arguments provided as
91 a simple string.
92
93 * `base`: representing the FQDN of the url.
94 * `path`: the path to the requested page.
95 * `args`: optionnals argument for the POST http request.
96
97 Returns the prepared CURL request.
98
99 ## CURL *curl_wrap_prepare_post_unescaped(const char *base, const char *path, const char *separator, const char * const *args)
100
101 Prepare a POST CURL operation on an unescaped `url` with arguments provided as
102 an array of string concatened with a provided separator string.
103
104 * `base`: representing the FQDN of the url.
105 * `path`: the path to the requested page.
106 * `separator`: string used as a separator when concatening the arguments.
107 * `args`: optionnal array of arguments for the POST http request.
108
109 Returns the prepared CURL request.
110
111 ## CURL *curl_wrap_prepare_post_escaped(const char *base, const char *path, const char * const *args)
112
113 Prepare a POST CURL operation on an unescaped `url` with arguments provided as
114 an array of string concatened without any separator.
115
116 * `base`: representing the FQDN of the url.
117 * `path`: the path to the requested page.
118 * `args`: optionnal array of arguments for the POST http request.
119
120 Returns the prepared CURL request.