39#include "HTTPCacheTable.h"
41#include "HTTPCacheDisconnectedMode.h"
105 FILE *d_locked_open_file;
107 bool d_cache_enabled;
108 bool d_cache_protected;
110 bool d_expire_ignored;
111 bool d_always_validate;
113 unsigned long d_total_size;
114 unsigned long d_folder_size;
115 unsigned long d_gc_buffer;
116 unsigned long d_max_entry_size;
117 int d_default_expiration;
119 vector<string> d_cache_control;
129 pthread_mutex_t d_cache_mutex;
134 vector<string> d_open_files;
136 static HTTPCache *_instance;
138 friend class HTTPCacheTest;
139 friend class HTTPConnectTest;
141 friend class HTTPCacheInterruptHandler;
144 HTTPCache(
const HTTPCache &);
146 HTTPCache &operator=(
const HTTPCache &);
148 HTTPCache(
string cache_root,
bool force);
150 static void delete_instance();
152 void set_cache_root(
const string &root =
"");
153 void create_cache_root(
const string &cache_root);
156 bool get_single_user_lock(
bool force =
false);
157 void release_single_user_lock();
159 bool is_url_in_cache(
const string &url);
163 void write_metadata(
const string &cachename,
const vector<string> &headers);
164 void read_metadata(
const string &cachename, vector<string> &headers);
165 int write_body(
const string &cachename,
const FILE *src);
166 FILE *open_body(
const string &cachename);
169 bool startGC()
const;
171 void perform_garbage_collection();
177 static HTTPCache *
instance(
const string &cache_root,
bool force =
false);
189 bool is_expire_ignored()
const;
206 void lock_cache_interface() {
207 DBG(cerr <<
"Locking interface... ");
208 LOCK(&d_cache_mutex);
209 DBGN(cerr <<
"Done" << endl);
211 void unlock_cache_interface() {
212 DBG(cerr <<
"Unlocking interface... ");
213 UNLOCK(&d_cache_mutex);
214 DBGN(cerr <<
"Done" << endl);
218 bool cache_response(
const string &url, time_t request_time,
const vector<string> &headers,
const FILE *body);
219 void update_response(
const string &url, time_t request_time,
const vector<string> &headers);
CacheDisconnectedMode get_cache_disconnected() const
bool cache_response(const string &url, time_t request_time, const vector< string > &headers, const FILE *body)
static HTTPCache * instance(const string &cache_root, bool force=false)
vector< string > get_cache_control()
void set_expire_ignored(bool mode)
void set_default_expiration(int exp_time)
string get_cache_root() const
void set_cache_disconnected(CacheDisconnectedMode mode)
void release_cached_response(FILE *response)
vector< string > get_conditional_request_headers(const string &url)
unsigned long get_max_entry_size() const
void set_cache_enabled(bool mode)
unsigned long get_max_size() const
void set_max_entry_size(unsigned long size)
bool get_always_validate() const
int get_default_expiration() const
bool is_url_valid(const string &url)
void set_always_validate(bool validate)
void update_response(const string &url, time_t request_time, const vector< string > &headers)
void set_max_size(unsigned long size)
void set_cache_control(const vector< string > &cc)
FILE * get_cached_response(const string &url, vector< string > &headers, string &cacheName)
bool is_cache_enabled() const
top level DAP object to house generic methods
bool is_hop_by_hop_header(const string &header)