#include <HttpTransactCache.h>
Static Public Member Functions | |
static int | SelectFromAlternates (CacheHTTPInfoVector *cache_vector_data, HTTPHdr *client_request, CacheLookupHttpConfig *cache_lookup_http_config_params) |
Given a set of alternates, select the best match. | |
static float | calculate_quality_of_match (CacheLookupHttpConfig *http_config_params, HTTPHdr *client_request, HTTPHdr *obj_client_request, HTTPHdr *obj_origin_server_response) |
For cached req/res and incoming req, return quality of match. | |
static float | calculate_quality_of_accept_match (MIMEField *accept_field, MIMEField *content_field) |
static float | calculate_quality_of_accept_charset_match (MIMEField *accept_field, MIMEField *content_field, MIMEField *cached_accept_field=NULL) |
static float | calculate_quality_of_accept_encoding_match (MIMEField *accept_field, MIMEField *content_field, MIMEField *cached_accept_field=NULL) |
static ContentEncoding | match_gzip (MIMEField *accept_field) |
static float | calculate_quality_of_accept_language_match (MIMEField *accept_field, MIMEField *content_field, MIMEField *cached_accept_field=NULL) |
static Variability_t | CalcVariability (CacheLookupHttpConfig *http_config_params, HTTPHdr *client_request, HTTPHdr *obj_client_request, HTTPHdr *obj_origin_server_response) |
If the cached object contains a Vary header, then the object only matches if ALL of the headers named in Vary are present in the new request, and these match the headers in the stored request. | |
static HTTPStatus | match_response_to_request_conditionals (HTTPHdr *ua_request, HTTPHdr *c_response) |
If the request has If-modified-since or If-none-match, HTTP_STATUS_NOT_MODIFIED is returned if both or the existing one (if only one exists) fails; otherwise, the response's status code is returned. |
Definition at line 100 of file HttpTransactCache.h.
float HttpTransactCache::calculate_quality_of_accept_charset_match | ( | MIMEField * | accept_field, | |
MIMEField * | content_field, | |||
MIMEField * | cached_accept_field = NULL | |||
) | [static] |
Definition at line 631 of file HttpTransactCache.cc.
References Debug, does_charset_match(), HttpCompat::find_Q_param_in_strlist(), StrList::head, ink_strlcpy(), Str::len, HttpCompat::lookup_param_in_semicolon_string(), Str::next, HttpCompat::parse_semicolon_list(), Str::str, MIMEField::value_get(), and MIMEField::value_get_comma_list().
Referenced by calculate_quality_of_match().
float HttpTransactCache::calculate_quality_of_accept_encoding_match | ( | MIMEField * | accept_field, | |
MIMEField * | content_field, | |||
MIMEField * | cached_accept_field = NULL | |||
) | [static] |
Definition at line 843 of file HttpTransactCache.cc.
References Debug, GZIP, StrList::head, Str::len, match_accept_content_encoding(), match_gzip(), Str::next, Str::str, MIMEField::value_get(), and MIMEField::value_get_comma_list().
Referenced by calculate_quality_of_match().
float HttpTransactCache::calculate_quality_of_accept_language_match | ( | MIMEField * | accept_field, | |
MIMEField * | content_field, | |||
MIMEField * | cached_accept_field = NULL | |||
) | [static] |
Definition at line 1082 of file HttpTransactCache.cc.
References Debug, StrList::head, match_accept_content_language(), Str::next, Str::str, MIMEField::value_get(), and MIMEField::value_get_comma_list().
Referenced by calculate_quality_of_match().
float HttpTransactCache::calculate_quality_of_accept_match | ( | MIMEField * | accept_field, | |
MIMEField * | content_field | |||
) | [static] |
Definition at line 514 of file HttpTransactCache.cc.
References do_content_types_match(), HttpCompat::find_Q_param_in_strlist(), StrList::head, ink_assert, is_asterisk(), Str::len, Str::next, HttpCompat::parse_mime_type(), HttpCompat::parse_semicolon_list(), Str::str, MIMEField::value_get(), and MIMEField::value_get_comma_list().
Referenced by calculate_quality_of_match().
float HttpTransactCache::calculate_quality_of_match | ( | CacheLookupHttpConfig * | http_config_param, | |
HTTPHdr * | client_request, | |||
HTTPHdr * | obj_client_request, | |||
HTTPHdr * | obj_origin_server_response | |||
) | [static] |
For cached req/res and incoming req, return quality of match.
The current school of thought: quality 1st, freshness 2nd. This function takes a user agent request client_request and the two headers for a cached object (obj_client_request and obj_origin_server_response), and returns a floating point number for how well the object matches the client's request.
Two factors currently affect a match: Accept headers, which filter and sort the matches, and Vary headers, which constrain whether a dynamic document matches a request.
Note: According to the specs, specific matching takes precedence over wildcard matching. For example, listed in precedence: text/html;q=0.5, text/ascii, image/'*', '*'/'*'. So, ideally, in choosing between alternates, we should given preference to those which matched specifically over those which matched with wildcards.
Definition at line 299 of file HttpTransactCache.cc.
References calculate_quality_of_accept_charset_match(), calculate_quality_of_accept_encoding_match(), calculate_quality_of_accept_language_match(), calculate_quality_of_accept_match(), CalcVariability(), HTTPHdr::clear(), HTTPHdr::copy_shallow(), Debug, MIMEHdr::field_find(), FeatureAPIHooks< ID, N >::get(), http_global_hooks, HTTP_WKSIDX_PURGE, CacheLookupHttpConfig::ignore_accept_charset_mismatch, CacheLookupHttpConfig::ignore_accept_encoding_mismatch, CacheLookupHttpConfig::ignore_accept_language_mismatch, CacheLookupHttpConfig::ignore_accept_mismatch, APIHook::invoke(), HttpAltInfo::m_cached_req, HttpAltInfo::m_cached_resp, HttpAltInfo::m_client_req, HttpAltInfo::m_qvalue, HTTPHdr::method_get_wksidx(), MIME_FIELD_ACCEPT, MIME_FIELD_ACCEPT_CHARSET, MIME_FIELD_ACCEPT_ENCODING, MIME_FIELD_ACCEPT_LANGUAGE, MIME_FIELD_CONTENT_ENCODING, MIME_FIELD_CONTENT_LANGUAGE, MIME_FIELD_CONTENT_TYPE, MIME_LEN_ACCEPT, MIME_LEN_ACCEPT_CHARSET, MIME_LEN_ACCEPT_ENCODING, MIME_LEN_ACCEPT_LANGUAGE, MIME_LEN_CONTENT_ENCODING, MIME_LEN_CONTENT_LANGUAGE, MIME_LEN_CONTENT_TYPE, MIME_PRESENCE_VARY, APIHook::next(), MIMEHdr::presence(), TS_EVENT_HTTP_SELECT_ALT, TS_HTTP_SELECT_ALT_HOOK, and VARIABILITY_NONE.
Referenced by SelectFromAlternates().
Variability_t HttpTransactCache::CalcVariability | ( | CacheLookupHttpConfig * | http_config_params, | |
HTTPHdr * | client_request, | |||
HTTPHdr * | obj_client_request, | |||
HTTPHdr * | obj_origin_server_response | |||
) | [static] |
If the cached object contains a Vary header, then the object only matches if ALL of the headers named in Vary are present in the new request, and these match the headers in the stored request.
We relax this rule to allow matches if neither the current nor original client headers contained a varying header. This is different from what is stated in the specs.
Definition at line 1162 of file HttpTransactCache.cc.
References CacheLookupHttpConfig::cache_enable_default_vary_headers, CacheLookupHttpConfig::cache_global_user_agent_header, CacheLookupHttpConfig::cache_vary_default_images, CacheLookupHttpConfig::cache_vary_default_other, CacheLookupHttpConfig::cache_vary_default_text, StrList::count, Debug, HttpCompat::do_header_values_rfc2068_14_43_match(), StrList::dump(), MIMEHdr::field_find(), hdrtoken_string_to_wks(), StrList::head, CacheLookupHttpConfig::ignore_accept_encoding_mismatch, ink_assert, is_debug_tag_set, MIME_FIELD_CONTENT_TYPE, MIME_FIELD_VARY, MIME_LEN_CONTENT_TYPE, MIME_LEN_VARY, MIME_PRESENCE_VARY, Str::next, NUL, HttpCompat::parse_comma_list(), HttpCompat::parse_mime_type_with_len(), MIMEHdr::presence(), MIMEHdr::value_get(), and MIMEHdr::value_get_comma_list().
Referenced by calculate_quality_of_match().
ContentEncoding HttpTransactCache::match_gzip | ( | MIMEField * | accept_field | ) | [static] |
Definition at line 765 of file HttpTransactCache.cc.
References does_encoding_match(), HttpCompat::find_Q_param_in_strlist(), StrList::head, Str::next, HttpCompat::parse_semicolon_list(), Str::str, and MIMEField::value_get_comma_list().
Referenced by calculate_quality_of_accept_encoding_match(), and HttpTransact::ModifyRequest().
HTTPStatus HttpTransactCache::match_response_to_request_conditionals | ( | HTTPHdr * | request, | |
HTTPHdr * | response | |||
) | [static] |
If the request has If-modified-since or If-none-match, HTTP_STATUS_NOT_MODIFIED is returned if both or the existing one (if only one exists) fails; otherwise, the response's status code is returned.
If the request has If-unmodified-since or If-match, HTTP_STATUS_PRECONDITION_FAILED is returned if one fails; otherwise, the response's status code is returned.
If the request is a RANGE request with If-range, HTTP_STATUS_RANGE_NOT_SATISFIABLE is returned if the If-range condition is not satisfied (or fails); that means the document is changed and the whole document should be returned with 200 status code. Otherwise, the response's status code is returned.
Definition at line 1310 of file HttpTransactCache.cc.
References do_strings_match_strongly(), do_strings_match_weakly(), MIMEHdr::get_if_modified_since(), MIMEHdr::get_if_range_date(), MIMEHdr::get_if_unmodified_since(), MIMEHdr::get_last_modified(), HTTP_STATUS_NONE, ink_assert, MIME_FIELD_ETAG, MIME_FIELD_IF_MATCH, MIME_FIELD_IF_NONE_MATCH, MIME_FIELD_IF_RANGE, MIME_LEN_ETAG, MIME_LEN_IF_MATCH, MIME_LEN_IF_NONE_MATCH, MIME_LEN_IF_RANGE, MIME_PRESENCE_IF_MATCH, MIME_PRESENCE_IF_MODIFIED_SINCE, MIME_PRESENCE_IF_NONE_MATCH, MIME_PRESENCE_IF_RANGE, MIME_PRESENCE_IF_UNMODIFIED_SINCE, MIME_PRESENCE_RANGE, MIMEHdr::presence(), HTTPHdr::status_get(), and MIMEHdr::value_get().
Referenced by HttpTransact::build_response_from_cache(), and HttpTransact::handle_cache_operation_on_forward_server_response().
int HttpTransactCache::SelectFromAlternates | ( | CacheHTTPInfoVector * | cache_vector, | |
HTTPHdr * | client_request, | |||
CacheLookupHttpConfig * | http_config_params | |||
) | [static] |
Given a set of alternates, select the best match.
The current school of thought: quality 1st, freshness 2nd. Loop through alternates and find the one with the highest quality factor. Then determine if it is fresh enough. If not, find the next best match. In keeping with "quality is job 1", subsequent matches will only be considered if their quality is equal to the quality of the first match.
Definition at line 168 of file HttpTransactCache.cc.
References ACQUIRE_PRINT_LOCK, HttpTransactHeaders::calculate_document_age(), calculate_quality_of_match(), CacheHTTPInfoVector::count(), Debug, diags, CacheHTTPInfoVector::get(), MIMEHdr::get_date(), ink_assert, ink_cluster_time(), Diags::on(), HTTPHdr::print(), RELEASE_PRINT_LOCK, HTTPHdr::valid(), and zero_key.
Referenced by CacheVC::openReadChooseWriter(), and CacheVC::openReadStartHead().