Stop using cv2pdb and improve HTTP handling a little
This commit is contained in:
@@ -457,13 +457,6 @@ HttpServerResponse World::http_serve(const HttpParser &request) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// Get the name of the desired function.
|
||||
std::string_view fn = request.first_path_component("index");
|
||||
if (!sv::is_lua_id(fn)) {
|
||||
response.fail(404, util::ss("not a function name: ", fn));
|
||||
return response;
|
||||
}
|
||||
|
||||
lua_State *L = state();
|
||||
LuaVar www, func, reqtab;
|
||||
LuaExtStack LS(L, www, func, reqtab);
|
||||
@@ -476,11 +469,19 @@ HttpServerResponse World::http_serve(const HttpParser &request) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// Get the name of the desired function.
|
||||
std::string_view orig_fn = request.first_path_component("index");
|
||||
eng::string lua_fn = HttpParser::to_lua_identifier(orig_fn);
|
||||
if (lua_fn.empty()) {
|
||||
response.fail(404, util::ss("cannot convert to lua function name: ", orig_fn));
|
||||
return response;
|
||||
}
|
||||
|
||||
// Get the closure. If there's no such closure,
|
||||
// return a 404 Not Found to the client.
|
||||
LS.rawget(func, www, fn);
|
||||
LS.rawget(func, www, lua_fn);
|
||||
if (!LS.isfunction(func)) {
|
||||
response.fail(404, util::ss("no such function: www.", fn));
|
||||
response.fail(404, util::ss("no such lua function: www.", lua_fn));
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -507,7 +508,7 @@ HttpServerResponse World::http_serve(const HttpParser &request) {
|
||||
// a 500 Internal Server Error to the client.
|
||||
int newtop = lua_gettop(L);
|
||||
if ((newtop != oldtop + 1) || (!lua_istable(L, newtop))) {
|
||||
response.fail(500, util::ss("lua function www.", fn, " didn't return a table"));
|
||||
response.fail(500, util::ss("lua function www.", lua_fn, " didn't return a table"));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user