Created
March 28, 2013 19:19
-
-
Save mtourne/5266024 to your computer and use it in GitHub Desktop.
Nginx clearing all headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* clear all the headers */ | |
ngx_memzero(&r->headers_in, sizeof (ngx_http_headers_in)); | |
/* reinitialize headers */ | |
r->headers_in.content_length_n = -1; | |
r->headers_in.keep_alive_n = -1; | |
/* TODO (mtourne): init to the size of the table passed in param */ | |
if (ngx_list_init(&r->headers_in.headers, r->pool, 20, | |
sizeof(ngx_table_elt_t)) | |
!= NGX_OK) { | |
return luaL_error(L, "out of memory"); | |
} | |
if (ngx_array_init(&r->headers_in.cookies, r->pool, 2, | |
sizeof(ngx_table_elt_t *)) | |
!= NGX_OK) { | |
return luaL_error(L, "out of memory"); | |
} | |
#if 0 | |
part = &r->headers_in.headers.part; | |
while (part != NULL) { | |
part->nelts = 0; | |
part = part->next; | |
} | |
/* clear cookies */ | |
r->headers_in.cookies.nelts = 0; | |
/* clear all the "fixed" headers */ | |
start = &r->headers_in.host; | |
stop = (ngx_table_elt_t **) &r->headers_in.user; | |
for (p = start; p < stop; p++) { | |
h = *p; | |
if (h == NULL) { | |
continue; | |
} | |
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
"[lua-cf] clearing builtin header: \"%V\"", | |
&h->key); | |
h->hash = 0; | |
h->value = null_string; | |
} | |
r->headers_in.server = null_string; | |
r->headers_in.content_length_n = -1; | |
r->headers_in.chunked = 0; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment