Functions | Variables

HttpTransactCache.cc File Reference

A brief file description. More...

#include "libts.h"
#include "HttpTransact.h"
#include "HttpTransactHeaders.h"
#include "HttpTransactCache.h"
#include "time.h"
#include "HTTP.h"
#include "HttpCompat.h"
#include "Error.h"
#include "InkErrno.h"
Include dependency graph for HttpTransactCache.cc:

Go to the source code of this file.

Functions

static const char * find_etag (const char *raw_tag_field, int raw_tag_field_len, int *length)
 Find the pointer and length of an etag, after stripping off any leading "W/" prefix, and surrounding double quotes.
static bool do_strings_match_strongly (const char *raw_tag_field, int raw_tag_field_len, const char *comma_sep_tag_list, int comma_sep_tag_list_len)
 Match an etag raw_tag_field with a list of tags in the comma-separated string field_to_match, using strong rules.
static bool do_strings_match_weakly (const char *raw_tag_field, int raw_tag_field_len, const char *comma_sep_tag_list, int comma_sep_tag_list_len)
 Match an etag raw_tag_field with a list of tags in the comma-separated string field_to_match, using weak rules.
static bool is_asterisk (char *s)
static bool is_empty (char *s)
static bool do_content_types_match (char *type1, char *subtype1, char *type2, char *subtype2)
 Match request Accept with response Content-Type.
static bool does_charset_match (char *charset1, char *charset2)
 Match request Accept-Charset with response Content-Type.
static bool does_encoding_match (char *enc1, const char *enc2)
 Match request Accept-Encoding with response Content-Encoding.
static bool match_accept_content_encoding (const char *c_raw, MIMEField *accept_field, bool *wildcard_present, float *wildcard_q, float *q)
static bool does_language_range_match (const char *range1, const char *range2)
 Match request Accept-Language with response Content-Language.
static bool match_accept_content_language (const char *c_raw, MIMEField *accept_field, bool *wildcard_present, float *wildcard_q, float *q, int *a_range_length)

Variables

ClassAllocator
< CacheLookupHttpConfig
CacheLookupHttpConfigAllocator ("CacheLookupHttpConfigAllocator")
CacheLookupHttpConfig global_cache_lookup_config

Detailed Description

A brief file description.

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file HttpTransactCache.cc.


Function Documentation

static bool do_content_types_match ( char *  type1,
char *  subtype1,
char *  type2,
char *  subtype2 
) [inline, static]

Match request Accept with response Content-Type.

If the Accept field mime-type value is *, do not attempt to match, but note the q value for the wildcard match. If the type is not *, but the subtype is * and the Accept type and Content type match, again do not attempt to match, but note the q value. If neither of these two cases, match, keeping track of the highest q value for the matches. At the end of the loop over the Accept header field values, if the highest q value is -1.0 (there was no specific match), if there was a wildcard subtype match, set the q value to the wildcard subtype q value. If there is still no match, and there is a wildcard type match, set the q value to the wildcard type q value.

We allow no Content-Type headers in responses to match with quality 1.0.

Returns:
quality (-1: no match, 0..1: poor..good).

Definition at line 505 of file HttpTransactCache.cc.

References is_asterisk(), and is_empty().

Referenced by HttpTransactCache::calculate_quality_of_accept_match().

static bool do_strings_match_strongly ( const char *  raw_tag_field,
int  raw_tag_field_len,
const char *  comma_sep_tag_list,
int  comma_sep_tag_list_len 
) [inline, static]

Match an etag raw_tag_field with a list of tags in the comma-separated string field_to_match, using strong rules.

Definition at line 75 of file HttpTransactCache.cc.

References find_etag(), StrList::head, Str::next, and HttpCompat::parse_comma_list().

Referenced by HttpTransactCache::match_response_to_request_conditionals().

static bool do_strings_match_weakly ( const char *  raw_tag_field,
int  raw_tag_field_len,
const char *  comma_sep_tag_list,
int  comma_sep_tag_list_len 
) [inline, static]

Match an etag raw_tag_field with a list of tags in the comma-separated string field_to_match, using weak rules.

Definition at line 115 of file HttpTransactCache.cc.

References find_etag(), StrList::head, Str::next, and HttpCompat::parse_comma_list().

Referenced by HttpTransactCache::match_response_to_request_conditionals().

static bool does_charset_match ( char *  charset1,
char *  charset2 
) [inline, static]

Match request Accept-Charset with response Content-Type.

Extract the response charset from the Content-Type field - the charset is after the semicolon. Loop through the charsets in the request's Accept-Charset field. If the Accept-Charset value is a wildcard, do not attempt to match. Otherwise match and note the highest q value. If after the loop the q value is -1, indicating no match, then if Accept-Charset had a wildcard, allow it to match - setting q to the wildcard q value. If there is still no match and the Content-Type was the default charset, allow a match with a q value of 1.0.

We allow no Content-Type headers in responses to match with quality 1.0.

Returns:
quality (-1: no match, 0..1: poor..good).

Definition at line 624 of file HttpTransactCache.cc.

References is_asterisk(), and is_empty().

Referenced by HttpTransactCache::calculate_quality_of_accept_charset_match().

static bool does_encoding_match ( char *  enc1,
const char *  enc2 
) [inline, static]

Match request Accept-Encoding with response Content-Encoding.

First determine if the cached document has identity encoding. This can be the case if the document has no Content-Encoding header field or if the Content-Encoding field explicitly lists "identity". Then, if there is no Accept-Encoding header and the cached response uses identity encoding return a match. If there is no Accept-Encoding header and the cached document uses some other form of encoding, also return a match, albeit one with a slightly lower q value (0.999).

If none of the above cases occurs, compare Content-Encoding with Accept-Encoding, by looping over the Content-Encoding values (there may be more than one, since a document may be gzipped, followed by compressed, etc.). If any of the Content-Encoding values are not in the Accept-Encoding header, exit the loop. Before exiting, if there has not been a match, match a wildcard in the Accept-Encoding field and if still no match, match an identity encoding - this may happen if the request did not list "identity" in the Accept-Encoding field, but the response listed it in the Content-Encoding field. In this last case, match with a q value of 0.001.

The return values are:

  • -1.0: Doesn't match
  • 0.999: No Accept-Encoding header, and Content-Encoding does not list "identity".
  • 0.001: Accept-Encoding was not empty, but Content-Encoding was either empty or explicitly listed "identity".
  • 0.0..1.0: Matches with a quality between 0 (poor) and 1 (good).
Returns:
quality (-1: no match, 0..1: poor..good).

Definition at line 746 of file HttpTransactCache.cc.

References is_asterisk().

Referenced by match_accept_content_encoding(), and HttpTransactCache::match_gzip().

static bool does_language_range_match ( const char *  range1,
const char *  range2 
) [inline, static]

Match request Accept-Language with response Content-Language.

Language matching is a little more complicated because of "ranges". First, no Accept-Language header or no Content-Language headers match with q of 1. Otherwise, loop over Content-Languages. If there is a match with a language in the Accept-Language field, keep track of how many characters were in the value. The q value for the longest range is returned. If there was no explicit match or a mismatch, try wildcard matching.

Returns:
quality (-1: no match, 0..1: poor..good).

Definition at line 1000 of file HttpTransactCache.cc.

References ParseRules::ink_tolower(), and NUL.

Referenced by match_accept_content_language().

static const char* find_etag ( const char *  raw_tag_field,
int  raw_tag_field_len,
int *  length 
) [inline, static]

Find the pointer and length of an etag, after stripping off any leading "W/" prefix, and surrounding double quotes.

Definition at line 45 of file HttpTransactCache.cc.

Referenced by do_strings_match_strongly(), and do_strings_match_weakly().

static bool is_asterisk ( char *  s  )  [inline, static]
static bool is_empty ( char *  s  )  [inline, static]

Definition at line 150 of file HttpTransactCache.cc.

References NUL.

Referenced by do_content_types_match(), and does_charset_match().

static bool match_accept_content_encoding ( const char *  c_raw,
MIMEField accept_field,
bool *  wildcard_present,
float *  wildcard_q,
float *  q 
) [inline, static]
static bool match_accept_content_language ( const char *  c_raw,
MIMEField accept_field,
bool *  wildcard_present,
float *  wildcard_q,
float *  q,
int *  a_range_length 
) [inline, static]

Variable Documentation

Definition at line 37 of file HttpTransactCache.cc.