File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,44 @@ ALWAYS_INLINE struct lwan_request *lwan_lua_get_request_from_userdata(lua_State
44
44
return * r ;
45
45
}
46
46
47
+ LWAN_LUA_METHOD (http_version )
48
+ {
49
+ if (request -> flags & REQUEST_IS_HTTP_1_0 )
50
+ lua_pushstring (L , "HTTP/1.0" );
51
+ else
52
+ lua_pushstring (L , "HTTP/1.1" );
53
+ return 1 ;
54
+ }
55
+
56
+ LWAN_LUA_METHOD (http_method )
57
+ {
58
+ lua_pushstring (L , lwan_request_get_method_str (request ));
59
+ return 1 ;
60
+ }
61
+
62
+ LWAN_LUA_METHOD (http_headers )
63
+ {
64
+ const struct lwan_request_parser_helper * helper = request -> helper ;
65
+
66
+ lua_newtable (L );
67
+
68
+ for (size_t i = 0 ; i < helper -> n_header_start ; i ++ ) {
69
+ const char * key = helper -> header_start [i ];
70
+ const char * key_end = strchr (key , ':' );
71
+
72
+ if (!key_end )
73
+ break ;
74
+
75
+ const char * value = key_end + 2 ;
76
+
77
+ lua_pushlstring (L , key , (size_t )(key_end - key ));
78
+ lua_pushstring (L , value );
79
+ lua_rawset (L , -3 );
80
+ }
81
+
82
+ return 1 ;
83
+ }
84
+
47
85
LWAN_LUA_METHOD (say )
48
86
{
49
87
size_t response_str_len ;
You can’t perform that action at this time.
0 commit comments