Lua template: Optimize code

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
main
Jianhui Zhao 2017-12-05 23:26:36 +08:00
parent 52f6309844
commit 2ab93c9680
1 changed files with 2 additions and 3 deletions

View File

@ -626,11 +626,10 @@ void uh_template(struct uh_connection *con)
for (i = 0; i < con->req.header_num; i ++) {
struct uh_header *h = &con->req.header[i];
char buf[128] = "";
snprintf(buf, sizeof(buf), "%.*s", (int)h->field.len, h->field.at);
lua_pushlstring(L, h->field.at, h->field.len);
lua_pushlstring(L, h->value.at, h->value.len);
lua_setfield(L, -2, buf);
lua_settable(L, -3);
}
lua_setfield(L, -2, "HEADERS");