|
httpmessage
0.4.0
HTTP message parsing library
|
Classes | |
| struct | httpmessage_headerfield_value |
| HTTP header field value text reference. More... | |
| struct | httpmessage_headerfield |
| HTTP header field and value. More... | |
Functions | |
| HMAPI int | httpmessage_headerfield_name_consume (const char **name, size_t *name_length, const char *text, size_t length) |
| Read the header field name. More... | |
| HMAPI httpmessage_headerfield_value * | httpmessage_headerfield_value_new (void) |
| Allocate and initialize a new header value. More... | |
| HMAPI void | httpmessage_headerfield_value_init (httpmessage_headerfield_value *value) |
| Initialize a header value. More... | |
| HMAPI httpmessage_headerfield_value * | httpmessage_headerfield_value_append_line (httpmessage_headerfield_value *value, const char *text, size_t length) |
| Append a new line of data to the given header value. More... | |
| HMAPI size_t | httpmessage_headerfield_value_total_length (const httpmessage_headerfield_value *value) |
| Get the total length of the header value text. More... | |
| HMAPI int | httpmessage_headerfield_value_merge_lines (char *output, size_t output_size, const httpmessage_headerfield_value *value) |
| Copy the referenced header value lines to a contiguous text buffer. More... | |
| HMAPI void | httpmessage_headerfield_value_free (httpmessage_headerfield_value **value) |
| Free header value and following lines. More... | |
| HMAPI int | httpmessage_headerfield_value_line_consume (const char **value, size_t *value_length, const char *text, size_t length, int option_flags) |
| Read header value content until the end of the current line. More... | |
| HMAPI httpmessage_headerfield * | httpmessage_headerfield_new (void) |
| Allocate and initialize a new header object. More... | |
| HMAPI void | httpmessage_headerfield_init (httpmessage_headerfield *field) |
| Initialize header members. More... | |
| HMAPI void | httpmessage_headerfield_free (httpmessage_headerfield **field) |
| Free header memory. More... | |
| HMAPI int | httpmessage_headerfield_is (const httpmessage_headerfield *field, const char *name) |
| Indicates if the given header field name match the expected name. More... | |
| HMAPI void | httpmessage_headerfield_clear (httpmessage_headerfield *field, int option_flags) |
| Clear header member to their initial state. More... | |
| HMAPI size_t | httpmessage_headerfield_count (httpmessage_headerfield *headerfield_list) |
| Get the number of valid headers in the given header list. More... | |
| HMAPI httpmessage_headerfield * | httpmessage_headerfield_find (httpmessage_headerfield *headerfield_list, const char *name, size_t name_length) |
| Find the first header field matching the given field name. More... | |
| HMAPI int | httpmessage_headerfield_line_consume (httpmessage_headerfield **field, httpmessage_headerfield *current_header, const char *text, size_t length, int option_flags) |
Read header field name and value on a single line
| |
| HMAPI ssize_t | httpmessage_headerfield_write_file (FILE *file, const httpmessage_headerfield *field) |
| Write a HTTP header line to a file. More... | |
| HMAPI ssize_t | httpmessage_headerfield_write_buffer (void *output, size_t output_size, const httpmessage_headerfield *field) |
| Write a HTTP header line to a buffer. More... | |
| HMAPI int | httpmessage_headerfield_list_consume (httpmessage_headerfield *headerfield_list, const char *text, size_t length, int option_flags) |
| Parse all headers in the given text. More... | |
| HMAPI ssize_t | httpmessage_headerfield_list_write_file (FILE *file, const httpmessage_headerfield *headerfield_list) |
| Write HTTP headers to a file. More... | |
| HMAPI ssize_t | httpmessage_headerfield_list_write_buffer (void *output, size_t output_size, const httpmessage_headerfield *headerfield_list) |
| Write a list of HTTP header to a buffer. More... | |
Variables | |
| HTTPMESSAGE_C_BEGIN typedef httpmessage_stringview | httpmessage_headerfield_name |
| Headef field name text reference. | |
| HMAPI void httpmessage_headerfield_clear | ( | httpmessage_headerfield * | field, |
| int | option_flags | ||
| ) |
Clear header member to their initial state.
Except if HTTPMESSAGE_CLEAR_NO_FREE option is set, all dynamically allocated members are freed.
| field | Header to clear |
| option_flags | Option flags. Supported flags are: |
| HMAPI size_t httpmessage_headerfield_count | ( | httpmessage_headerfield * | headerfield_list | ) |
Get the number of valid headers in the given header list.
| headerfield_list | Header list |
headerfield_list | HMAPI httpmessage_headerfield* httpmessage_headerfield_find | ( | httpmessage_headerfield * | headerfield_list, |
| const char * | name, | ||
| size_t | name_length | ||
| ) |
Find the first header field matching the given field name.
| headerfield_list | Header field list. |
| name | Header field name to find. |
| name_length | Header field name length. |
NULL if none of the header fields in the list have the exepected field name. | HMAPI void httpmessage_headerfield_free | ( | httpmessage_headerfield ** | field | ) |
Free header memory.
| field | Header to free |
| HMAPI void httpmessage_headerfield_init | ( | httpmessage_headerfield * | field | ) |
Initialize header members.
Initialize a header descriptor.
| field | Header structure to initialize |
| field | Header descriptor instance |
| HMAPI int httpmessage_headerfield_is | ( | const httpmessage_headerfield * | field, |
| const char * | name | ||
| ) |
Indicates if the given header field name match the expected name.
String comparison is case instensitive.
| field | Header to test field name |
| name | Name to match. The string MUST be null-terminated |
name | HMAPI int httpmessage_headerfield_line_consume | ( | httpmessage_headerfield ** | field, |
| httpmessage_headerfield * | current_header, | ||
| const char * | text, | ||
| size_t | length, | ||
| int | option_flags | ||
| ) |
Read header field name and value on a single line
current_header and header will point to it. If the current line starts with a white psace, the content of the line is added the the current_header value and header will point to current_header
| field | The new header |
| current_header | The current header |
| text | Input text |
| length | Input text length |
| option_flags | Option flags. Supported flags are: |
| HMAPI int httpmessage_headerfield_list_consume | ( | httpmessage_headerfield * | headerfield_list, |
| const char * | text, | ||
| size_t | length, | ||
| int | option_flags | ||
| ) |
Parse all headers in the given text.
Function stops when end of input is reached or if a leading CRLF is found.
| headerfield_list | Header list to populate |
| text | Input text |
| length | Input text length |
| option_flags | Option flags. These flags are passed to httpmessage API functions called internally. |
text. On error, one of httpmessage_result_code | HMAPI ssize_t httpmessage_headerfield_list_write_buffer | ( | void * | output, |
| size_t | output_size, | ||
| const httpmessage_headerfield * | headerfield_list | ||
| ) |
Write a list of HTTP header to a buffer.
| output | Output buffer |
| output_size | Output buffer size |
| headerfield_list | List of headers to write. |
| HMAPI ssize_t httpmessage_headerfield_list_write_file | ( | FILE * | file, |
| const httpmessage_headerfield * | headerfield_list | ||
| ) |
Write HTTP headers to a file.
| file | Output file |
| headerfield_list | List of header to write |
| HMAPI int httpmessage_headerfield_name_consume | ( | const char ** | name, |
| size_t * | name_length, | ||
| const char * | text, | ||
| size_t | length | ||
| ) |
Read the header field name.
Alias of httpmessage_token_consume()
| name | Output field |
| name_length | Output field length |
| text | Input text |
| length | Input text length |
text consumed. On error, one of httpmessage_result_code| HMAPI httpmessage_headerfield* httpmessage_headerfield_new | ( | void | ) |
Allocate and initialize a new header object.
| HMAPI httpmessage_headerfield_value* httpmessage_headerfield_value_append_line | ( | httpmessage_headerfield_value * | value, |
| const char * | text, | ||
| size_t | length | ||
| ) |
Append a new line of data to the given header value.
| value | Header value that will receive the line |
| text | Text to add |
| length | Text length |
| HMAPI void httpmessage_headerfield_value_free | ( | httpmessage_headerfield_value ** | value | ) |
Free header value and following lines.
| value | Header value to free |
| HMAPI void httpmessage_headerfield_value_init | ( | httpmessage_headerfield_value * | value | ) |
Initialize a header value.
| value | Instance to initialize |
| HMAPI int httpmessage_headerfield_value_line_consume | ( | const char ** | value, |
| size_t * | value_length, | ||
| const char * | text, | ||
| size_t | length, | ||
| int | option_flags | ||
| ) |
Read header value content until the end of the current line.
| value | Pointer that will hold a reference to the first meaningful byte of the header value |
| value_length | Pointer that will hold the trimmed header value length |
| text | Input text |
| length | Input text length |
| option_flags | Option flags. Supported flags are |
text consumed. This MAY be greated than the value stored in value_length since leading white space and trailing CRLF and white space are not counted in value_length. On error, one of the httpmessage_result_code| HMAPI int httpmessage_headerfield_value_merge_lines | ( | char * | output, |
| size_t | output_size, | ||
| const httpmessage_headerfield_value * | value | ||
| ) |
Copy the referenced header value lines to a contiguous text buffer.
| output | Output buffer |
| output_size | Output buffer size |
| value | Input header value |
output (excluding the NULL termination character). On error, one of the httpmessage_result_code codes| HMAPI httpmessage_headerfield_value* httpmessage_headerfield_value_new | ( | void | ) |
Allocate and initialize a new header value.
NULL on error | HMAPI size_t httpmessage_headerfield_value_total_length | ( | const httpmessage_headerfield_value * | value | ) |
Get the total length of the header value text.
| value | Header value |
| HMAPI ssize_t httpmessage_headerfield_write_buffer | ( | void * | output, |
| size_t | output_size, | ||
| const httpmessage_headerfield * | field | ||
| ) |
Write a HTTP header line to a buffer.
| output | Output buffer |
| output_size | Output buffer size |
| field | Header to write |
| HMAPI ssize_t httpmessage_headerfield_write_file | ( | FILE * | file, |
| const httpmessage_headerfield * | field | ||
| ) |
Write a HTTP header line to a file.
| file | Output file |
| field | Header to write |
1.8.13