# Re: List of all request headers in perl?

**URL:** <https://www.ruby-forum.com/t/re-list-of-all-request-headers-in-perl/229252>\
**Category:** NGINX\
**Created:** [December 18, 2012, 4:49am UTC](https://www.ruby-forum.com/t/re-list-of-all-request-headers-in-perl/229252 "2012-12-18T04:49:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESWestbrook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@ESWestbrook](https://www.ruby-forum.com/u/ESWestbrook)\
**Post date:** [December 18, 2012, 4:49am UTC](https://www.ruby-forum.com/t/re-list-of-all-request-headers-in-perl/229252/1 "2012-12-18T04:49:18Z")

</div>

I’m very confused… there’s not an “$r” to be seen at that link.  
Perhaps I asked the original question poorly, or in the wrong place?

Thanks again,  
Eric

On Mon, Dec 17, 2012 at 7:38 PM, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

```
This may help:

View HTTP Request and Response Header

```

On Mon, Dec 17, 2012 at 5:29 PM, E. Westbrook [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

```
Hi!

I'm new to the list; so please accept my apologies and do kindly
correct me if I've missed something in my research, or if I'm not
complying with any particular social custom or etiquette on this 

```

list.

```
I'm using nginx's integrated perl support, and all is going well so
far, but I'm missing one critical thing right now: a way to get a
list of all of the request headers.

I can certainly use $r->header_in() to obtain any given specific
header, which works well if I know the header in advance -- but in
my case I need to iterate all of the incoming request headers, even
(especially, actually) headers whose presence I would not have
anticipated.

I do see some references to Nginx modules on CPAN, and in at least
one of those, a $r->headers_in() method... but those modules are
not the same animal as the built-in "nginx" module, are they.

Please help!

Thanks,
Eric

```

---

<div class="post-metadata">

**Author:** ![ESWestbrook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@ESWestbrook](https://www.ruby-forum.com/u/ESWestbrook)\
**Post date:** [December 18, 2012, 3:12pm UTC](https://www.ruby-forum.com/t/re-list-of-all-request-headers-in-perl/229252/2 "2012-12-18T15:12:03Z")

</div>

You’re right the Nginx modules on CPAN are not related. Sorry I don’t  
have  
a setup in front of me but isn’t $r-\>args some data structure that may  
contain the request headers? Can you iterate thru it or incorporate  
Data::Dumper to see what it contains? Check the source code of the  
embedded  
perl module to see what is implemented?

---

<div class="post-metadata">

**Author:** ![ESWestbrook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4af34b/32.png) [@ESWestbrook](https://www.ruby-forum.com/u/ESWestbrook)\
**Post date:** [December 18, 2012, 6:03pm UTC](https://www.ruby-forum.com/t/re-list-of-all-request-headers-in-perl/229252/3 "2012-12-18T18:03:48Z")

</div>

Thanks for the thought! Unfortunately, I don’t think that helps.

The $r-args() function seems to only return data from the GET-style  
query parameters (if any).

As for the source module (at least, the nginx.pm file), it seems to be  
just constants, declarations, definitions and such, but no actual code.  
I presume it’s all in some kind of XS stuff, which I’m sure could be  
further dissected if needed. I suppose I might end up going that way if  
all else fails, in hopes it might reveal some clever API usage that  
would work.

But that feels more to me like an effort would seem to be heading in the  
direction of developing a patch – which might be great (for someone  
other than me, too) – but it also might represent a level of  
development and maintenance effort far greater than simply switching to  
a different (and lesser in some ways) implementation.

Indeed, I’m hoping someone just knows of a way using the perl API just  
as it is, maybe just not thoroughly documented or easy to find. After  
all, I’m just trying to list the request’s headers! Isn’t that a pretty  
basic operation?

Thanks again,  
Eric

On Tue, Dec 18, 2012 at 7:11 AM, Harold Sinclair  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

```
You're right the Nginx modules on CPAN are not related. Sorry I
don't have a setup in front of me but isn't $r->args some data
structure that may contain the request headers? Can you iterate thru
it or incorporate Data::Dumper to see what it contains? Check the
source code of the embedded perl module to see what is implemented?

```
