# Empty headers\_out in log phase

**URL:** <https://www.ruby-forum.com/t/empty-headers-out-in-log-phase/218868>\
**Category:** NGINX\
**Created:** [April 13, 2012, 9:58pm UTC](https://www.ruby-forum.com/t/empty-headers-out-in-log-phase/218868 "2012-04-13T21:58:59Z")\
**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 13, 2012, 9:58pm UTC](https://www.ruby-forum.com/t/empty-headers-out-in-log-phase/218868/1 "2012-04-13T21:58:59Z")

</div>

Hello,

I’m writing an nginx module but I’ve got a problem for getting  
response headers. It’s using an NGX\_HTTP\_LOG\_PHASE handler and I want  
to have access to response headers sent to client. (with or without  
proxy\_pass)

And, in fact, the headers\_out variable of request isn’t really  
completed. When debugging module using gdb, in the log phase handler,  
the headers\_out variable is always like that:

headers\_out = {  
headers = {  
last = 0x1ed5530,  
part = {  
elts = 0x1ec6250,  
nelts = 1,  
next = 0x0  
},  
size = 48,  
nalloc = 20,  
pool = 0x1ec6200  
},  
status = 304,  
status\_line = {  
len = 0,  
data = 0x0  
},  
server = 0x0,  
date = 0x0,  
content\_length = 0x0,  
content\_encoding = 0x0,  
location = 0x0,  
refresh = 0x0,  
last\_modified = 0x0,  
content\_range = 0x0,  
accept\_ranges = 0x0,  
www\_authenticate = 0x0,  
expires = 0x0,  
etag = 0x0,  
override\_charset = 0x0,  
content\_type\_len = 9,  
content\_type = {  
len = 0,  
data = 0x1ed1248 “text/html”  
},  
charset = {  
len = 0,  
data = 0x0  
},  
content\_type\_lowcase = 0x0,  
content\_type\_hash = 0,  
cache\_control = {  
elts = 0x0,  
nelts = 0,  
size = 0,  
nalloc = 0,  
pool = 0x0  
},  
content\_length\_n = -1,  
date\_time = 0,  
last\_modified\_time = 1334219772  
},

The headers\_out array is containing the only request that I added  
using “add\_header” in location, and the “server”, “date”, etc…  
variables are empty.

Do you know why there isn’t any value in headers\_out structure? And do  
you know how can I get these headers?

Thanks you very much in advance!  
Samuel.

---

<div class="post-metadata">

**Author:** ![Samuel\_ROZE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Samuel\_ROZE](https://www.ruby-forum.com/u/Samuel_ROZE)\
**Post date:** [April 14, 2012, 4:07pm UTC](https://www.ruby-forum.com/t/empty-headers-out-in-log-phase/218868/2 "2012-04-14T16:07:42Z")

</div>

Hello!

On Fri, Apr 13, 2012 at 09:58:14PM +0200, Samuel ROZE wrote:

> ```
> pool = 0x1ec6200
> location = 0x0,
> len = 0,
> nelts = 0,
> 
> ```
> 
> using “add\_header” in location, and the “server”, “date”, etc…  
> variables are empty.
> 
> Do you know why there isn’t any value in headers\_out structure? And do  
> you know how can I get these headers?

The “Server”, “Date”, “Content-Length”, “Last-Modified” and other  
standard headers aren’t normally exists in r-\>headers\_out for  
nginx’s own responses, they are instead constructed on the fly in  
ngx\_http\_header\_filter.c.

The r-\>headers\_out structure either hold needed data (as  
last\_modified\_time for the “Last-Modified” header) or just nothing  
(as for the “Date” header, as it just uses current time).

Maxim D.
