NUGU SDK Linux
1.7.6
|
HTTP request management. More...
Classes | |
struct | _nugu_http_response |
HTTP Response object. More... | |
Typedefs | |
typedef int(* | NuguHttpCallback) (NuguHttpRequest *req, const NuguHttpResponse *resp, void *user_data) |
Callback prototype for receiving async HTTP response. More... | |
typedef struct _nugu_http_header | NuguHttpHeader |
HTTP Header object. | |
typedef struct _nugu_http_host | NuguHttpHost |
HTTP Host object. | |
typedef int(* | NuguHttpProgressCallback) (NuguHttpRequest *req, const NuguHttpResponse *resp, long long downloaded, long long total, void *user_data) |
Callback prototype for HTTP download progress. | |
typedef struct _nugu_http_request | NuguHttpRequest |
HTTP Request object. | |
typedef struct _nugu_http_response | NuguHttpResponse |
HTTP Response object. | |
Enumerations | |
enum | NuguHttpRequestType { NUGU_HTTP_REQUEST_GET , NUGU_HTTP_REQUEST_POST , NUGU_HTTP_REQUEST_PUT , NUGU_HTTP_REQUEST_DELETE } |
HTTP request types. | |
Functions | |
NUGU_API NuguHttpRequest * | nugu_http_delete (NuguHttpHost *host, const char *path, NuguHttpHeader *header, NuguHttpCallback callback, void *user_data) |
A convenient API for HTTP DELETE async requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_delete_sync (NuguHttpHost *host, const char *path, NuguHttpHeader *header) |
A convenient API for HTTP DELETE sync requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_download (NuguHttpHost *host, const char *path, const char *dest_path, NuguHttpHeader *header, NuguHttpCallback callback, NuguHttpProgressCallback progress_callback, void *user_data) |
A convenient API for HTTP file download async requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_get (NuguHttpHost *host, const char *path, NuguHttpHeader *header, NuguHttpCallback callback, void *user_data) |
A convenient API for HTTP GET async requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_get_sync (NuguHttpHost *host, const char *path, NuguHttpHeader *header) |
A convenient API for HTTP GET sync requests. More... | |
NUGU_API int | nugu_http_header_add (NuguHttpHeader *header, const char *key, const char *value) |
Add a key-value string to header object. More... | |
NUGU_API NuguHttpHeader * | nugu_http_header_dup (const NuguHttpHeader *src_header) |
Duplicate the http header object. More... | |
NUGU_API const char * | nugu_http_header_find (NuguHttpHeader *header, const char *key) |
Find value from header object. More... | |
NUGU_API void | nugu_http_header_free (NuguHttpHeader *header) |
Destroy the header object. More... | |
NUGU_API int | nugu_http_header_import (NuguHttpHeader *header, const NuguHttpHeader *from) |
Import header data from other header object. More... | |
NUGU_API NuguHttpHeader * | nugu_http_header_new (void) |
Create a new HTTP header object. More... | |
NUGU_API int | nugu_http_header_remove (NuguHttpHeader *header, const char *key) |
Remove a key-value string from header object. More... | |
NUGU_API void | nugu_http_host_free (NuguHttpHost *host) |
Destroy the host object. More... | |
NUGU_API NuguHttpHost * | nugu_http_host_new (const char *url) |
Create a new HTTP host object. More... | |
NUGU_API const char * | nugu_http_host_peek_url (NuguHttpHost *host) |
Get url from HTTP host object. More... | |
NUGU_API void | nugu_http_host_set_connection_timeout (NuguHttpHost *host, long msecs) |
Set connection timeout to host. More... | |
NUGU_API void | nugu_http_host_set_timeout (NuguHttpHost *host, long msecs) |
Set timeout to host. More... | |
NUGU_API void | nugu_http_init (void) |
Initialize HTTP module (curl_global_init) | |
NUGU_API NuguHttpRequest * | nugu_http_post (NuguHttpHost *host, const char *path, NuguHttpHeader *header, const void *body, size_t body_len, NuguHttpCallback callback, void *user_data) |
A convenient API for HTTP POST async requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_post_sync (NuguHttpHost *host, const char *path, NuguHttpHeader *header, const void *body, size_t body_len) |
A convenient API for HTTP POST sync requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_put (NuguHttpHost *host, const char *path, NuguHttpHeader *header, const void *body, size_t body_len, NuguHttpCallback callback, void *user_data) |
A convenient API for HTTP PUT async requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_put_sync (NuguHttpHost *host, const char *path, NuguHttpHeader *header, const void *body, size_t body_len) |
A convenient API for HTTP PUT sync requests. More... | |
NUGU_API NuguHttpRequest * | nugu_http_request (enum NuguHttpRequestType type, NuguHttpHost *host, const char *path, NuguHttpHeader *header, const void *body, size_t body_len, NuguHttpCallback callback, void *user_data) |
HTTP async request. More... | |
NUGU_API void | nugu_http_request_free (NuguHttpRequest *req) |
Destroy the HTTP request object. More... | |
NUGU_API const NuguHttpResponse * | nugu_http_request_response_get (NuguHttpRequest *req) |
Get the HTTP response from request object. More... | |
NUGU_API NuguHttpRequest * | nugu_http_request_sync (enum NuguHttpRequestType type, NuguHttpHost *host, const char *path, NuguHttpHeader *header, const void *body, size_t body_len) |
HTTP sync request. More... | |
NUGU_API NuguHttpResponse * | nugu_http_response_dup (const NuguHttpResponse *orig) |
Duplicate the HTTP response object. More... | |
NUGU_API void | nugu_http_response_free (NuguHttpResponse *resp) |
Destroy the HTTP response object. More... | |
HTTP request management.
The NuguHttp handles REST(GET/POST/PUT/DELETE) requests using HTTP.
typedef int(* NuguHttpCallback) (NuguHttpRequest *req, const NuguHttpResponse *resp, void *user_data) |
Callback prototype for receiving async HTTP response.
1 | automatically free memory after return the callback |
0 | free the memory manually by the nugu_http_request_free(). |
NUGU_API NuguHttpHost* nugu_http_host_new | ( | const char * | url | ) |
Create a new HTTP host object.
[in] | url | host url |
NUGU_API void nugu_http_host_set_timeout | ( | NuguHttpHost * | host, |
long | msecs | ||
) |
Set timeout to host.
[in] | host | host object |
[in] | msecs | millisecond |
NUGU_API void nugu_http_host_set_connection_timeout | ( | NuguHttpHost * | host, |
long | msecs | ||
) |
Set connection timeout to host.
[in] | host | host object |
[in] | msecs | millisecond |
NUGU_API const char* nugu_http_host_peek_url | ( | NuguHttpHost * | host | ) |
Get url from HTTP host object.
[in] | host | host object |
NUGU_API void nugu_http_host_free | ( | NuguHttpHost * | host | ) |
NUGU_API NuguHttpHeader* nugu_http_header_new | ( | void | ) |
NUGU_API int nugu_http_header_add | ( | NuguHttpHeader * | header, |
const char * | key, | ||
const char * | value | ||
) |
Add a key-value string to header object.
[in] | header | header object |
[in] | key | key string, e.g. "Content-Type" |
[in] | value | value string, e.g. "application/json" |
0 | success |
-1 | failure |
NUGU_API int nugu_http_header_remove | ( | NuguHttpHeader * | header, |
const char * | key | ||
) |
Remove a key-value string from header object.
[in] | header | header object |
[in] | key | key string |
0 | success |
-1 | failure |
NUGU_API const char* nugu_http_header_find | ( | NuguHttpHeader * | header, |
const char * | key | ||
) |
Find value from header object.
[in] | header | header object |
[in] | key | key string |
NUGU_API NuguHttpHeader* nugu_http_header_dup | ( | const NuguHttpHeader * | src_header | ) |
Duplicate the http header object.
[in] | src_header | source header object |
NUGU_API int nugu_http_header_import | ( | NuguHttpHeader * | header, |
const NuguHttpHeader * | from | ||
) |
Import header data from other header object.
[in] | header | header object |
[in] | from | header object to import |
0 | success |
-1 | failure |
NUGU_API void nugu_http_header_free | ( | NuguHttpHeader * | header | ) |
NUGU_API NuguHttpRequest* nugu_http_request | ( | enum NuguHttpRequestType | type, |
NuguHttpHost * | host, | ||
const char * | path, | ||
NuguHttpHeader * | header, | ||
const void * | body, | ||
size_t | body_len, | ||
NuguHttpCallback | callback, | ||
void * | user_data | ||
) |
HTTP async request.
[in] | type | request type |
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | body | body data to send |
[in] | body_len | length of body data |
[in] | callback | callback function to receive response |
[in] | user_data | data to pass to the user callback |
NUGU_API NuguHttpRequest* nugu_http_request_sync | ( | enum NuguHttpRequestType | type, |
NuguHttpHost * | host, | ||
const char * | path, | ||
NuguHttpHeader * | header, | ||
const void * | body, | ||
size_t | body_len | ||
) |
HTTP sync request.
[in] | type | request type |
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | body | body data to send |
[in] | body_len | length of body data |
NUGU_API NuguHttpRequest* nugu_http_get | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header, | ||
NuguHttpCallback | callback, | ||
void * | user_data | ||
) |
A convenient API for HTTP GET async requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | callback | callback function to receive response |
[in] | user_data | data to pass to the user callback |
NUGU_API NuguHttpRequest* nugu_http_get_sync | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header | ||
) |
A convenient API for HTTP GET sync requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
NUGU_API NuguHttpRequest* nugu_http_post | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header, | ||
const void * | body, | ||
size_t | body_len, | ||
NuguHttpCallback | callback, | ||
void * | user_data | ||
) |
A convenient API for HTTP POST async requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | body | body data to send |
[in] | body_len | length of body data |
[in] | callback | callback function to receive response |
[in] | user_data | data to pass to the user callback |
NUGU_API NuguHttpRequest* nugu_http_post_sync | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header, | ||
const void * | body, | ||
size_t | body_len | ||
) |
A convenient API for HTTP POST sync requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | body | body data to send |
[in] | body_len | length of body data |
NUGU_API NuguHttpRequest* nugu_http_put | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header, | ||
const void * | body, | ||
size_t | body_len, | ||
NuguHttpCallback | callback, | ||
void * | user_data | ||
) |
A convenient API for HTTP PUT async requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | body | body data to send |
[in] | body_len | length of body data |
[in] | callback | callback function to receive response |
[in] | user_data | data to pass to the user callback |
NUGU_API NuguHttpRequest* nugu_http_put_sync | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header, | ||
const void * | body, | ||
size_t | body_len | ||
) |
A convenient API for HTTP PUT sync requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | body | body data to send |
[in] | body_len | length of body data |
NUGU_API NuguHttpRequest* nugu_http_delete | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header, | ||
NuguHttpCallback | callback, | ||
void * | user_data | ||
) |
A convenient API for HTTP DELETE async requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
[in] | callback | callback function to receive response |
[in] | user_data | data to pass to the user callback |
NUGU_API NuguHttpRequest* nugu_http_delete_sync | ( | NuguHttpHost * | host, |
const char * | path, | ||
NuguHttpHeader * | header | ||
) |
A convenient API for HTTP DELETE sync requests.
[in] | host | host object |
[in] | path | url path |
[in] | header | header object |
NUGU_API NuguHttpRequest* nugu_http_download | ( | NuguHttpHost * | host, |
const char * | path, | ||
const char * | dest_path, | ||
NuguHttpHeader * | header, | ||
NuguHttpCallback | callback, | ||
NuguHttpProgressCallback | progress_callback, | ||
void * | user_data | ||
) |
A convenient API for HTTP file download async requests.
[in] | host | host object |
[in] | path | url path |
[in] | dest_path | path to save the file |
[in] | header | header object |
[in] | callback | callback function to receive response |
[in] | progress_callback | callback function to receive download progress |
[in] | user_data | data to pass to the user callback |
NUGU_API void nugu_http_request_free | ( | NuguHttpRequest * | req | ) |
Destroy the HTTP request object.
[in] | req | request object |
NUGU_API NuguHttpResponse* nugu_http_response_dup | ( | const NuguHttpResponse * | orig | ) |
Duplicate the HTTP response object.
[in] | orig | Original response object |
NUGU_API void nugu_http_response_free | ( | NuguHttpResponse * | resp | ) |
Destroy the HTTP response object.
[in] | resp | response object |
NUGU_API const NuguHttpResponse* nugu_http_request_response_get | ( | NuguHttpRequest * | req | ) |
Get the HTTP response from request object.
[in] | req | request object |