![]() |
BSB Developer Docs
|
Library for building fetch-like HTTP clients. More...
Go to the source code of this file.
Data Structures | |
| struct | FetchRequestHeaders |
| Request headers structure. More... | |
| struct | FetchRequestBody |
| Request body structure. More... | |
| struct | FetchRequest |
| Request structure. More... | |
Macros | |
| #define | FETCH_HEADERS_COUNT_MAX (12) |
| Maximum number of additional request headers. | |
Typedefs | |
| typedef struct Fetch | Fetch |
| Opaque Fetch structure declaration. | |
| typedef void(* | FetchRxDataCallback) (const void *data, size_t data_size, void *context) |
| Received HTTP data callback function type. | |
| typedef void(* | FetchHeaderCallback) (const void *data, size_t data_size, void *context) |
| Received HTTP headers callback function type. | |
| typedef void(* | FetchProgressCallback) (const FetchProgress *progress, void *context) |
| Progress reporting callback function type. | |
| typedef void(* | FetchErrorCallback) (const char *error, void *context) |
| Error reporting callback function type. | |
Functions | |
| Fetch * | fetch_alloc (void) |
| Create a Fetch instance. | |
| void | fetch_free (Fetch *instance) |
| Delete the Fetch instance. | |
| FetchStatus | fetch_run (Fetch *instance, const FetchRequest *request) |
| Run the fetch process in the current thread. | |
| void | fetch_stop (Fetch *instance) |
| Request the ongoing fetch process to stop. | |
| void | fetch_set_callback_context (Fetch *instance, void *context) |
| Set the callback context for the Fetch instance. | |
| void | fetch_set_rx_data_callback (Fetch *instance, FetchRxDataCallback callback) |
| Set the callback for received data. | |
| void | fetch_set_header_callback (Fetch *instance, FetchHeaderCallback callback) |
| Set the callback for the header data. | |
| void | fetch_set_error_callback (Fetch *instance, FetchErrorCallback callback) |
| Set the callback for error reporting. | |
| void | fetch_set_progress_callback (Fetch *instance, FetchProgressCallback callback) |
| Sets the callback for status updates. | |
Library for building fetch-like HTTP clients.
| typedef void(* FetchErrorCallback) (const char *error, void *context) |
Error reporting callback function type.
| [in] | error | pointer to a zero-terminated string containing the error description |
| [in,out] | context | pointer to a user-specific object (may be NULL) |
| typedef void(* FetchHeaderCallback) (const void *data, size_t data_size, void *context) |
Received HTTP headers callback function type.
| [in] | data | pointer to header data |
| [in] | data_size | length of the header data |
| [in,out] | context | pointer to a user-specific object (may be NULL) |
| typedef void(* FetchProgressCallback) (const FetchProgress *progress, void *context) |
Progress reporting callback function type.
| [in] | progress | pointer to a structure containing the current progress information |
| [in,out] | context | pointer to a user-specific object (may be NULL) |
| typedef void(* FetchRxDataCallback) (const void *data, size_t data_size, void *context) |
Received HTTP data callback function type.
| [in] | data | pointer to received data |
| [in] | data_size | length of the received data |
| [in,out] | context | pointer to a user-specific object (may be NULL) |
| Fetch * fetch_alloc | ( | void | ) |
Create a Fetch instance.
| void fetch_free | ( | Fetch * | instance | ) |
Delete the Fetch instance.
| [in,out] | instance | Pointer to the Fetch instance to free. |
| FetchStatus fetch_run | ( | Fetch * | instance, |
| const FetchRequest * | request ) |
Run the fetch process in the current thread.
This call will block the calling thread until the fetch process is complete.
The callbacks will be executed in the calling thread's context.
| [in,out] | instance | Pointer to the Fetch instance. |
| [in] | request | Pointer to the request to be executed. |
FetchStatusOk on success, any other FetchStatus value otherwise | void fetch_set_callback_context | ( | Fetch * | instance, |
| void * | context ) |
Set the callback context for the Fetch instance.
| [in,out] | instance | Pointer to the Fetch instance. |
| [in,out] | context | Pointer to the context to set. |
| void fetch_set_error_callback | ( | Fetch * | instance, |
| FetchErrorCallback | callback ) |
Set the callback for error reporting.
| [in,out] | instance | Pointer to the Fetch instance. |
| [in] | callback | Function pointer to the callback function. |
| void fetch_set_header_callback | ( | Fetch * | instance, |
| FetchHeaderCallback | callback ) |
Set the callback for the header data.
| [in,out] | instance | Pointer to the Fetch instance. |
| [in] | callback | Function pointer to the callback function. |
| void fetch_set_progress_callback | ( | Fetch * | instance, |
| FetchProgressCallback | callback ) |
Sets the callback for status updates.
| [in,out] | instance | Pointer to the Fetch instance. |
| [in] | callback | Function pointer to the callback function. |
| void fetch_set_rx_data_callback | ( | Fetch * | instance, |
| FetchRxDataCallback | callback ) |
Set the callback for received data.
| [in,out] | instance | Pointer to the Fetch instance. |
| [in] | callback | Function pointer to the callback function. |
| void fetch_stop | ( | Fetch * | instance | ) |
Request the ongoing fetch process to stop.
This function is non-blocking. The execution thread must wait until fetch_exec() returns.
| [in,out] | instance | Pointer to the Fetch instance. |