|
static char | to_lower (const char x) |
|
static int | fetch_strcasecmp (const char *s1, const char *s2) |
|
static void | http_parse_context_free (struct http_parse_context *ctx) |
|
static struct http_parse_context * | http_parse_context_new (void) |
|
static bool | is_response_complete (const struct http_parse_context *ctx) |
|
static size_t | format_chunk_header (char *buffer, size_t data_size) |
|
static size_t | format_chunk_trailer (char *buffer) |
|
static size_t | format_final_chunk (char *buffer) |
|
static size_t | read_file_chunk (struct fetch_connection *conn, char *buffer, size_t buffer_size) |
|
static bool | has_more_file_data (struct fetch_connection *conn) |
|
static fetch_url_t * | fetch_url_parse (const char *url) |
|
static void | fetch_url_free (fetch_url_t *fetch_url) |
|
static bool | fetch_url_is_same_origin (const fetch_url_t *url1, const fetch_url_t *url2) |
|
static fetch_response_t * | create_response_from_context (const struct http_parse_context *ctx, const fetch_url_t *final_url, bool *supports_keep_alive, const fetch_request_t *request) |
|
static void | fetch_request_free (fetch_request_t *request) |
|
static fetch_request_t * | fetch_request_new (fetch_url_t *parsed_url, fetch_init_t *init) |
|
static uint64_t | get_connection_timeout_ms (const fetch_connection_t *conn) |
|
static uint32_t | get_connection_max_redirects (const fetch_connection_t *conn) |
|
static bool | get_connection_keepalive (const fetch_connection_t *conn) |
|
static http_method_t | get_connection_method (const fetch_connection_t *conn) |
|
static const fetch_url_t * | get_connection_url (const fetch_connection_t *conn) |
|
static fetch_headers_t * | get_connection_headers (const fetch_connection_t *conn) |
|
static fetch_body_t * | get_connection_body (const fetch_connection_t *conn) |
|
static bool | should_include_credentials (fetch_credentials_t credentials, const fetch_url_t *request_url, const char *origin) |
|
static uint64_t | fetch_get_time_ms (void) |
|
static pooled_connection_t * | pooled_connection_new (FETCH_SOCKET socket, const char *host, uint16_t port, bool is_tls, tls_context_t *tls_context) |
|
static void | pooled_connection_free (pooled_connection_t *conn) |
|
static bool | pooled_connection_is_valid (pooled_connection_t *conn) |
|
static connection_pool_t * | find_or_create_pool (const char *host, uint16_t port) |
|
static void | remove_from_available (connection_pool_t *pool, pooled_connection_t *conn) |
|
static void | add_to_available (connection_pool_t *pool, pooled_connection_t *conn) |
|
static void | cleanup_expired_connections (connection_pool_t *pool) |
|
static void | evict_if_needed (connection_pool_t *pool) |
|
static pooled_connection_t * | acquire_pooled_connection (const char *host, uint16_t port, bool is_tls) |
|
static bool | return_connection_to_pool (FETCH_SOCKET socket, const char *host, uint16_t port, bool keep_alive, bool is_tls, tls_context_t *tls_context) |
|
static uint64_t | fetch_next_connection_id (void) |
|
static void | insert_timer (fetch_timer_t *timer) |
|
static fetch_timer_t * | extract_expired_timers (uint64_t current_time_ms) |
|
static bool | add_connection_timeout (fetch_connection_t *conn) |
|
static void | remove_connection_timeout (uint64_t connection_id) |
|
static fetch_connection_t * | fetch_connection_new (fetch_promise_t *promise, fetch_request_t *request) |
|
static void | remove_socket_from_event_system (FETCH_SOCKET socket) |
|
static void | fetch_connection_free (fetch_connection_t *conn) |
|
static void | add_active_connection (fetch_connection_t *conn) |
|
static void | remove_active_connection (fetch_connection_t *conn) |
|
static void | move_to_completed (fetch_connection_t *conn) |
|
static fetch_connection_t * | find_connection_by_id (uint64_t connection_id) |
|
static void | set_connection_error (fetch_connection_t *conn, fetch_error_t error, const char *message) |
|
static void | set_connection_cancelled (fetch_connection_t *conn, const char *reason) |
|
static void | set_connection_complete (fetch_connection_t *conn, fetch_response_t *response) |
|
static void | update_connection_activity (fetch_connection_t *conn) |
|
static bool | is_connection_timed_out (fetch_connection_t *conn, uint64_t current_time_ms) |
|
static void | process_completed_connections (void) |
|
static bool | is_redirect_status (int status_code) |
|
static char * | resolve_redirect_url (const fetch_url_t *base_url, const char *location) |
|
static http_method_t | get_redirect_method (http_method_t original_method, int status_code) |
|
static bool | reset_connection_for_redirect (fetch_connection_t *conn, const char *new_url, http_method_t new_method) |
|
static bool | init_event_loop_select (void) |
|
static void | cleanup_event_loop_select (void) |
|
static void | wakeup_event_loop_select (void) |
|
static bool | init_event_loop_platform (void) |
|
static void | cleanup_event_loop_platform (void) |
|
static void | wakeup_event_loop (void) |
|
static FETCH_SOCKET | create_nonblocking_socket (int family) |
|
static void | dns_resolution_callback (dns_result_t *result, void *user_data) |
|
static socket_op_result_t | start_connect (fetch_connection_t *conn) |
|
static bool | is_socket_connected (FETCH_SOCKET socket) |
|
static socket_op_result_t | check_connect_completion (fetch_connection_t *conn) |
|
static socket_op_result_t | send_data (fetch_connection_t *conn) |
|
static socket_op_result_t | receive_data (fetch_connection_t *conn) |
|
static bool | prepare_socket_for_state (fetch_connection_t *conn) |
|
static void | add_cookie_header_to_request (fetch_headers_t *headers, const fetch_url_t *url, const fetch_request_t *request) |
|
static void | process_set_cookie_headers (const fetch_headers_t *response_headers, const fetch_url_t *url, const fetch_request_t *request) |
|
static char * | build_request_line (const char *method, const fetch_url_t *url) |
|
static char * | build_host_header (const fetch_url_t *url) |
|
static char * | build_http_headers (const fetch_headers_t *headers, const char *host_header, const char *user_agent, const char *content_type, size_t content_length, bool has_body, bool use_chunked_encoding, bool use_keep_alive, const fetch_url_t *url, const fetch_request_t *request, size_t *total_size) |
|
static bool | build_http_request (fetch_connection_t *conn) |
|
static bool | ensure_body_capacity (http_parse_context_t *ctx, size_t needed) |
|
static bool | append_to_body (http_parse_context_t *ctx, const char *data, size_t size) |
|
static bool | convert_phr_headers (http_parse_context_t *ctx) |
|
static void | analyze_headers (http_parse_context_t *ctx) |
|
static bool | parse_http_response (http_parse_context_t *ctx, const char *data, size_t size, size_t *consumed) |
|
static bool | is_response_complete (const http_parse_context_t *ctx) |
|
static void | process_timeout_events (void) |
|
static bool | handle_redirect_response (fetch_connection_t *conn) |
|
static void | process_connection_state (fetch_connection_t *conn) |
|
static int | process_events_select (uint32_t timeout_ms) |
|
static void | perform_pool_maintenance (void) |
|
int | fetch_event_loop_process (uint32_t timeout_ms) |
| Process events in the event loop (NON-BLOCKING with timeout)
|
|
bool | fetch_event_loop_start (void) |
| Start the event loop.
|
|
void | fetch_event_loop_stop (void) |
| Stop the event loop.
|
|
bool | fetch_event_loop_is_running (void) |
| Check if the event loop is running.
|
|
static bool | submit_connection_to_event_loop (fetch_connection_t *conn) |
|
void | fetch_global_init (const fetch_config_t *config) |
| Initialize the fetch library with configuration.
|
|
void | fetch_global_dispose (void) |
| Clean up the fetch library.
|
|
static fetch_error_t | validate_request (const char *url, const fetch_init_t *init, fetch_url_t **parsed_url_out) |
|
static fetch_response_t * | create_error_response (fetch_error_t error, const char *message, const char *url) |
|
fetch_promise_t * | fetch_async (const char *url, fetch_init_t *init) |
| Make an asynchronous HTTP request (NON-BLOCKING)
|
|
fetch_response_t * | fetch (const char *url, fetch_init_t *init) |
| Make a synchronous HTTP request (BLOCKING)
|
|
bool | fetch_promise_poll (fetch_promise_t *promise) |
| Check if a promise has completed (NON-BLOCKING)
|
|
bool | fetch_promise_await (fetch_promise_t *promise, uint32_t timeout_ms) |
| Wait for a promise to complete (BLOCKING)
|
|
bool | fetch_promise_cancel (fetch_promise_t *promise, const char *reason) |
| Cancel a pending promise.
|
|
bool | fetch_promise_cancelled (const fetch_promise_t *promise) |
| Check if a promise was cancelled.
|
|
fetch_response_t * | fetch_promise_response (const fetch_promise_t *promise) |
| Get the response from a fulfilled promise.
|
|
fetch_promise_state_t | fetch_promise_state (const fetch_promise_t *promise) |
| Get the current state of a promise.
|
|
fetch_error_t | fetch_promise_error (const fetch_promise_t *promise) |
| Get the error code from a rejected promise.
|
|
const char * | fetch_promise_error_message (const fetch_promise_t *promise) |
| Get the error message from a rejected promise.
|
|
bool | fetch_promise_pending (const fetch_promise_t *promise) |
| Check if promise is still pending.
|
|
bool | fetch_promise_fulfilled (const fetch_promise_t *promise) |
| Check if promise was fulfilled successfully.
|
|
bool | fetch_promise_rejected (const fetch_promise_t *promise) |
| Check if promise was rejected.
|
|
fetch_headers_t * | fetch_headers_new (void) |
| Create a new headers container.
|
|
void | fetch_headers_free (fetch_headers_t *headers) |
| Free a headers container and all its contents.
|
|
static bool | fetch_headers_resize (fetch_headers_t *headers) |
|
void | fetch_headers_append (fetch_headers_t *headers, const char *name, const char *value) |
| Add a header (allows duplicates)
|
|
void | fetch_headers_set (fetch_headers_t *headers, const char *name, const char *value) |
| Set a header (replaces existing)
|
|
void | fetch_headers_delete (fetch_headers_t *headers, const char *name) |
| Remove all headers with the given name.
|
|
const char * | fetch_headers_get (const fetch_headers_t *headers, const char *name) |
| Get the first header value with the given name.
|
|
bool | fetch_headers_has (const fetch_headers_t *headers, const char *name) |
| Check if a header exists.
|
|
fetch_headers_iterator_t | fetch_headers_entries (const fetch_headers_t *headers) |
| Create an iterator for headers.
|
|
bool | fetch_headers_next (fetch_headers_iterator_t *iter, const char **key, const char **value) |
| Get the next header from an iterator.
|
|
fetch_body_t * | fetch_body_text (const char *text) |
| Create a text body.
|
|
fetch_body_t * | fetch_body_json (const char *json) |
| Create a JSON body.
|
|
fetch_body_t * | fetch_body_binary (const void *data, size_t size, const char *content_type) |
| Create a binary body.
|
|
fetch_body_t * | fetch_body_form_data (const char *form_data) |
| Create a form data body.
|
|
void | fetch_body_free (fetch_body_t *body) |
| Free a body object.
|
|
const char * | fetch_response_text (fetch_response_t *response) |
| Get response body as text.
|
|
const void * | fetch_response_array_buffer (fetch_response_t *response, size_t *size) |
| Get response body as binary data.
|
|
const char * | fetch_response_json (fetch_response_t *response) |
| Get response body as JSON text.
|
|
bool | fetch_response_ok (const fetch_response_t *response) |
| Check if response is successful (2xx status)
|
|
uint16_t | fetch_response_status (const fetch_response_t *response) |
| Get HTTP status code.
|
|
const char * | fetch_response_status_text (const fetch_response_t *response) |
| Get HTTP status text.
|
|
const char * | fetch_response_url (const fetch_response_t *response) |
| Get final URL (after redirects)
|
|
fetch_headers_t * | fetch_response_headers (const fetch_response_t *response) |
| Get response headers.
|
|
void | fetch_response_free (fetch_response_t *response) |
| Free a response object.
|
|
void | fetch_promise_free (fetch_promise_t *promise) |
| Free a promise object.
|
|
bool | percent_encode (const char *input, const uint8_t character_set[], char *output, bool append) |
|
fetch_url_search_params_t * | fetch_url_search_params_new (void) |
| Create a new URL search parameters container.
|
|
void | fetch_url_search_params_free (fetch_url_search_params_t *params) |
| Free a URL search parameters container.
|
|
static bool | fetch_url_search_params_resize (fetch_url_search_params_t *params) |
|
void | fetch_url_search_params_append (fetch_url_search_params_t *params, const char *name, const char *value) |
| Add a parameter (allows duplicates)
|
|
void | fetch_url_search_params_set (fetch_url_search_params_t *params, const char *name, const char *value) |
| Set a parameter (replaces existing)
|
|
void | fetch_url_search_params_delete (fetch_url_search_params_t *params, const char *name) |
| Remove all parameters with the given name.
|
|
const char * | fetch_url_search_params_get (const fetch_url_search_params_t *params, const char *name) |
| Get the first parameter value with the given name.
|
|
bool | fetch_url_search_params_has (const fetch_url_search_params_t *params, const char *name) |
| Check if a parameter exists.
|
|
char * | fetch_url_search_params_to_string (const fetch_url_search_params_t *params) |
| Convert parameters to URL-encoded string.
|
|
fetch_body_t * | fetch_body_url_search_params (fetch_url_search_params_t *params) |
| Create a body from URL search parameters.
|
|
fetch_body_t * | fetch_body_file (FETCH_FILE_HANDLE file_handle, size_t size, const char *content_type, bool close_on_free, fetch_file_continue_cb continue_cb, void *userdata) |
| Create a body from a file handle for streaming.
|
|
fetch_url_search_params_iterator_t | fetch_url_search_params_entries (const fetch_url_search_params_t *params) |
| Create an iterator for URL search parameters.
|
|
bool | fetch_url_search_params_next (fetch_url_search_params_iterator_t *iter, const char **key, const char **value) |
| Get the next parameter from an iterator.
|
|
fetch_abort_controller_t * | fetch_abort_controller_new (void) |
| Create a new abort controller.
|
|
void | fetch_abort_controller_abort (fetch_abort_controller_t *controller, const char *reason) |
| Abort operations using this controller.
|
|
bool | fetch_abort_controller_aborted (const fetch_abort_controller_t *controller) |
| Check if controller has been aborted.
|
|
void | fetch_abort_controller_free (fetch_abort_controller_t *controller) |
| Free an abort controller.
|
|
fetch_init_t * | fetch_init_new (void) |
| Create a new request configuration.
|
|
void | fetch_init_free (fetch_init_t *init) |
| Free a request configuration.
|
|
fetch_init_t * | fetch_init_method (fetch_init_t *init, http_method_t method) |
| Set HTTP method (fluent interface)
|
|
fetch_init_t * | fetch_init_headers (fetch_init_t *init, fetch_headers_t *headers) |
| Set request headers (fluent interface)
|
|
fetch_init_t * | fetch_init_body (fetch_init_t *init, fetch_body_t *body) |
| Set request body (fluent interface)
|
|
fetch_init_t * | fetch_init_timeout (fetch_init_t *init, uint32_t timeout_ms) |
| Set request timeout (fluent interface)
|
|
fetch_init_t * | fetch_init_signal (fetch_init_t *init, fetch_abort_controller_t *signal) |
| Set abort signal (fluent interface)
|
|
cookie_jar_t * | fetch_get_cookie_jar (void) |
| Get the current cookie jar.
|
|
size_t | fetch_cookie_jar_count (const char *domain_filter) |
| Count cookies in the jar.
|
|
void | fetch_cookie_jar_clear (void) |
| Clear all cookies from the jar.
|
|
void | fetch_disable_cookies (void) |
| Disable cookie handling.
|
|
cookie_jar_t * | fetch_create_cookie_jar (const char *persistent_file) |
| Create a new cookie jar.
|
|
void | fetch_cookie_jar_free (cookie_jar_t *jar) |
| Free a cookie jar.
|
|
bool | fetch_save_cookies (const char *filename, cookie_jar_t *jar) |
| Save cookies to a file.
|
|
bool | fetch_load_cookies (const char *filename, cookie_jar_t *jar) |
| Load cookies from a file.
|
|
void | fetch_cookie_jar_print (cookie_jar_t *jar, const char *domain_filter) |
| Print cookies to stdout (for debugging)
|
|
const char * | fetch_method_to_string (http_method_t method) |
| Convert HTTP method enum to string.
|
|
http_method_t | fetch_method_from_string (const char *method_str) |
| Convert string to HTTP method enum.
|
|
bool | fetch_is_valid_url (const char *url) |
| Check if a URL is valid.
|
|
const char * | fetch_error_to_string (fetch_error_t error) |
| Convert error code to human-readable string.
|
|