From: Thierry FOURNIER Date: Wed, 18 Mar 2015 12:43:10 +0000 (+0100) Subject: MINOR: lua: (req|res)_get_headers return more than one header value X-Git-Tag: v1.6-dev2~219 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04c57b3357b79c9eba2dee0e1c9de724ca286660;p=thirdparty%2Fhaproxy.git MINOR: lua: (req|res)_get_headers return more than one header value the functions (req|res)_get_headers() return only the last entry for each header with the same name. This patch fix this behavior. Each header name contain an array of values. --- diff --git a/src/hlua.c b/src/hlua.c index 0499ea3921..dc75473e2d 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2814,6 +2814,10 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str struct hdr_idx_elem *cur_hdr; const char *hn, *hv; int hnl, hvl; + int type; + const char *in; + char *out; + int len; /* Create the table. */ lua_newtable(L); @@ -2855,10 +2859,48 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str hv = p; hvl = cur_ptr+cur_hdr->len-p; - /* Push values in the table. */ - lua_pushlstring(L, hn, hnl); - lua_pushlstring(L, hv, hvl); - lua_settable(L, -3); + /* Lowercase the key. Don't check the size of trash, it have + * the size of one buffer and the input data contains in one + * buffer. + */ + out = trash.str; + for (in=hn; in