HTTP stuff now uses keyword parser.

This commit is contained in:
2022-07-22 17:07:40 -04:00
parent 28ec61e47c
commit a5ef765524
6 changed files with 135 additions and 101 deletions

View File

@@ -64,7 +64,7 @@ LuaDefine(tangible_animate, "tan,configtable",
int64_t id = w->alloc_id_predictable();
AnimStep step;
step.configure(kp, tan->anim_queue_.back());
kp.check_unparsed_keywords();
kp.final_check_throw();
if (step.action() == "") {
luaL_error(L, "animation action must be specified");
}
@@ -152,7 +152,7 @@ LuaDefine(tangible_build, "config",
// Parse the initial animation step.
AnimStep initstep, blank;
initstep.configure(kp, blank);
kp.check_unparsed_keywords();
kp.final_check_throw();
if (!initstep.has_xyz()) {
luaL_error(L, "You must specify (X,Y,Z) for new tangible");
}
@@ -368,7 +368,7 @@ LuaDefine(tangible_find, "config",
LuaKeywordParser kw(LS, config);
PlaneScan scan;
scan.configure(kw);
kw.check_unparsed_keywords();
kw.final_check_throw();
// When the configure routine sees the 'near' flag, it stores the tangible
// ID, but not the center and plane, because doing so would require it to
@@ -761,12 +761,14 @@ int lfn_http_request(lua_State *L, const char *method) {
LuaArg request;
LuaRet response;
LuaStack LS(L, request, response);
LuaKeywordParser kp(LS, request);
HttpClientRequest req;
// Parse the request and make sure it's valid.
// If not, immediately pass a '400 bad request' back to lua.
req.set_method(method);
req.set_config(LS, request);
req.configure(kp);
kp.final_check_throw();
req.set_defaults();
eng::string error = req.check();
if (!error.empty()) {