35#define _Class _URLSessionDataTask
52#pragma mark - URLSessionTask
101 if (this->cachedResponse) {
104 this->cachedResponse = NULL;
126 if (this->cachedResponse) {
153 if (this->cachedResponse) {
154 switch (this->urlSessionTask.state) {
161 if (this->urlSessionTask.completion) {
182 const uint8_t *bytes = (uint8_t *)
data;
183 const size_t bytesReceived = size * count;
185 if (this->data == NULL) {
191 this->urlSessionTask.bytesReceived += bytesReceived;
192 return bytesReceived;
202 curl_easy_setopt(self->handle, CURLOPT_WRITEFUNCTION,
writeFunction);
203 curl_easy_setopt(self->handle, CURLOPT_WRITEDATA, self);
206#pragma mark - Class lifecycle
233 .name =
"URLSessionDataTask",
236 .interfaceSize =
sizeof(URLSessionDataTaskInterface),
static Object * copy(const Object *self)
static Array * init(Array *self)
static void setup(void)
Called when initializing Object to setup Objectively.
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
Class * _initialize(const ClassDef *def)
Initializes the given Class.
ident retain(ident obj)
Atomically increment the given Object's reference count.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
static void appendBytes(Data *self, const uint8_t *bytes, size_t length)
void * ident
The identity type, similar to Objective-C id.
static void storeCachedResponseForRequest(URLCache *self, const URLRequest *request, const URLResponse *response, const Data *data)
A cache for HTTP responses.
A management context for loading resources via URLs.
Class * _URLSessionDataTask(void)
static size_t writeFunction(char *data, size_t size, size_t count, ident self)
The CURLOPT_WRITEFUNCTION callback.
static void resume(URLSessionTask *self)
static void materializeCachedResponse(URLSessionDataTask *self)
Copies a cached response into this task's live response and data fields.
static void cancel(URLSessionTask *self)
static void cacheResponse(URLSessionDataTask *self)
static void execute(URLSessionTask *self)
static void dealloc(Object *self)
static void initialize(Class *clazz)
Use data tasks to send and receive Data in-memory.
Class * _URLSessionTask(void)
@ URLSESSIONTASK_RESUMING
@ URLSESSIONTASK_CANCELED
@ URLSESSIONTASK_SUSPENDING
@ URLSESSIONTASK_SUSPENDED
@ URLSESSIONTASK_COMPLETED
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
ident interface
The interface of the Class.
Object is the root Class of The Objectively Class hierarchy.
A cache for HTTP responses.
URLResponse * response
The HTTP response.
Data * data
The response body.
size_t size
The cached body size.
A protocol-agnostic abstraction for URLSessionTask responses.
URLCache * urlCache
The cache for URL responses, or NULL to disable caching.
Use data tasks to send and receive Data in-memory.
URLCachedResponse * cachedResponse
A cached response, if this task was fulfilled from URLCache.
Data * data
The data received.
URLSessionTask urlSessionTask
The superclass.
URLSessionConfiguration * configuration
The session configuration.
URL session tasks are handles to pending URL operations.
struct URLResponse * response
The response.
int result
The libcurl result code (CURLcode) of the transfer, 0 on success.
size_t bytesExpectedToSend
The count of bytes this task expects to send.
struct URLRequest * request
The request.
size_t bytesReceived
The count of bytes received.
struct URLSession * session
The session, which is not retained.
URLSessionTaskState state
The state.
size_t bytesSent
The count of bytes sent.
size_t bytesExpectedToReceive
The count of bytes this task expects to receive.