#include <stddef.h>
Go to the source code of this file.
|
| struct | KlUrl |
| | Parsed URL components (points into original URL string). More...
|
| |
|
| #define | KL_URL_MAX 2048 |
| | Maximum URL length for resolved URLs.
|
| |
|
| int | kl_url_parse (const char *url, KlUrl *out) |
| | Parse an HTTP/HTTPS URL into components.
|
| |
| int | kl_url_resolve (const char *base_url, const char *location, char *out, size_t out_size) |
| | Resolve a Location header value against a base URL.
|
| |
◆ KL_URL_MAX
Maximum URL length for resolved URLs.
◆ kl_url_parse()
| int kl_url_parse |
( |
const char * |
url, |
|
|
KlUrl * |
out |
|
) |
| |
Parse an HTTP/HTTPS URL into components.
Supports http://, https://, ws://, and wss:// schemes, IPv6 addresses in brackets ([::1]:port), explicit ports, and path+query. Rejects CRLF injection in hostname and path.
- Parameters
-
| url | URL string to parse. |
| out | Parsed components (pointers into url). |
- Returns
- 0 on success, -1 on error.
◆ kl_url_resolve()
| int kl_url_resolve |
( |
const char * |
base_url, |
|
|
const char * |
location, |
|
|
char * |
out, |
|
|
size_t |
out_size |
|
) |
| |
Resolve a Location header value against a base URL.
Handles absolute URLs (http:// or https://), protocol-relative (//), and absolute-path (/...) references. Strips fragment (#) if present. Bare relative refs (../foo) are not supported and return -1.
- Parameters
-
| base_url | The URL of the current request. |
| location | The Location header value. |
| out | Output buffer for the resolved URL. |
| out_size | Size of the output buffer. |
- Returns
- 0 on success, -1 on error.