49 lwc_string_unref(self->
name);
50 if (self->
value != NULL) {
51 lwc_string_unref(self->
value);
59 const char *pos = *input;
61 lwc_string *value = NULL;
84 lwc_string_unref(name);
89 directive = malloc(
sizeof(*directive));
90 if (directive == NULL) {
92 lwc_string_unref(value);
94 lwc_string_unref(name);
99 directive->
name = name;
100 directive->
value = value;
114 lwc_string *name, lwc_string **value)
118 while (list != NULL) {
119 if (lwc_string_caseless_isequal(name, list->
name,
120 &match) == lwc_error_ok && match)
129 if (list->
value != NULL) {
130 *value = lwc_string_ref(list->
value);
140 lwc_string **name, lwc_string **value)
145 *name = lwc_string_ref(cur->
name);
146 if (cur->
value != NULL) {
147 *value = lwc_string_ref(cur->
value);
160 while (list != NULL) {
161 if (lwc_string_caseless_isequal(key, list->
name,
162 &match) == lwc_error_ok && match) {
183 lwc_string *name = NULL, *value = NULL;
189 lwc_string_unref(name);
191 lwc_string_unref(value);
193 }
while (key != NULL);
200 const char *pos = lwc_string_data(value);
201 const char *end = pos + lwc_string_length(value);
212 if (
'0' <= *pos && *pos <=
'9') {
213 uint32_t nv = val * 10 + (*pos -
'0');
236 const char *pos = header_value;
240 lwc_string *max_age_str = NULL, *isd_str = NULL;
242 bool include_sub_domains =
false;
260 if (directives != NULL) {
277 corestring_lwc_max_age, &max_age_str);
278 if (error !=
NSERROR_OK || max_age_str == NULL) {
285 lwc_string_unref(max_age_str);
289 lwc_string_unref(max_age_str);
293 corestring_lwc_includesubdomains, &isd_str);
298 if (isd_str != NULL) {
300 lwc_string_unref(isd_str);
304 include_sub_domains =
true;
308 sts = malloc(
sizeof(*sts));
Useful interned string pointers (interface).
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_NOMEM
Memory exhaustion.
#define http__item_list_destroy(l)
#define HTTP__ITEM_INIT(item, n, f)
#define http__item_list_parse(i, p, f, r)
HTTP header parsing functions.
nserror http__parse_token(const char **input, lwc_string **value)
Parse an HTTP token.
void http__skip_LWS(const char **input)
Skip past linear whitespace in input.
nserror http__parse_quoted_string(const char **input, lwc_string **value)
Parse an HTTP quoted-string.
struct http_directive http_directive
Representation of a directive.
static bool check_duplicates(const http_directive *directives)
nserror http_parse_strict_transport_security(const char *header_value, http_strict_transport_security **result)
Parse an HTTP Strict-Transport-Security header value.
void http_strict_transport_security_destroy(http_strict_transport_security *victim)
Destroy a strict transport security object.
static void http_destroy_directive(http_directive *self)
static nserror parse_max_age(lwc_string *value, uint32_t *result)
static void http_directive_list_destroy(http_directive *list)
static nserror http__parse_directive(const char **input, http_directive **result)
static uint32_t count(const http_directive *list, lwc_string *key)
static const http_directive * http_directive_list_iterate(const http_directive *cur, lwc_string **name, lwc_string **value)
bool http_strict_transport_security_include_subdomains(http_strict_transport_security *sts)
Get the value of a strict transport security's includeSubDomains flag.
uint32_t http_strict_transport_security_max_age(http_strict_transport_security *sts)
Get the value of a strict transport security's max-age.
static nserror http_directive_list_find_item(const http_directive *list, lwc_string *name, lwc_string **value)
Representation of an item.
struct http__item * next
Next item in list, or NULL.
Representation of a directive.
lwc_string * value
Parameter value (optional)
lwc_string * name
Parameter name.
Representation of a Strict-Transport-Security.
uint32_t max_age
Max age (delta seconds)
bool include_sub_domains
Whether subdomains are included.