4 * Created on: 15/03/2009
8 #ifndef MOD_CRCCACHE_CLIENT_H
9 #define MOD_CRCCACHE_CLIENT_H
11 #include "cache/cache.h"
13 #include <openssl/evp.h>
14 #include <ap_config.h>
15 #include <http_config.h>
16 #include <apr-1.0/apr_optional.h>
18 extern module AP_MODULE_DECLARE_DATA crccache_client_module
;
20 const char* cache_create_key( request_rec
*r
);
22 APR_DECLARE_OPTIONAL_FN(apr_status_t
,
23 ap_cache_generate_key
,
24 (request_rec
*r
, apr_pool_t
*p
, char**key
));
26 extern APR_OPTIONAL_FN_TYPE(ap_cache_generate_key
) *cache_generate_key
;
28 /* Forward declarations */
29 int remove_entity(cache_handle_t
*h
);
30 apr_status_t
store_headers(cache_handle_t
*h
, request_rec
*r
,
32 apr_status_t
store_body(cache_handle_t
*h
, request_rec
*r
,
33 apr_bucket_brigade
*b
);
34 apr_status_t
recall_headers(cache_handle_t
*h
, request_rec
*r
);
35 apr_status_t
recall_body(cache_handle_t
*h
, apr_pool_t
*p
,
36 apr_bucket_brigade
*bb
);
37 apr_status_t
read_array(request_rec
*r
, apr_array_header_t
* arr
,
40 int remove_url(cache_handle_t
*h
, apr_pool_t
*p
);
41 int create_entity(cache_handle_t
*h
, request_rec
*r
, const char *key
, apr_off_t len
);
42 int open_entity(cache_handle_t
*h
, request_rec
*r
, const char *key
);
45 #define FULL_BLOCK_COUNT 40
47 typedef enum decoding_state
{
50 DECODING_LITERAL_BODY
,
51 DECODING_LITERAL_SIZE
,
53 DECODING_BLOCK_HEADER
,
58 DECOMPRESSION_INITIALIZED
,
60 } decompression_state_t
;
62 typedef struct crccache_client_ctx_t
{
63 apr_bucket_brigade
*bb
;
65 size_t tail_block_size
;
66 apr_bucket
* cached_bucket
;// original data so we can fill in the matched blocks
69 decompression_state_t decompression_state
;
70 z_stream
*decompression_stream
;
73 unsigned char md_value_calc
[EVP_MAX_MD_SIZE
];
74 unsigned char md_value_rx
[EVP_MAX_MD_SIZE
];
76 unsigned literal_size
;
77 unsigned char * partial_literal
;// original data so we can fill in the matched blocks
78 } crccache_client_ctx
;
86 struct cache_disable
{
91 /* static information about the local cache */
94 apr_array_header_t
*cacheenable
; /* URLs to cache */
95 apr_array_header_t
*cachedisable
; /* URLs not to cache */
96 /* Maximum time to keep cached files in msecs */
99 /* default time to keep cached file in msecs */
102 /* factor for estimating expires date */
105 /** ignore the last-modified header when deciding to cache this request */
106 int no_last_mod_ignore_set
;
107 int no_last_mod_ignore
;
108 /** ignore client's requests for uncached responses */
109 int ignorecachecontrol
;
110 int ignorecachecontrol_set
;
111 /** ignore Cache-Control: private header from server */
113 int store_private_set
;
114 /** ignore Cache-Control: no-store header from client or server */
116 int store_nostore_set
;
117 /** store the headers that should not be stored in the cache */
118 apr_array_header_t
*ignore_headers
;
119 /* flag if CacheIgnoreHeader has been set */
120 #define CACHE_IGNORE_HEADERS_SET 1
121 #define CACHE_IGNORE_HEADERS_UNSET 0
122 int ignore_headers_set
;
123 /* Minimum time to keep cached files in msecs */
126 /** ignore query-string when caching */
127 int ignorequerystring
;
128 int ignorequerystring_set
;
130 // from mod diskcache
131 const char* cache_root
;
132 apr_size_t cache_root_len
;
133 int dirlevels
; /* Number of levels of subdirectories */
134 int dirlength
; /* Length of subdirectory names */
135 apr_off_t minfs
; /* minimum file size for cached files */
136 apr_off_t maxfs
; /* maximum file size for cached files */
137 } crccache_client_conf
;
139 #endif /*MOD_CRCCACHE_CLIENT_H*/