251 {
252
253 self->handle = curl_easy_init();
254 assert(self->handle);
255
256 curl_easy_setopt(self->handle, CURLOPT_ERRORBUFFER, self->
error);
257 curl_easy_setopt(self->handle, CURLOPT_FOLLOWLOCATION, true);
258
261 curl_easy_setopt(self->handle, CURLOPT_CONNECTTIMEOUT, config->
connectTimeout);
262 }
264 curl_easy_setopt(self->handle, CURLOPT_TIMEOUT, config->
timeout);
265 }
267 curl_easy_setopt(self->handle, CURLOPT_LOW_SPEED_LIMIT, 1L);
268 curl_easy_setopt(self->handle, CURLOPT_LOW_SPEED_TIME, 10L);
269 }
270
271 curl_easy_setopt(self->handle, CURLOPT_HEADERFUNCTION,
responseHeader);
272 curl_easy_setopt(self->handle, CURLOPT_HEADERDATA, self);
273
274 curl_easy_setopt(self->handle, CURLOPT_NOPROGRESS, 0L);
275 curl_easy_setopt(self->handle, CURLOPT_XFERINFOFUNCTION,
progress);
276 curl_easy_setopt(self->handle, CURLOPT_XFERINFODATA, self);
277
279 if (body) {
280 curl_easy_setopt(self->handle, CURLOPT_POSTFIELDS, body->
bytes);
281 curl_easy_setopt(self->handle, CURLOPT_POSTFIELDSIZE, body->
length);
282 }
283
284 struct curl_slist *httpHeaders = NULL;
286
288 if (headers) {
290 }
291
293 if (headers) {
295 }
296
297 curl_easy_setopt(self->handle, CURLOPT_HTTPHEADER, httpHeaders);
298
299 self->requestHeaders = httpHeaders;
300
303 curl_easy_setopt(self->handle, CURLOPT_POST, true);
304 break;
306 curl_easy_setopt(self->handle, CURLOPT_PUT, true);
307 break;
309 curl_easy_setopt(self->handle, CURLOPT_CUSTOMREQUEST, "DELETE");
310 break;
312 curl_easy_setopt(self->handle, CURLOPT_CUSTOMREQUEST, "PATCH");
313 break;
315 curl_easy_setopt(self->handle, CURLOPT_NOBODY, true);
316 break;
318 curl_easy_setopt(self->handle, CURLOPT_CUSTOMREQUEST, "OPTIONS");
319 break;
320 default:
321 break;
322 }
323
325}
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.