NetSurf
Data Structures | Typedefs | Functions
cache-control.c File Reference
#include <limits.h>
#include <stdlib.h>
#include "utils/corestrings.h"
#include "utils/http.h"
#include "utils/http/generics.h"
#include "utils/http/primitives.h"
Include dependency graph for cache-control.c:

Go to the source code of this file.

Data Structures

struct  http_cache_control
 Representation of a Cache-Control. More...
 
struct  http_directive
 Representation of a directive. More...
 

Typedefs

typedef struct http_directive http_directive
 Representation of a directive. More...
 

Functions

static void http_destroy_directive (http_directive *self)
 
static nserror http__parse_directive (const char **input, http_directive **result)
 
static void http_directive_list_destroy (http_directive *list)
 
static nserror http_directive_list_find_item (const http_directive *list, lwc_string *name, lwc_string **value)
 
static const http_directivehttp_directive_list_iterate (const http_directive *cur, lwc_string **name, lwc_string **value)
 
static uint32_t count (const http_directive *list, lwc_string *key)
 
static bool check_duplicates (const http_directive *directives)
 
static nserror parse_max_age (lwc_string *value, uint32_t *result)
 
nserror http_parse_cache_control (const char *header_value, http_cache_control **result)
 Parse an HTTP Cache-Control header value. More...
 
void http_cache_control_destroy (http_cache_control *victim)
 Destroy a cache_control object. More...
 
bool http_cache_control_has_max_age (http_cache_control *cc)
 Determine if a valid max-age directive is present. More...
 
uint32_t http_cache_control_max_age (http_cache_control *cc)
 Get the value of a cache control's max-age. More...
 
bool http_cache_control_no_cache (http_cache_control *cc)
 Get the value of a cache control's no-cache flag. More...
 
bool http_cache_control_no_store (http_cache_control *cc)
 Get the value of a cache control's no-store flag. More...
 

Typedef Documentation

◆ http_directive

Representation of a directive.

Function Documentation

◆ check_duplicates()

static bool check_duplicates ( const http_directive directives)
static

Definition at line 174 of file cache-control.c.

References count(), http_directive_list_iterate(), and result.

Referenced by http_parse_cache_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ count()

static uint32_t count ( const http_directive list,
lwc_string *  key 
)
static

◆ http__parse_directive()

static nserror http__parse_directive ( const char **  input,
http_directive **  result 
)
static

Definition at line 58 of file cache-control.c.

References HTTP__ITEM_INIT, http__parse_quoted_string(), http__parse_token(), http__skip_LWS(), http_destroy_directive(), http_directive::name, NSERROR_NOMEM, NSERROR_OK, result, and http_directive::value.

Referenced by http_parse_cache_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_cache_control_destroy()

void http_cache_control_destroy ( http_cache_control victim)

Destroy a cache_control object.

Parameters
victimObject to destroy

Definition at line 326 of file cache-control.c.

Referenced by llcache_fetch_parse_cache_control().

Here is the caller graph for this function:

◆ http_cache_control_has_max_age()

bool http_cache_control_has_max_age ( http_cache_control cc)

Determine if a valid max-age directive is present.

Parameters
ccObject to inspect
Returns
Whether max-age is valid

Definition at line 332 of file cache-control.c.

References http_cache_control::max_age_valid.

Referenced by llcache_fetch_parse_cache_control().

Here is the caller graph for this function:

◆ http_cache_control_max_age()

uint32_t http_cache_control_max_age ( http_cache_control cc)

Get the value of a cache control's max-age.

Parameters
ccObject to inspect
Returns
Max age, in delta-seconds

Definition at line 338 of file cache-control.c.

References http_cache_control::max_age.

Referenced by llcache_fetch_parse_cache_control().

Here is the caller graph for this function:

◆ http_cache_control_no_cache()

bool http_cache_control_no_cache ( http_cache_control cc)

Get the value of a cache control's no-cache flag.

Parameters
ccObject to inspect
Returns
Whether caching is forbidden

Definition at line 344 of file cache-control.c.

References http_cache_control::no_cache.

Referenced by llcache_fetch_parse_cache_control().

Here is the caller graph for this function:

◆ http_cache_control_no_store()

bool http_cache_control_no_store ( http_cache_control cc)

Get the value of a cache control's no-store flag.

Parameters
ccObject to inspect
Returns
Whether persistent caching is forbidden

Definition at line 350 of file cache-control.c.

References http_cache_control::no_store.

Referenced by llcache_fetch_parse_cache_control().

Here is the caller graph for this function:

◆ http_destroy_directive()

static void http_destroy_directive ( http_directive self)
static

Definition at line 49 of file cache-control.c.

References http_directive::name, and http_directive::value.

Referenced by http__parse_directive().

Here is the caller graph for this function:

◆ http_directive_list_destroy()

static void http_directive_list_destroy ( http_directive list)
static

Definition at line 110 of file cache-control.c.

References http__item_list_destroy.

Referenced by http_parse_cache_control().

Here is the caller graph for this function:

◆ http_directive_list_find_item()

static nserror http_directive_list_find_item ( const http_directive list,
lwc_string *  name,
lwc_string **  value 
)
static

Definition at line 115 of file cache-control.c.

References http_directive::base, http_directive::name, http__item::next, NSERROR_NOT_FOUND, NSERROR_OK, and http_directive::value.

Referenced by http_parse_cache_control().

Here is the caller graph for this function:

◆ http_directive_list_iterate()

static const http_directive * http_directive_list_iterate ( const http_directive cur,
lwc_string **  name,
lwc_string **  value 
)
static

Definition at line 140 of file cache-control.c.

References http_directive::base, http_directive::name, http__item::next, and http_directive::value.

Referenced by check_duplicates().

Here is the caller graph for this function:

◆ http_parse_cache_control()

nserror http_parse_cache_control ( const char *  header_value,
http_cache_control **  result 
)

Parse an HTTP Cache-Control header value.

Parameters
header_valueHeader value to parse
resultPointer to location to receive result
Returns
NSERROR_OK on success, NSERROR_NOMEM on memory exhaustion, appropriate error otherwise

Definition at line 235 of file cache-control.c.

References check_duplicates(), http__item_list_parse, http__parse_directive(), http__skip_LWS(), http_directive_list_destroy(), http_directive_list_find_item(), http_cache_control::max_age, http_cache_control::max_age_valid, http_cache_control::no_cache, http_cache_control::no_store, NSERROR_NOMEM, NSERROR_NOT_FOUND, NSERROR_OK, parse_max_age(), and result.

Referenced by llcache_fetch_parse_cache_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_max_age()

static nserror parse_max_age ( lwc_string *  value,
uint32_t *  result 
)
static

Definition at line 200 of file cache-control.c.

References NSERROR_NOT_FOUND, NSERROR_OK, and result.

Referenced by http_parse_cache_control().

Here is the caller graph for this function: