Header Questions

39 views
Skip to first unread message

Mathew Heard

unread,
Jun 14, 2015, 10:51:36 PM6/14/15
to openre...@googlegroups.com
Not entirely a Lua question, but I want to request it from Lua (if possible) so yeah :)

Is it possible to get either:
a) The original request headers in a raw form?
or
b) The original request headers in order?

From my understanding of the request parsing process I do not believe this is possible, but please correct me if I am wrong. Hopefully I am.

Mathew Heard

unread,
Jun 14, 2015, 11:08:26 PM6/14/15
to openre...@googlegroups.com
Just a re-write of the question for clarity:

a) Is r->headers_in ordered by the order received in the request? It does appear to be.
b) Lua Tables with keys are not insert order I hazard. Hence that explains what I am seeing.

Yichun Zhang (agentzh)

unread,
Jun 16, 2015, 2:32:20 AM6/16/15
to openresty-en
Hello!

On Mon, Jun 15, 2015 at 10:51 AM, Mathew Heard wrote:
> Not entirely a Lua question, but I want to request it from Lua (if possible)
> so yeah :)
>
> Is it possible to get either:
> a) The original request headers in a raw form?
> or
> b) The original request headers in order?
>

Yes, sure:

https://github.com/openresty/lua-nginx-module#ngxreqraw_header

If you are interested in how it is implemented, just check out the source ;)

Regards,
-agentzh

Mathew Heard

unread,
Jun 16, 2015, 5:37:54 AM6/16/15
to openre...@googlegroups.com
Thank you I was not aware of that method :)

Ideally I would have preferred just a format like:

{
{name="Host",value="domain.com"},
{..},
...
}

But I should be able to make that work.

Regards,
Mathew
Reply all
Reply to author
Forward
0 new messages