51 lwc_string_unref(self->
name);
52 if (self->
value != NULL) {
53 lwc_string_unref(self->
value);
61 const char *pos = *input;
63 lwc_string *value = NULL;
86 lwc_string_unref(name);
91 directive = malloc(
sizeof(*directive));
92 if (directive == NULL) {
94 lwc_string_unref(value);
96 lwc_string_unref(name);
101 directive->
name = name;
102 directive->
value = value;
116 lwc_string *name, lwc_string **value)
120 while (list != NULL) {
121 if (lwc_string_caseless_isequal(name, list->
name,
122 &match) == lwc_error_ok && match)
131 if (list->
value != NULL) {
132 *value = lwc_string_ref(list->
value);
142 lwc_string **name, lwc_string **value)
147 *name = lwc_string_ref(cur->
name);
148 if (cur->
value != NULL) {
149 *value = lwc_string_ref(cur->
value);
162 while (list != NULL) {
163 if (lwc_string_caseless_isequal(key, list->
name,
164 &match) == lwc_error_ok && match) {
185 lwc_string *name = NULL, *value = NULL;
191 lwc_string_unref(name);
193 lwc_string_unref(value);
195 }
while (key != NULL);
202 const char *pos = lwc_string_data(value);
203 const char *end = pos + lwc_string_length(value);
214 if (
'0' <= *pos && *pos <=
'9') {
215 uint32_t nv = val * 10 + (*pos -
'0');
238 const char *pos = header_value;
242 lwc_string *value_str = NULL;
243 uint32_t max_age = 0;
244 bool max_age_valid =
false;
245 bool no_cache =
false;
246 bool no_store =
false;
264 if (directives != NULL) {
281 corestring_lwc_max_age, &value_str);
282 if (error ==
NSERROR_OK && value_str != NULL) {
285 lwc_string_unref(value_str);
290 corestring_lwc_no_cache, &value_str);
293 if (value_str != NULL) {
294 lwc_string_unref(value_str);
300 corestring_lwc_no_store, &value_str);
303 if (value_str != NULL) {
304 lwc_string_unref(value_str);
310 cc = malloc(
sizeof(*cc));
struct http_directive http_directive
Representation of a directive.
static bool check_duplicates(const http_directive *directives)
static void http_destroy_directive(http_directive *self)
uint32_t http_cache_control_max_age(http_cache_control *cc)
Get the value of a cache control's max-age.
static nserror parse_max_age(lwc_string *value, uint32_t *result)
static void http_directive_list_destroy(http_directive *list)
bool http_cache_control_has_max_age(http_cache_control *cc)
Determine if a valid max-age directive is present.
nserror http_parse_cache_control(const char *header_value, http_cache_control **result)
Parse an HTTP Cache-Control header value.
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)
void http_cache_control_destroy(http_cache_control *victim)
Destroy a cache_control object.
bool http_cache_control_no_cache(http_cache_control *cc)
Get the value of a cache control's no-cache flag.
bool http_cache_control_no_store(http_cache_control *cc)
Get the value of a cache control's no-store flag.
static nserror http_directive_list_find_item(const http_directive *list, lwc_string *name, lwc_string **value)
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.
Representation of an item.
struct http__item * next
Next item in list, or NULL.
Representation of a Cache-Control.
bool no_store
Whether persistent caching is forbidden.
bool max_age_valid
Whether max-age is valid.
uint32_t max_age
Max age (delta seconds)
bool no_cache
Whether caching is forbidden.
Representation of a directive.
lwc_string * value
Parameter value (optional)
lwc_string * name
Parameter name.