Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #if !defined (_HttpTransactCache_h_)
00032 #define _HttpTransactCache_h_
00033
00034 #include "libts.h"
00035
00036 struct CacheHTTPInfoVector;
00037
00038 class CacheLookupHttpConfig
00039 {
00040 public:
00041 bool cache_global_user_agent_header;
00042 bool cache_enable_default_vary_headers;
00043 unsigned ignore_accept_mismatch;
00044 unsigned ignore_accept_language_mismatch;
00045 unsigned ignore_accept_encoding_mismatch;
00046 unsigned ignore_accept_charset_mismatch;
00047 char *cache_vary_default_text;
00048 char *cache_vary_default_images;
00049 char *cache_vary_default_other;
00050
00051 inkcoreapi int marshal_length();
00052 inkcoreapi int marshal(char *buf, int length);
00053 int unmarshal(Arena * arena, const char *buf, int length);
00054
00055 CacheLookupHttpConfig():
00056 cache_global_user_agent_header(false),
00057 cache_enable_default_vary_headers(false),
00058 ignore_accept_mismatch(0),
00059 ignore_accept_language_mismatch(0),
00060 ignore_accept_encoding_mismatch(0),
00061 ignore_accept_charset_mismatch(0),
00062 cache_vary_default_text(NULL), cache_vary_default_images(NULL), cache_vary_default_other(NULL)
00063 { }
00064
00065 void *operator new(size_t size, void *mem);
00066 void operator delete(void *mem);
00067 };
00068
00069 extern ClassAllocator<CacheLookupHttpConfig> CacheLookupHttpConfigAllocator;
00070
00071 extern CacheLookupHttpConfig global_cache_lookup_config;
00072
00073 inline void *
00074 CacheLookupHttpConfig::operator new(size_t size, void *mem)
00075 {
00076 (void) size;
00077 return mem;
00078 }
00079
00080 inline void
00081 CacheLookupHttpConfig::operator delete(void *mem)
00082 {
00083 CacheLookupHttpConfigAllocator.free((CacheLookupHttpConfig *) mem);
00084 }
00085
00086 enum Variability_t
00087 {
00088 VARIABILITY_NONE = 0,
00089 VARIABILITY_SOME,
00090 VARIABILITY_ALL
00091 };
00092
00093 enum ContentEncoding
00094 {
00095 NO_GZIP = 0,
00096 GZIP
00097 };
00098
00099
00100 class HttpTransactCache
00101 {
00102 public:
00103
00104
00105
00106
00107
00108 static int SelectFromAlternates(CacheHTTPInfoVector * cache_vector_data,
00109 HTTPHdr * client_request, CacheLookupHttpConfig * cache_lookup_http_config_params);
00110
00111 static float calculate_quality_of_match(CacheLookupHttpConfig * http_config_params, HTTPHdr * client_request,
00112 HTTPHdr * obj_client_request,
00113 HTTPHdr * obj_origin_server_response);
00114
00115 static float calculate_quality_of_accept_match(MIMEField * accept_field, MIMEField * content_field);
00116
00117 static float calculate_quality_of_accept_charset_match(MIMEField * accept_field,
00118 MIMEField * content_field,
00119 MIMEField * cached_accept_field = NULL);
00120
00121 static float calculate_quality_of_accept_encoding_match(MIMEField * accept_field,
00122 MIMEField * content_field,
00123 MIMEField * cached_accept_field = NULL);
00124 static ContentEncoding match_gzip(MIMEField * accept_field);
00125
00126 static float calculate_quality_of_accept_language_match(MIMEField * accept_field,
00127 MIMEField * content_field,
00128 MIMEField * cached_accept_field = NULL);
00129
00130
00131
00132
00133
00134 static Variability_t CalcVariability(CacheLookupHttpConfig * http_config_params, HTTPHdr * client_request,
00135 HTTPHdr * obj_client_request,
00136 HTTPHdr * obj_origin_server_response
00137 );
00138
00139 static HTTPStatus match_response_to_request_conditionals(HTTPHdr * ua_request, HTTPHdr * c_response);
00140
00141 };
00142
00143 #endif