check if cache enabled

This commit is contained in:
hladu357 2024-06-04 15:17:08 +02:00
parent a00d33f2bd
commit 7e2f9c6458
1 changed files with 7 additions and 3 deletions

View File

@ -104,9 +104,10 @@ ngx_module_t ngx_http_key_header_module =
static ngx_int_t
ngx_http_key_header_filter(ngx_http_request_t *r )
{
if(r->loc_conf != NULL) {
if(r->loc_conf ) {
ngx_http_key_header_loc_conf_t *conf = ngx_http_get_module_loc_conf(r, ngx_http_key_header_module);
if(conf->enabled) {
// enabled cahce enabled
if(conf->enabled && r->cache) {
ngx_table_elt_t *h;
h = ngx_list_push(&r->headers_out.headers);
if(h == NULL) {
@ -114,11 +115,14 @@ ngx_http_key_header_filter(ngx_http_request_t *r )
}
u_char hexKey[2 * NGX_HTTP_CACHE_KEY_LEN + 1];
memset(hexKey, 0, sizeof(hexKey));
ngx_hex_dump(hexKey, r->cache->key, NGX_HTTP_CACHE_KEY_LEN);
h->hash = 1;
h->next = NULL;
ngx_str_set(&h->key, "X-Cache-Key");
ngx_str_set(&h->value, hexKey);
ngx_str_set(&h->value, "abcd");
}
}
return ngx_http_next_header_filter(r);