Lua template: Optimize code
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
1 parent
52f6309844
commit
2ab93c9680
1 file changed
+2
-3
+2
-3
@@ -626,11 +626,10 @@ void uh_template(struct uh_connection *con)
|
|||||||
|
|
||||||
for (i = 0; i < con->req.header_num; i ++) {
|
for (i = 0; i < con->req.header_num; i ++) {
|
||||||
struct uh_header *h = &con->req.header[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_pushlstring(L, h->value.at, h->value.len);
|
||||||
lua_setfield(L, -2, buf);
|
lua_settable(L, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_setfield(L, -2, "HEADERS");
|
lua_setfield(L, -2, "HEADERS");
|
||||||
|
|||||||
Reference in new issue
Block a user