# Lua location capture

**URL:** <https://www.ruby-forum.com/t/lua-location-capture/207180>\
**Category:** NGINX\
**Created:** [May 19, 2011, 11:59pm UTC](https://www.ruby-forum.com/t/lua-location-capture/207180 "2011-05-19T23:59:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 19, 2011, 11:59pm UTC](https://www.ruby-forum.com/t/lua-location-capture/207180/1 "2011-05-19T23:59:31Z")

</div>

Hi  
The lua doc at [https://github.com/chaoslawful/lua-nginx-module](https://github.com/chaoslawful/lua-nginx-module)  
Says “Note that, by default, subrequests issued by ngx.location.capture  
inherit all the request headers of the current request.”  
And goes on to say that it can be an unwanted feature  
In my project I actually take advantage of this feature, but for some  
reason the headers don’t go through to the sub request  
All I get is:

Uri:/checksize/100meg.zip  
Host : 127.0.0.1:12340  
Connection : close  
Content-Length : 0

It should have a TON of headers and I’ve proven they are there in the  
main request  
Any ideas why they don’t get through?

Thanks as always  
Richard

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [May 20, 2011, 5:56am UTC](https://www.ruby-forum.com/t/lua-location-capture/207180/2 "2011-05-20T05:56:56Z")

</div>

On Fri, May 20, 2011 at 5:59 AM, Richard K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the headers dont go through to the sub request

Could you please paste your nginx.conf here? Also, information about  
your nginx’s version and ngx\_lua’s version can also be helpful 🙂

Best,  
-agentzh

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [May 20, 2011, 1:33pm UTC](https://www.ruby-forum.com/t/lua-location-capture/207180/3 "2011-05-20T13:33:14Z")

</div>

Hi  
Thanks for the reply  
I traced the issue with the header’s not being re-sent

ngx.location.capture("/some-location", { method = ngx.HTTP\_HEAD })  
they are not re-sent

but  
ngx.location.capture("/some-location", { method = ngx.HTTP\_GET })  
they are sent

I don’t know if this is correct behavior (it may well be)  
I got around it by changing the headers I needed into args then  
re-creating them at /some-location ☹

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [May 23, 2011, 10:47am UTC](https://www.ruby-forum.com/t/lua-location-capture/207180/4 "2011-05-23T10:47:06Z")

</div>

On Fri, May 20, 2011 at 7:32 PM, Richard K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I got around it by changing the headers I needed into args then re-creating them  
> at /some-location ☹

This issue has been proven to be caused by two separate bugs. I’ve  
already fixed them in ngx\_lua’s master branch:

```
http://bit.ly/mU1Z29

```

Could you please try it out?

Best,  
-agentzh
