|
KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
|
HTTP redirect following (sync + async). More...
#include <keel/allocator.h>#include <keel/client.h>#include <keel/client_pool.h>#include <keel/error.h>#include <keel/event_ctx.h>#include <keel/url.h>

Go to the source code of this file.
Data Structures | |
| struct | KlRedirectConfig |
Macros | |
| #define | KL_REDIRECT_DEFAULT_MAX 10 |
| Default maximum redirects. | |
Typedefs | |
| typedef struct KlRedirectClient | KlRedirectClient |
| typedef void(* | KlRedirectDoneFn) (KlRedirectClient *rc, void *user_data) |
| Callback invoked when an async redirect-following request completes. | |
Functions | |
| int | kl_redirect_request (KlAllocator *alloc, const KlClientConfig *cfg, const KlRedirectConfig *redir, const char *method, const char *url, const KlClientHeader *headers, int num_headers, const char *body, size_t body_len, KlClientResponse *resp) |
| Synchronous HTTP request with automatic redirect following. | |
| int | kl_redirect_request_pooled (KlClientPool *pool, KlAllocator *alloc, const KlClientConfig *cfg, const KlRedirectConfig *redir, const char *method, const char *url, const KlClientHeader *headers, int num_headers, const char *body, size_t body_len, KlClientResponse *resp) |
| Synchronous pooled HTTP request with automatic redirect following. | |
| KlRedirectClient * | kl_redirect_start (KlEventCtx *ev_ctx, KlAllocator *alloc, const KlClientConfig *cfg, const KlRedirectConfig *redir, const char *method, const char *url, const KlClientHeader *headers, int num_headers, const char *body, size_t body_len, KlRedirectDoneFn on_done, void *user_data) |
| Start an asynchronous HTTP request with automatic redirect following. | |
| KlRedirectClient * | kl_redirect_start_pooled (KlClientPool *pool, KlEventCtx *ev_ctx, KlAllocator *alloc, const KlClientConfig *cfg, const KlRedirectConfig *redir, const char *method, const char *url, const KlClientHeader *headers, int num_headers, const char *body, size_t body_len, KlRedirectDoneFn on_done, void *user_data) |
| Start an asynchronous pooled HTTP request with redirect following. | |
| const KlClientResponse * | kl_redirect_response (const KlRedirectClient *rc) |
| Get the final response from a completed redirect client. | |
| int | kl_redirect_error (const KlRedirectClient *rc) |
| Check if the redirect request completed with an error. | |
| KlError | kl_redirect_last_error (const KlRedirectClient *rc) |
| Get the specific error code from a completed redirect request. | |
| void | kl_redirect_cancel (KlRedirectClient *rc) |
| Cancel an in-flight redirect request. | |
| void | kl_redirect_free (KlRedirectClient *rc) |
| Free all redirect client resources. | |
HTTP redirect following (sync + async).
Orthogonal redirect module that wraps the existing client APIs with automatic 3xx redirect following. Does not modify client.h or client.c. Supports both unpooled and pooled variants.
| #define KL_REDIRECT_DEFAULT_MAX 10 |
Default maximum redirects.
| typedef struct KlRedirectClient KlRedirectClient |
| typedef void(* KlRedirectDoneFn) (KlRedirectClient *rc, void *user_data) |
Callback invoked when an async redirect-following request completes.
| int kl_redirect_request | ( | KlAllocator * | alloc, |
| const KlClientConfig * | cfg, | ||
| const KlRedirectConfig * | redir, | ||
| const char * | method, | ||
| const char * | url, | ||
| const KlClientHeader * | headers, | ||
| int | num_headers, | ||
| const char * | body, | ||
| size_t | body_len, | ||
| KlClientResponse * | resp | ||
| ) |
Synchronous HTTP request with automatic redirect following.
Follows 301/302/303/307/308 redirects up to max_redirects hops. Method transformation per RFC 7231/7538: 301/302/303 change POST/PUT/PATCH to GET (dropping body); 307/308 preserve method.
| int kl_redirect_request_pooled | ( | KlClientPool * | pool, |
| KlAllocator * | alloc, | ||
| const KlClientConfig * | cfg, | ||
| const KlRedirectConfig * | redir, | ||
| const char * | method, | ||
| const char * | url, | ||
| const KlClientHeader * | headers, | ||
| int | num_headers, | ||
| const char * | body, | ||
| size_t | body_len, | ||
| KlClientResponse * | resp | ||
| ) |
Synchronous pooled HTTP request with automatic redirect following.
| KlRedirectClient * kl_redirect_start | ( | KlEventCtx * | ev_ctx, |
| KlAllocator * | alloc, | ||
| const KlClientConfig * | cfg, | ||
| const KlRedirectConfig * | redir, | ||
| const char * | method, | ||
| const char * | url, | ||
| const KlClientHeader * | headers, | ||
| int | num_headers, | ||
| const char * | body, | ||
| size_t | body_len, | ||
| KlRedirectDoneFn | on_done, | ||
| void * | user_data | ||
| ) |
Start an asynchronous HTTP request with automatic redirect following.
| KlRedirectClient * kl_redirect_start_pooled | ( | KlClientPool * | pool, |
| KlEventCtx * | ev_ctx, | ||
| KlAllocator * | alloc, | ||
| const KlClientConfig * | cfg, | ||
| const KlRedirectConfig * | redir, | ||
| const char * | method, | ||
| const char * | url, | ||
| const KlClientHeader * | headers, | ||
| int | num_headers, | ||
| const char * | body, | ||
| size_t | body_len, | ||
| KlRedirectDoneFn | on_done, | ||
| void * | user_data | ||
| ) |
Start an asynchronous pooled HTTP request with redirect following.
| const KlClientResponse * kl_redirect_response | ( | const KlRedirectClient * | rc | ) |
Get the final response from a completed redirect client.
| int kl_redirect_error | ( | const KlRedirectClient * | rc | ) |
Check if the redirect request completed with an error.
| KlError kl_redirect_last_error | ( | const KlRedirectClient * | rc | ) |
Get the specific error code from a completed redirect request.
| void kl_redirect_cancel | ( | KlRedirectClient * | rc | ) |
Cancel an in-flight redirect request.
| void kl_redirect_free | ( | KlRedirectClient * | rc | ) |
Free all redirect client resources.