Empty headers_out in log phase

Samuel ROZE samuel.roze at gmail.com
Fri Apr 13 19:58:14 UTC 2012


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.



More information about the nginx mailing list