# Deleting Request-Headers

**URL:** <https://www.ruby-forum.com/t/deleting-request-headers/205604>\
**Category:** NGINX\
**Created:** [April 10, 2011, 12:44pm UTC](https://www.ruby-forum.com/t/deleting-request-headers/205604 "2011-04-10T12:44:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 10, 2011, 12:44pm UTC](https://www.ruby-forum.com/t/deleting-request-headers/205604/1 "2011-04-10T12:44:17Z")

</div>

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:

> **[Deleting Request-Headers](https://forum.nginx.org/read.php?2,189846,189846#msg-189846)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![andiL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/50afbb/32.png) [@andiL](https://www.ruby-forum.com/u/andiL)\
**Post date:** [April 18, 2011, 7:06am UTC](https://www.ruby-forum.com/t/deleting-request-headers/205604/2 "2011-04-18T07:06:53Z")

</div>

On Sun, Apr 10, 2011 at 6:43 PM, andiL [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 ☹

Cheers,  
-agentzh
