Functions for managing HTTP headers.
More...
Functions for managing HTTP headers.
◆ fetch_headers_append()
void fetch_headers_append |
( |
fetch_headers_t * | headers, |
|
|
const char * | name, |
|
|
const char * | value ) |
Add a header (allows duplicates)
- Parameters
-
headers | Headers container |
name | Header name |
value | Header value |
- Note
- Memory: Makes copies of name and value strings
◆ fetch_headers_delete()
Remove all headers with the given name.
- Parameters
-
headers | Headers container |
name | Header name to remove (case-insensitive) |
◆ fetch_headers_entries()
Create an iterator for headers.
- Parameters
-
headers | Headers to iterate |
- Returns
- Iterator object (no cleanup required)
◆ fetch_headers_free()
Free a headers container and all its contents.
- Parameters
-
headers | Headers to free (can be NULL) |
- Note
- Memory: Frees the headers object and all contained strings
◆ fetch_headers_get()
const char * fetch_headers_get |
( |
const fetch_headers_t * | headers, |
|
|
const char * | name ) |
Get the first header value with the given name.
- Parameters
-
headers | Headers container |
name | Header name (case-insensitive) |
- Returns
- Header value (owned by headers, do not free), or NULL if not found
- Note
- Memory: Returned string is owned by the headers object
if (content_type) {
printf("Content-Type: %s\n", content_type);
}
◆ fetch_headers_has()
bool fetch_headers_has |
( |
const fetch_headers_t * | headers, |
|
|
const char * | name ) |
Check if a header exists.
- Parameters
-
headers | Headers container |
name | Header name (case-insensitive) |
- Returns
- true if header exists
◆ fetch_headers_new()
Create a new headers container.
- Returns
- New headers object (caller owns, must call fetch_headers_free()), or NULL on memory allocation failure
- Note
- Memory: Returns owned object that must be freed
if (!headers) {
fprintf(stderr, "Failed to create headers\n");
return -1;
}
◆ fetch_headers_next()
Get the next header from an iterator.
- Parameters
-
iter | Iterator object |
key | Output pointer for header name (owned by headers, do not free) |
value | Output pointer for header value (owned by headers, do not free) |
- Returns
- true if a header was returned, false if iteration complete
- Note
- Memory: Returned strings are owned by the headers object
const char *key, *value;
printf("%s: %s\n", key, value);
}
◆ fetch_headers_set()
void fetch_headers_set |
( |
fetch_headers_t * | headers, |
|
|
const char * | name, |
|
|
const char * | value ) |
Set a header (replaces existing)
- Parameters
-
headers | Headers container |
name | Header name (case-insensitive) |
value | Header value |
- Note
- Memory: Makes copies of name and value strings