32#define _Class _RESTClient
34#pragma mark - Async internals
55#pragma mark - Request helpers
86 if (out_data && task->
data) {
138#pragma mark - RESTClient
298#pragma mark - Class lifecycle
308 RESTClientInterface *rest = (RESTClientInterface *) clazz->
interface;
339 .name =
"RESTClient",
342 .interfaceOffset = offsetof(
RESTClient, interface),
343 .interfaceSize =
sizeof(RESTClientInterface),
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 destroy(Class *clazz)
static int request(RESTClient *self, HTTPMethod method, const char *url_string, const Data *body, Data **out_data)
static int put(RESTClient *self, const char *url, const Data *body, Data **data)
static void headAsync(RESTClient *self, const char *url, RESTClientCompletion completion, void *user_data)
static void putAsync(RESTClient *self, const char *url, const Data *body, RESTClientCompletion completion, void *user_data)
static int get(RESTClient *self, const char *url, Data **data)
static int patch(RESTClient *self, const char *url, const Data *body, Data **data)
static void patchAsync(RESTClient *self, const char *url, const Data *body, RESTClientCompletion completion, void *user_data)
static void postAsync(RESTClient *self, const char *url, const Data *body, RESTClientCompletion completion, void *user_data)
static RESTClient * _sharedInstance
static int httpDelete(RESTClient *self, const char *url, Data **data)
static int options(RESTClient *self, const char *url, Data **data)
static RESTClient * init(RESTClient *self)
static void getAsync(RESTClient *self, const char *url, RESTClientCompletion completion, void *user_data)
static int head(RESTClient *self, const char *url)
static void httpDeleteAsync(RESTClient *self, const char *url, RESTClientCompletion completion, void *user_data)
static void optionsAsync(RESTClient *self, const char *url, RESTClientCompletion completion, void *user_data)
Class * _RESTClient(void)
static void dealloc(Object *self)
static RESTClient * initWithSession(RESTClient *self, URLSession *session)
static void initialize(Class *clazz)
static void RESTClient_AsyncCompletion(URLSessionTask *task, bool success)
static RESTClient * sharedInstance(void)
static void requestAsync(RESTClient *self, HTTPMethod method, const char *url_string, const Data *body, RESTClientCompletion completion, void *user_data)
static int post(RESTClient *self, const char *url, const Data *body, Data **data)
An HTTP REST client backed by URLSession.
static String * initWithCharacters(String *self, const char *chars)
Uniform Resource Locators (RFC 3986).
static URLRequest * initWithURL(URLRequest *self, URL *url)
static void setValueForHTTPHeaderField(URLRequest *self, const char *value, const char *field)
A protocol-agnostic abstraction for requesting resources via URLs.
static URLSessionDataTask * dataTaskWithRequest(URLSession *self, URLRequest *request, URLSessionTaskCompletion completion)
static URLSessionDataTask * dataTaskWithURL(URLSession *self, URL *url, URLSessionTaskCompletion completion)
static void resume(URLSessionTask *self)
static void execute(URLSessionTask *self)
Use data tasks to send and receive Data in-memory.
#define do_once(once, block)
Executes the given block at most one time.
void(* RESTClientCompletion)(int status, Data *data, void *user_data)
A completion handler for asynchronous RESTClient requests.
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.
RESTClientCompletion completion
An HTTP REST client backed by URLSession.
RESTClient * initWithSession(RESTClient *, URLSession *)
Initializes this RESTClient with the specified URLSession.
URLSession * session
The URLSession backing this client.
int httpDelete(RESTClient *, const char *, Data **)
Synchronously performs an HTTP DELETE request.
Uniform Resource Locators (RFC 3986).
A protocol-agnostic abstraction for requesting resources via URLs.
int httpStatusCode
The HTTP response status code.
Use data tasks to send and receive Data in-memory.
Data * data
The data received.
URLSessionTask urlSessionTask
The superclass.
A management context for loading resources via URLs.
URL session tasks are handles to pending URL operations.
struct URLResponse * response
The response.