211 {
212
213 self->locals.
handle = curl_easy_init();
214 assert(self->locals.
handle);
215
216 curl_easy_setopt(self->locals.
handle, CURLOPT_ERRORBUFFER, self->
error);
217 curl_easy_setopt(self->locals.
handle, CURLOPT_FOLLOWLOCATION,
true);
218
222 }
224 curl_easy_setopt(self->locals.
handle, CURLOPT_TIMEOUT, config->
timeout);
225 }
227 curl_easy_setopt(self->locals.
handle, CURLOPT_LOW_SPEED_LIMIT, 1L);
228 curl_easy_setopt(self->locals.
handle, CURLOPT_LOW_SPEED_TIME, 10L);
229 }
230
232 curl_easy_setopt(self->locals.
handle, CURLOPT_HEADERDATA, self);
233
234 curl_easy_setopt(self->locals.
handle, CURLOPT_XFERINFOFUNCTION,
progress);
235 curl_easy_setopt(self->locals.
handle, CURLOPT_XFERINFODATA, self);
236
238 if (body) {
239 curl_easy_setopt(self->locals.
handle, CURLOPT_POSTFIELDS, body->
bytes);
240 curl_easy_setopt(self->locals.
handle, CURLOPT_POSTFIELDSIZE, body->
length);
241 }
242
243 struct curl_slist *httpHeaders = NULL;
245
247 if (headers) {
249 }
250
252 if (headers) {
254 }
255
256 curl_easy_setopt(self->locals.
handle, CURLOPT_HTTPHEADER, httpHeaders);
257
259
262 curl_easy_setopt(self->locals.
handle, CURLOPT_POST,
true);
263 break;
265 curl_easy_setopt(self->locals.
handle, CURLOPT_PUT,
true);
266 break;
268 curl_easy_setopt(self->locals.
handle, CURLOPT_CUSTOMREQUEST,
"DELETE");
269 break;
271 curl_easy_setopt(self->locals.
handle, CURLOPT_CUSTOMREQUEST,
"PATCH");
272 break;
274 curl_easy_setopt(self->locals.
handle, CURLOPT_NOBODY,
true);
275 break;
277 curl_easy_setopt(self->locals.
handle, CURLOPT_CUSTOMREQUEST,
"OPTIONS");
278 break;
279 default:
280 break;
281 }
282
284}
static void enumerateObjectsAndKeys(const Dictionary *self, DictionaryEnumerator enumerator, ident data)
static void requestHeaders_enumerator(const Dictionary *dictionary, ident obj, ident key, ident data)
A helper to populate the request headers list for CURL.
static size_t responseHeader(char *buffer, size_t size, size_t count, void *data)
The CURLOPT_HEADERFUNCTION for parsing response headers.
size_t length
The length of bytes.
uint8_t * bytes
The bytes.
String * urlString
The URL String.
HTTPMethod httpMethod
The HTTP request method.
Dictionary * httpHeaders
The HTTP request headers.
Data * httpBody
The HTTP request body, sent as POST or PUT data.
Configuration bundle for URLSession.
long connectTimeout
The timeout interval for establishing a connection, in seconds. 0 means no limit.
Dictionary * httpHeaders
The HTTP headers added to every HTTP URLRequest.
bool longPolling
If true, disables stall detection (LOW_SPEED_LIMIT / LOW_SPEED_TIME). Use for requests that legitimat...
long timeout
The timeout for the entire transfer, in seconds. 0 means no limit.
URLSessionConfiguration * configuration
The session configuration.
ident requestHeaders
HTTP headers, in libcurl list structure.