Deleting Request-Headers
andiL
nginx-forum at nginx.us
Sun Apr 10 14:43:37 MSD 2011
Hi,
i'm trying to extend the lua-module with some features... currently i'm
still bugging around with the Request/Response Headers...
With older nginx-versions (0.7.x) you were able to completeley remove
Request-Headers for cgi-scripts when the "hash"-value of the header was
set to zero.
Sadly this method is not working with the current stable (0.8.54)
anymore :( - As a workaround i name the Key and Value of the header
"deleted" for now.
Is there something i can use to completely remove the header?
Here's the sample-code i use:
int
ngx_http_lua_req_header_rm(lua_State *L)
{
ngx_http_request_t *r;
ngx_str_t temp_key;
ngx_str_t del_text;
ngx_list_part_t *header_part;
lua_getglobal(L, GLOBALS_SYMBOL_REQUEST);
r = lua_touserdata(L, -1);
lua_pop(L, 1);
temp_key.data = (u_char*) luaL_checkstring(L,1);
temp_key.len = strlen(luaL_checkstring(L,1));
del_text.data = (u_char*) "deleted";
del_text.len = strlen("deleted");
for(header_part = &(r->headers_in.headers.part) ; header_part ;
header_part = header_part->next)
{
unsigned int i;
ngx_table_elt_t *header = header_part->elts;
for(i = 0; i < header_part->nelts; ++i)
{
if( aod_strcmp(header[i].key, temp_key) == 0 )
{
header[i].hash = 0;
header[i].key = del_text;
header[i].value = del_text;
}
}
}
return 0;
}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,189846,189846#msg-189846
More information about the nginx
mailing list