| 3852 | //////////////////////////////////////////////////////// |
| 3853 | |
| 3854 | void |
| 3855 | MIMEHdrImpl::recompute_cooked_stuff(MIMEField *changing_field_or_null) |
| 3856 | { |
| 3857 | int len, tlen; |
| 3858 | const char *s; |
| 3859 | const char *c; |
| 3860 | const char *e; |
| 3861 | const char *token_wks; |
| 3862 | MIMEField *field; |
| 3863 | uint32_t mask = 0; |
| 3864 | |
| 3865 | mime_hdr_cooked_stuff_init(this, changing_field_or_null); |
| 3866 | |
| 3867 | ////////////////////////////////////////////////// |
| 3868 | // (1) cook the Cache-Control header if present // |
| 3869 | ////////////////////////////////////////////////// |
| 3870 | |
| 3871 | // to be safe, recompute unless you know this call is for other cooked field |
| 3872 | if ((changing_field_or_null == nullptr) || (changing_field_or_null->m_wks_idx != MIME_WKSIDX_PRAGMA)) { |
| 3873 | field = mime_hdr_field_find(this, MIME_FIELD_CACHE_CONTROL, MIME_LEN_CACHE_CONTROL); |
| 3874 | |
| 3875 | if (field) { |
| 3876 | // try pathpaths first -- unlike most other fastpaths, this one |
| 3877 | // is probably more useful for polygraph than for the real world |
| 3878 | if (!field->has_dups()) { |
| 3879 | auto val{field->value_get()}; |
| 3880 | if (ptr_len_casecmp(val.data(), val.length(), "public", 6) == 0) { |
| 3881 | mask = MIME_COOKED_MASK_CC_PUBLIC; |
| 3882 | m_cooked_stuff.m_cache_control.m_mask |= mask; |
| 3883 | } else if (ptr_len_casecmp(val.data(), val.length(), "private,no-cache", 16) == 0) { |
| 3884 | mask = MIME_COOKED_MASK_CC_PRIVATE | MIME_COOKED_MASK_CC_NO_CACHE; |
| 3885 | m_cooked_stuff.m_cache_control.m_mask |= mask; |
| 3886 | } |
| 3887 | } |
| 3888 | |
| 3889 | if (mask == 0) { |
| 3890 | HdrCsvIter csv_iter; |
| 3891 | |
| 3892 | for (s = csv_iter.get_first(field, &len); s != nullptr; s = csv_iter.get_next(&len)) { |
| 3893 | e = s + len; |
| 3894 | for (c = s; (c < e) && (ParseRules::is_token(*c)); c++) { |
| 3895 | ; |
| 3896 | } |
| 3897 | tlen = c - s; |
| 3898 | |
| 3899 | // If >= 0 then this is a well known token |
| 3900 | if (hdrtoken_tokenize(s, tlen, &token_wks) >= 0) { |
| 3901 | #if TRACK_COOKING |
| 3902 | Dbg(dbg_ctl_http, "recompute_cooked_stuff: got field '%s'", token_wks); |
| 3903 | #endif |
| 3904 | |
| 3905 | HdrTokenHeapPrefix *p = hdrtoken_wks_to_prefix(token_wks); |
| 3906 | mask = p->wks_type_specific.u.cache_control.cc_mask; |
| 3907 | m_cooked_stuff.m_cache_control.m_mask |= mask; |
| 3908 | |
| 3909 | #if TRACK_COOKING |
| 3910 | Dbg(dbg_ctl_http, " set mask 0x%0X", mask); |
| 3911 | #endif |
no test coverage detected