39 #ifndef _http_cache_table_h
47 #ifndef _internalerr_h
61 #ifndef _response_too_big_err_h
65 #ifndef _http_cache_disconnected_mode_h
69 #ifndef _signal_handler_registered_err_h
136 FILE *d_locked_open_file;
138 bool d_cache_enabled;
139 bool d_cache_protected;
141 bool d_expire_ignored;
142 bool d_always_validate;
144 unsigned long d_total_size;
145 unsigned long d_folder_size;
146 unsigned long d_gc_buffer;
147 unsigned long d_max_entry_size;
148 int d_default_expiration;
150 vector<string> d_cache_control;
160 pthread_mutex_t d_cache_mutex;
165 vector<string> d_open_files;
169 friend class HTTPCacheTest;
170 friend class HTTPConnectTest;
176 throw InternalErr(__FILE__, __LINE__,
"Unimplemented");
179 throw InternalErr(__FILE__, __LINE__,
"Unimplemented");
181 HTTPCache &operator=(
const HTTPCache &) {
182 throw InternalErr(__FILE__, __LINE__,
"Unimplemented");
185 HTTPCache(
string cache_root,
bool force);
187 static void delete_instance();
189 void set_cache_root(
const string &root =
"");
190 void create_cache_root(
const string &cache_root);
193 bool get_single_user_lock(
bool force =
false);
194 void release_single_user_lock();
196 bool is_url_in_cache(
const string &url);
200 void write_metadata(
const string &cachename,
const vector<string> &headers);
201 void read_metadata(
const string &cachename, vector<string> &headers);
202 int write_body(
const string &cachename,
const FILE *src);
203 FILE *open_body(
const string &cachename);
206 bool startGC()
const;
208 void perform_garbage_collection();
214 static HTTPCache *instance(
const string &cache_root,
bool force =
false);
215 virtual ~HTTPCache();
217 string get_cache_root()
const;
219 void set_cache_enabled(
bool mode);
220 bool is_cache_enabled()
const;
225 void set_expire_ignored(
bool mode);
226 bool is_expire_ignored()
const;
228 void set_max_size(
unsigned long size);
229 unsigned long get_max_size()
const;
231 void set_max_entry_size(
unsigned long size);
232 unsigned long get_max_entry_size()
const;
234 void set_default_expiration(
int exp_time);
235 int get_default_expiration()
const;
237 void set_always_validate(
bool validate);
238 bool get_always_validate()
const;
240 void set_cache_control(
const vector<string> &cc);
241 vector<string> get_cache_control();
244 DBG(cerr <<
"Locking interface... ");
245 LOCK(&d_cache_mutex);
246 DBGN(cerr <<
"Done" << endl);
249 DBG(cerr <<
"Unlocking interface... " );
251 DBGN(cerr <<
"Done" << endl);
255 bool cache_response(
const string &url, time_t request_time,
256 const vector<string> &headers,
const FILE *body);
257 void update_response(
const string &url, time_t request_time,
258 const vector<string> &headers);
263 bool is_url_valid(
const string &url);
266 vector<string> get_conditional_request_headers(
const string &url);
267 FILE *get_cached_response(
const string &url, vector<string> &headers,
269 FILE *get_cached_response(
const string &url, vector<string> &headers);
270 FILE *get_cached_response(
const string &url);
272 void release_cached_response(FILE *response);
279 #endif // _http_cache_h
A class for software fault reporting.
bool is_hop_by_hop_header(const string &header)
void unlock_cache_interface()
void lock_cache_interface()