![]() |
BSB Developer Docs
|
Utility functions for dealing with HTTP headers. More...
#include <core/string.h>Go to the source code of this file.
Data Structures | |
| struct | HttpHeader |
| Single HTTP header structure (key: value). More... | |
Typedefs | |
| typedef struct HttpHeader | HttpHeader |
| Single HTTP header structure (key: value). | |
Functions | |
| HttpHeaders * | http_headers_alloc (void) |
| Create an empty HttpHeaders instance. | |
| void | http_headers_free (HttpHeaders *instance) |
| Delete the HttpHeaders instance. | |
| bool | http_headers_parse (HttpHeaders *instance, const char *data, size_t data_len) |
| Parse the HTTP headers from a string. | |
| size_t | http_headers_get_count (const HttpHeaders *instance) |
| Get the number of header elements held in the instance. | |
| const HttpHeader * | http_headers_get_by_index (const HttpHeaders *instance, size_t index) |
| Get the header element by its index. | |
| const HttpHeader * | http_headers_get (const HttpHeaders *instance, const char *key) |
| Get the header element by its string key. | |
| void | http_headers_set (HttpHeaders *instance, const char *key, const char *value) |
| Set the header element under the string key. | |
Utility functions for dealing with HTTP headers.
| HttpHeaders * http_headers_alloc | ( | void | ) |
Create an empty HttpHeaders instance.
| void http_headers_free | ( | HttpHeaders * | instance | ) |
Delete the HttpHeaders instance.
| [in,out] | instance | pointer to the instance to be deleted |
| const HttpHeader * http_headers_get | ( | const HttpHeaders * | instance, |
| const char * | key ) |
Get the header element by its string key.
The key string is case-insensitive (i.e. "KeY" and "key" are treated the same).
parse() or set() functions or deleting it using http_headers_free().| [in] | instance | pointer to the instance to be queried |
| [in] | key | zero-terminated string containing the header name (key) |
NULL if none exists | const HttpHeader * http_headers_get_by_index | ( | const HttpHeaders * | instance, |
| size_t | index ) |
Get the header element by its index.
parse() or set() functions or deleting it using http_headers_free().| [in] | instance | pointer to the instance to be queried |
| [in] | index | the desired element index (must be < total number of elements) |
| size_t http_headers_get_count | ( | const HttpHeaders * | instance | ) |
Get the number of header elements held in the instance.
| [in] | instance | pointer to the instance to be queried |
| bool http_headers_parse | ( | HttpHeaders * | instance, |
| const char * | data, | ||
| size_t | data_len ) |
Parse the HTTP headers from a string.
| [in,out] | instance | pointer to the instance to hold the parsing results |
| [in] | data | pointer to the source string (not required to be zero-terminated) |
| [in] | data_len | length of the source string in bytes |
true if the input data could be parsed, false otherwise | void http_headers_set | ( | HttpHeaders * | instance, |
| const char * | key, | ||
| const char * | value ) |
Set the header element under the string key.
The key string is case-insensitive (i.e. "KeY" and "key" are treated the same).
If an element already exists under the provided key, its value will be replaced with the new one, otherwise a new element will be inserted.
| [in,out] | instance | pointer to the instance to be modified |
| [in] | key | zero-terminated string containing the header name (key) |
| [in] | value | zero-terminated string containing the value |