Deleting Request-Headers

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 :frowning: - 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

On Sun, Apr 10, 2011 at 6:43 PM, andiL [email protected] wrote:

Hi,
i’m trying to extend the lua-module with some features… currently i’m
still bugging around with the Request/Response Headers…

See how ngx_headers_more is doing:

http://github.com/agentzh/headers-more-nginx-module

I’ve been trying to migrate everything there over to ngx_lua but sadly
I’ve been sucking from some illness recently :frowning:

Cheers,
-agentzh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs