|
Objectively
Object oriented framework for C.
|
#include <RESTClient.h>
An HTTP REST client backed by URLSession.
RESTClient provides synchronous and asynchronous HTTP verb methods (HEAD, GET, OPTIONS, POST, PATCH, PUT, DELETE) dealing in Data * request and response bodies. JSON marshalling is the caller's responsibility, typically via JSONContext. Every verb accepts an optional headers array for attaching additional request headers.
Definition at line 62 of file RESTClient.h.
Properties | |
| Object | object |
| The superclass. | |
| URLSession * | session |
| The URLSession backing this client. | |
Properties inherited from Object | |
| Class * | clazz |
| Every instance of Object begins with a pointer to its Class. | |
| unsigned int | magic |
| A header to allow introspection of Object types. | |
Methods | |
| Class * | _RESTClient (void) |
| The RESTClient archetype. | |
| int | del (RESTClient *, const char *, const char **, Data **) |
Synchronously performs an HTTP DELETE request. | |
| void | delAsync (RESTClient *, const char *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP DELETE request. | |
| int | get (RESTClient *, const char *, const char **, Data **) |
Synchronously performs an HTTP GET request. | |
| void | getAsync (RESTClient *, const char *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP GET request. | |
| int | head (RESTClient *, const char *, const char **) |
Synchronously performs an HTTP HEAD request. | |
| void | headAsync (RESTClient *, const char *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP HEAD request. | |
| RESTClient * | init (RESTClient *) |
| Initializes this RESTClient with the shared URLSession. | |
| RESTClient * | initWithSession (RESTClient *, URLSession *) |
| Initializes this RESTClient with the specified URLSession. | |
| int | options (RESTClient *, const char *, const char **, Data **) |
Synchronously performs an HTTP OPTIONS request. | |
| void | optionsAsync (RESTClient *, const char *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP OPTIONS request. | |
| int | patch (RESTClient *, const char *, const Data *, const char **, Data **) |
Synchronously performs an HTTP PATCH request. | |
| void | patchAsync (RESTClient *, const char *, const Data *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP PATCH request. | |
| int | post (RESTClient *, const char *, const Data *, const char **, Data **) |
Synchronously performs an HTTP POST request. | |
| void | postAsync (RESTClient *, const char *, const Data *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP POST request. | |
| int | put (RESTClient *, const char *, const Data *, const char **, Data **) |
Synchronously performs an HTTP PUT request. | |
| void | putAsync (RESTClient *, const char *, const Data *, const char **, RESTClientCompletion, void *) |
Asynchronously performs an HTTP PUT request. | |
| RESTClient * | sharedInstance (void) |
Methods inherited from Object | |
| Class * | _Object (void) |
| The Object archetype. | |
| Object * | copy (const Object *self) |
| Creates a shallow copy of this Object. | |
| void | dealloc (Object *self) |
| Frees all resources held by this Object. | |
| String * | description (const Object *self) |
| int | hash (const Object *self) |
| Object * | init (Object *self) |
| Initializes this Object. | |
| bool | isEqual (const Object *self, const Object *other) |
| Tests equality of the other Object. | |
| bool | isKindOfClass (const Object *self, const Class *clazz) |
| Tests for Class hierarchy membership. | |
Protected Attributes | |
| RESTClientInterface * | interface [0] |
| The interface type. | |
Protected Attributes inherited from Object | |
| ObjectInterface * | interface [0] |
| The interface type. | |
|
protected |
The interface type.
Definition at line 73 of file RESTClient.h.
| Object RESTClient::object |
The superclass.
Definition at line 67 of file RESTClient.h.
| URLSession* RESTClient::session |
The URLSession backing this client.
Definition at line 78 of file RESTClient.h.
| Class * _RESTClient | ( | void | ) |
The RESTClient archetype.
Definition at line 361 of file RESTClient.c.
| int del | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP DELETE request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| data | Optionally receives the retained response body. Caller must release. |
0 if the transfer failed or was cancelled. Definition at line 173 of file RESTClient.c.
| void delAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP DELETE request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 181 of file RESTClient.c.
| int get | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP GET request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| data | Optionally receives the retained response body. Caller must release. |
0 if the transfer failed or was cancelled. Definition at line 190 of file RESTClient.c.
| void getAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP GET request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 198 of file RESTClient.c.
| int head | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers | ||
| ) |
Synchronously performs an HTTP HEAD request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
0 if the transfer failed or was cancelled. Definition at line 207 of file RESTClient.c.
| void headAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP HEAD request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 215 of file RESTClient.c.
| RESTClient * init | ( | RESTClient * | self | ) |
Initializes this RESTClient with the shared URLSession.
| self | The RESTClient. |
NULL on error. Definition at line 224 of file RESTClient.c.
| RESTClient * initWithSession | ( | RESTClient * | self, |
| URLSession * | session | ||
| ) |
Initializes this RESTClient with the specified URLSession.
| self | The RESTClient. |
| session | The URLSession. |
NULL on error. Definition at line 232 of file RESTClient.c.
| int options | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP OPTIONS request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| data | Optionally receives the retained response body. Caller must release. |
0 if the transfer failed or was cancelled. Definition at line 246 of file RESTClient.c.
| void optionsAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP OPTIONS request.
| self | The RESTClient. |
| url | The URL string. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 254 of file RESTClient.c.
| int patch | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| const char ** | headers, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP PATCH request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| data | Optionally receives the retained response body. Caller must release. |
0 if the transfer failed or was cancelled. Definition at line 263 of file RESTClient.c.
| void patchAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP PATCH request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 271 of file RESTClient.c.
| int post | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| const char ** | headers, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP POST request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| data | Optionally receives the retained response body. Caller must release. |
0 if the transfer failed or was cancelled. Definition at line 280 of file RESTClient.c.
| void postAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP POST request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 288 of file RESTClient.c.
| int put | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| const char ** | headers, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP PUT request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| data | Optionally receives the retained response body. Caller must release. |
0 if the transfer failed or was cancelled. Definition at line 297 of file RESTClient.c.
| void putAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| const char ** | headers, | ||
| RESTClientCompletion | completion, | ||
| void * | userData | ||
| ) |
Asynchronously performs an HTTP PUT request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| headers | A NULL-terminated array of alternating field/value C strings (e.g. { "X-Field", "value", NULL }) to add to the request, or NULL for none. |
| completion | The completion handler. |
| userData | User data passed through to completion. |
Definition at line 305 of file RESTClient.c.
| RESTClient * sharedInstance | ( | void | ) |