httpmessage  0.4.0
HTTP message parsing library
Classes | Functions | Variables
header.h File Reference

HTTP header parsing and manipulation. More...

#include "httpmessage/preprocessor.h"
#include "httpmessage/text.h"
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
Include dependency graph for header.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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 void httpmessage_headerfield_value_clear (httpmessage_headerfield_value *value, int option_flags)
 Initialize a header field value. More...
 
HMAPI httpmessage_headerfield_valuehttpmessage_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_valuehttpmessage_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_headerfieldhttpmessage_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_headerfieldhttpmessage_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

  • If the current line starts by a header field name, a new header is created assigned as next header of current_header and header will point to it.
More...
 
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.
 

Detailed Description

HTTP header parsing and manipulation.

Function Documentation

◆ httpmessage_headerfield_value_clear()

HMAPI void httpmessage_headerfield_value_clear ( httpmessage_headerfield_value value,
int  option_flags 
)

Initialize a header field value.

Ensure all structure member are initialize with a meaningful value.

Parameters
valueHeader field value to initialize
option_flagsOption flags. Supported flags are:
See also
httpmessage_option_flags