157 {
158
160
161 self->locals.
handle = curl_multi_init();
162 assert(self->locals.
handle);
163
164 while (true) {
165 int ret;
166
167 bool idle;
171 }
173 });
174
175 if (idle) {
176 break;
177 }
178
180
182
185
186 if (task->locals.
handle) {
187 const CURLcode err = curl_easy_pause(task->locals.
handle, CURLPAUSE_ALL);
188 assert(err == CURLE_OK);
189 }
190
192
194
195 if (task->locals.
handle == NULL) {
196
198 assert(task->locals.
handle);
199
200 const CURLMcode merr = curl_multi_add_handle(self->locals.
handle, task->locals.
handle);
201 assert(merr == CURLM_OK);
202 } else {
203 const CURLcode err = curl_easy_pause(task->locals.
handle, CURLPAUSE_CONT);
204 assert(err == CURLE_OK);
205 }
206
208
210
211 if (task->locals.
handle) {
212 const CURLMcode merr = curl_multi_remove_handle(self->locals.
handle, task->locals.
handle);
213 assert(merr == CURLM_OK);
214 }
215
217
220 }
221
223
226 });
228
231 });
232 }
233 }
234
235 CURLMcode merr = curl_multi_wait(self->locals.
handle, NULL, 0, 0, NULL);
236 assert(merr == CURLM_OK);
237
238 merr = curl_multi_perform(self->locals.
handle, &ret);
239 assert(merr == CURLM_OK);
240
241 CURLMsg *message;
242 while ((message = curl_multi_info_read(self->locals.
handle, &ret))) {
243
246
248 if (t->locals.
handle == message->easy_handle) {
249 task = t;
250 break;
251 }
252 }
253
254 assert(task);
255
256 if (message->msg == CURLMSG_DONE) {
257
258 merr = curl_multi_remove_handle(self->locals.
handle, task->locals.
handle);
259 assert(merr == CURLM_OK);
260
262
264
267 }
268
269 if (task->completion) {
270 task->completion(task, message->data.result == CURLE_OK);
271 }
272
274
277 });
278 }
279 }
280
282 }
283
284 curl_multi_cleanup(self->locals.
handle);
285
286 return NULL;
287}
static void removeObject(Array *self, const ident obj)
static void teardown(void)
Called atexit to teardown Objectively.
static void setup(void)
Called when initializing Object to setup Objectively.
static bool isKindOfClass(const Object *self, const Class *clazz)
Class * _URLSessionDataTask(void)
static void cacheResponse(URLSessionDataTask *self)
@ URLSESSIONTASK_RESUMING
@ URLSESSIONTASK_CANCELED
@ URLSESSIONTASK_SUSPENDING
@ URLSESSIONTASK_SUSPENDED
@ URLSESSIONTASK_COMPLETED
@ URLSESSIONTASK_CANCELING
int httpStatusCode
The HTTP response status code.
ident handle
The libcurl handle.
struct URLResponse * response
The response.
ident handle
The backing libcurl handle.
URLSessionTaskState state
The state.
URLSessionTaskCompletion completion
The completion function.