check if cache enabled
This commit is contained in:
		
							parent
							
								
									a00d33f2bd
								
							
						
					
					
						commit
						7e2f9c6458
					
				| 
						 | 
				
			
			@ -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);   
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue