|
Objectively
Ultra-lightweight object oriented framework for GNU 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.
Definition at line 61 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 | get (RESTClient *, const char *, Data **) |
Synchronously performs an HTTP GET request. | |
| void | getAsync (RESTClient *, const char *, RESTClientCompletion, void *) |
Asynchronously performs an HTTP GET request. | |
| int | head (RESTClient *, const char *) |
Synchronously performs an HTTP HEAD request. | |
| void | headAsync (RESTClient *, const char *, RESTClientCompletion, void *) |
Asynchronously performs an HTTP HEAD request. | |
| int | httpDelete (RESTClient *, const char *, Data **) |
Synchronously performs an HTTP DELETE request. | |
| void | httpDeleteAsync (RESTClient *, const char *, RESTClientCompletion, void *) |
Asynchronously performs an HTTP DELETE 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 *, Data **) |
Synchronously performs an HTTP OPTIONS request. | |
| void | optionsAsync (RESTClient *, const char *, RESTClientCompletion, void *) |
Asynchronously performs an HTTP OPTIONS request. | |
| int | patch (RESTClient *, const char *, const Data *, Data **) |
Synchronously performs an HTTP PATCH request. | |
| void | patchAsync (RESTClient *, const char *, const Data *, RESTClientCompletion, void *) |
Asynchronously performs an HTTP PATCH request. | |
| int | post (RESTClient *, const char *, const Data *, Data **) |
Synchronously performs an HTTP POST request. | |
| void | postAsync (RESTClient *, const char *, const Data *, RESTClientCompletion, void *) |
Asynchronously performs an HTTP POST request. | |
| int | put (RESTClient *, const char *, const Data *, Data **) |
Synchronously performs an HTTP PUT request. | |
| void | putAsync (RESTClient *, const char *, const Data *, 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 |
| The interface. | |
Protected Attributes inherited from Object | |
| ObjectInterface * | interface |
| The interface. | |
|
protected |
The interface.
Definition at line 72 of file RESTClient.h.
| Object RESTClient::object |
The superclass.
Definition at line 66 of file RESTClient.h.
| URLSession* RESTClient::session |
The URLSession backing this client.
Definition at line 77 of file RESTClient.h.
| Class * _RESTClient | ( | void | ) |
The RESTClient archetype.
Definition at line 332 of file RESTClient.c.
| int get | ( | RESTClient * | self, |
| const char * | url, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP GET request.
| self | The RESTClient. |
| url | The URL string. |
| data | Optionally receives the retained response body. Caller must release. |
0 on connection failure. Definition at line 144 of file RESTClient.c.
| void getAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP GET request.
| self | The RESTClient. |
| url | The URL string. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 152 of file RESTClient.c.
| int head | ( | RESTClient * | self, |
| const char * | url | ||
| ) |
Synchronously performs an HTTP HEAD request.
| self | The RESTClient. |
| url | The URL string. |
0 on connection failure. Definition at line 161 of file RESTClient.c.
| void headAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP HEAD request.
| self | The RESTClient. |
| url | The URL string. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 169 of file RESTClient.c.
| int httpDelete | ( | RESTClient * | self, |
| const char * | url, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP DELETE request.
| self | The RESTClient. |
| url | The URL string. |
| data | Optionally receives the retained response body. Caller must release. |
0 on connection failure. Definition at line 178 of file RESTClient.c.
| void httpDeleteAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP DELETE request.
| self | The RESTClient. |
| url | The URL string. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 186 of file RESTClient.c.
| RESTClient * init | ( | RESTClient * | self | ) |
Initializes this RESTClient with the shared URLSession.
| self | The RESTClient. |
NULL on error. Definition at line 195 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 203 of file RESTClient.c.
| int options | ( | RESTClient * | self, |
| const char * | url, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP OPTIONS request.
| self | The RESTClient. |
| url | The URL string. |
| data | Optionally receives the retained response body. Caller must release. |
0 on connection failure. Definition at line 217 of file RESTClient.c.
| void optionsAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP OPTIONS request.
| self | The RESTClient. |
| url | The URL string. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 225 of file RESTClient.c.
| int patch | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP PATCH request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| data | Optionally receives the retained response body. Caller must release. |
0 on connection failure. Definition at line 234 of file RESTClient.c.
| void patchAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP PATCH request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 242 of file RESTClient.c.
| int post | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP POST request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| data | Optionally receives the retained response body. Caller must release. |
0 on connection failure. Definition at line 251 of file RESTClient.c.
| void postAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP POST request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 259 of file RESTClient.c.
| int put | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| Data ** | data | ||
| ) |
Synchronously performs an HTTP PUT request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| data | Optionally receives the retained response body. Caller must release. |
0 on connection failure. Definition at line 268 of file RESTClient.c.
| void putAsync | ( | RESTClient * | self, |
| const char * | url, | ||
| const Data * | body, | ||
| RESTClientCompletion | completion, | ||
| void * | user_data | ||
| ) |
Asynchronously performs an HTTP PUT request.
| self | The RESTClient. |
| url | The URL string. |
| body | The request body, or NULL. |
| completion | The completion handler. |
| user_data | User data passed through to completion. |
Definition at line 276 of file RESTClient.c.
| RESTClient * sharedInstance | ( | void | ) |