# Can I modify headers\_out's "location" in body filter?

**URL:** <https://www.ruby-forum.com/t/can-i-modify-headers-outs-location-in-body-filter/190255>\
**Category:** NGINX\
**Created:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/can-i-modify-headers-outs-location-in-body-filter/190255 "2010-06-17T16:22:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b9e5f3/32.png) [@ckong](https://www.ruby-forum.com/u/ckong)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/can-i-modify-headers-outs-location-in-body-filter/190255/1 "2010-06-17T16:22:31Z")

</div>

Hi all,  
I’m a newbie in nginx module development. I’ve a question here, need  
your help.  
I’m trying to develop a filter, which works with memcached, is used for  
request routing.  
for example, the conf here:

```auto
location /test {
            my_rr on;
            set $memcached_key $arg_key;
            memcached_pass 127.0.0.1:11211;
            default_type text/html;
}
```

ps: my\_rr enables my filter.  
In my filter module, I’ve modify headers\_out.status = 302 in my header  
filter, and I want to modify “Location” in my body filter, because the  
value of “Location” depends on the response of memcached.

I do modify headers\_out.location in my body filter, but it doesn’s work.

Could anybody tell me if I miss something?

Great thanks!

Posted at Nginx Forum:

> **[Can I modify headers\_out's "location" in body filter?](https://forum.nginx.org/read.php?2,99290,99290#msg-99290)**
>
> Hi all, I'm a newbie in nginx module development. I've a question here, need your help. I'm trying to develop a filter, which works with memcached, is used for request routing. for example, the conf here: \[code\] location /test { my\_rr on;

---

<div class="post-metadata">

**Author:** ![ckong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b9e5f3/32.png) [@ckong](https://www.ruby-forum.com/u/ckong)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/can-i-modify-headers-outs-location-in-body-filter/190255/2 "2010-06-17T16:22:37Z")

</div>

ckong at 2010-6-17 16:27 wrote:

> ```
> memcached_pass 127.0.0.1:11211;
> 
> ```

Noï¼Œyour modification is useless. Nginx sends the headers first, even  
before receiving all the response body from backends.

> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![ckong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b9e5f3/32.png) [@ckong](https://www.ruby-forum.com/u/ckong)\
**Post date:** [June 17, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/can-i-modify-headers-outs-location-in-body-filter/190255/3 "2010-06-17T16:26:21Z")

</div>

Thanks, Yao.  
Is there a way to postpone the header’s sending?  
btw: So content-lenght should be known before Nginx invokes the body  
filter, right?

Posted at Nginx Forum:

> **[Re: Can I modify headers\_out's "location" in body filter?](https://forum.nginx.org/read.php?2,99290,99305#msg-99305)**
>
> Hi all, I'm a newbie in nginx module development. I've a question here, need your help. I'm trying to develop a filter, which works with memcached, is used for request routing. for example, the conf here: \[code\] location /test { my\_rr on;
