MCPcopy Index your code
hub / github.com/apache/httpd / ap_cache_control

Function ap_cache_control

modules/cache/cache_util.c:1002–1133  ·  view source on GitHub ↗

* Parse the Cache-Control and Pragma headers in one go, marking * which tokens appear within the header. Populate the structure * passed in. */

Source from the content-addressed store, hash-verified

1000 * passed in.
1001 */
1002int ap_cache_control(request_rec *r, cache_control_t *cc,
1003 const char *cc_header, const char *pragma_header, apr_table_t *headers)
1004{
1005 char *last;
1006
1007 if (cc->parsed) {
1008 return cc->cache_control || cc->pragma;
1009 }
1010
1011 cc->parsed = 1;
1012 cc->max_age_value = -1;
1013 cc->max_stale_value = -1;
1014 cc->min_fresh_value = -1;
1015 cc->s_maxage_value = -1;
1016
1017 if (pragma_header) {
1018 char *header = apr_pstrdup(r->pool, pragma_header);
1019 const char *token = cache_strqtok(header, CACHE_SEPARATOR, &last);
1020 while (token) {
1021 if (!ap_cstr_casecmp(token, "no-cache")) {
1022 cc->no_cache = 1;
1023 }
1024 token = cache_strqtok(NULL, CACHE_SEPARATOR, &last);
1025 }
1026 cc->pragma = 1;
1027 }
1028
1029 if (cc_header) {
1030 char *endp;
1031 apr_off_t offt;
1032 char *header = apr_pstrdup(r->pool, cc_header);
1033 const char *token = cache_strqtok(header, CACHE_SEPARATOR, &last);
1034 while (token) {
1035 switch (token[0]) {
1036 case 'n':
1037 case 'N': {
1038 if (!ap_cstr_casecmpn(token, "no-cache", 8)) {
1039 if (token[8] == '=') {
1040 cc->no_cache_header = 1;
1041 }
1042 else if (!token[8]) {
1043 cc->no_cache = 1;
1044 }
1045 }
1046 else if (!ap_cstr_casecmp(token, "no-store")) {
1047 cc->no_store = 1;
1048 }
1049 else if (!ap_cstr_casecmp(token, "no-transform")) {
1050 cc->no_transform = 1;
1051 }
1052 break;
1053 }
1054 case 'm':
1055 case 'M': {
1056 if (!ap_cstr_casecmpn(token, "max-age", 7)) {
1057 if (token[7] == '='
1058 && !apr_strtoff(&offt, token + 8, &endp, 10)
1059 && endp > token + 8 && !*endp) {

Callers 4

ap_cache_check_no_cacheFunction · 0.85
ap_cache_check_no_storeFunction · 0.85
cache_check_freshnessFunction · 0.85
cache_save_filterFunction · 0.85

Calls 3

cache_strqtokFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_cstr_casecmpnFunction · 0.85

Tested by

no test coverage detected