diff --git a/nyash.toml b/nyash.toml index f3bff312..aae4988d 100644 --- a/nyash.toml +++ b/nyash.toml @@ -65,9 +65,9 @@ type_id = 20 [libraries."libnyash_net_plugin.so".HttpServerBox.methods] birth = { method_id = 0 } -start = { method_id = 1, args = ["port"] } -stop = { method_id = 2 } -accept = { method_id = 3 } +start = { method_id = 1, args = ["port"], returns_result = true } +stop = { method_id = 2, returns_result = true } +accept = { method_id = 3, returns_result = true } fini = { method_id = 4294967295 } [libraries."libnyash_net_plugin.so".HttpRequestBox] diff --git a/tests/e2e_plugin_net.rs b/tests/e2e_plugin_net.rs index 8435d1b3..a3ebf0f2 100644 --- a/tests/e2e_plugin_net.rs +++ b/tests/e2e_plugin_net.rs @@ -32,7 +32,7 @@ srv.start(8080) cli = new HttpClientBox() r = cli.get("http://localhost:8080/hello") -req = srv.accept() +req = srv.accept().get_value() resp = new HttpResponseBox() resp.setStatus(200) resp.write("OK") @@ -62,7 +62,7 @@ srv.start(8081) cli = new HttpClientBox() r = cli.get("http://localhost:8081/test1") -req = srv.accept() +req = srv.accept().get_value() resp = new HttpResponseBox() resp.write("A") req.respond(resp) @@ -74,7 +74,7 @@ resp = r.get_value() _ = resp.readBody() # consume first response (optional) r = cli.get("http://localhost:8081/test2") -req = srv.accept() +req = srv.accept().get_value() resp = new HttpResponseBox() resp.write("B") req.respond(resp) @@ -103,7 +103,7 @@ srv = new HttpServerBox() srv.start(8082) cli = new HttpClientBox() r = cli.get("http://localhost:8082/first") -req = srv.accept() +req = srv.accept().get_value() resp = new HttpResponseBox() resp.write("X") req.respond(resp) @@ -123,7 +123,7 @@ srv = new HttpServerBox() srv.start(8083) cli = new HttpClientBox() r = cli.get("http://localhost:8083/second") -req = srv.accept() +req = srv.accept().get_value() resp = new HttpResponseBox() resp.write("Y") req.respond(resp) @@ -151,7 +151,7 @@ srv.start(8090) cli = new HttpClientBox() r = cli.post("http://localhost:8090/api", "DATA") -req = srv.accept() +req = srv.accept().get_value() // check server saw body body = req.readBody() // prepare response @@ -182,7 +182,7 @@ fn e2e_http_multiple_requests_order() { if !try_init_plugins() { return; } let code = r#" -local srv, cli, r1, r2, r3, q1, q2, q3 +local srv, cli, r1, r2, r3, req1, req2, req3, q1, q2, q3 srv = new HttpServerBox() srv.start(8091) @@ -191,9 +191,12 @@ r1 = cli.get("http://localhost:8091/a") r2 = cli.get("http://localhost:8091/b") r3 = cli.get("http://localhost:8091/c") -q1 = srv.accept().path() -q2 = srv.accept().path() -q3 = srv.accept().path() +req1 = srv.accept().get_value() +q1 = req1.path() +req2 = srv.accept().get_value() +q2 = req2.path() +req3 = srv.accept().get_value() +q3 = req3.path() q1 + "," + q2 + "," + q3 "#; diff --git a/tests/e2e_plugin_net_additional.rs b/tests/e2e_plugin_net_additional.rs index af0d54df..8686cad2 100644 --- a/tests/e2e_plugin_net_additional.rs +++ b/tests/e2e_plugin_net_additional.rs @@ -36,8 +36,8 @@ r1 = c.get("http://localhost:8101/a") r2 = c.get("http://localhost:8102/b") // accept once per pending request and keep handles -req1 = s1.accept() -req2 = s2.accept() +req1 = s1.accept().get_value() +req2 = s2.accept().get_value() p1 = req1.path() p2 = req2.path() @@ -78,7 +78,7 @@ s.start(8103) c = new HttpClientBox() r = c.post("http://localhost:8103/long", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") -q = s.accept() +q = s.accept().get_value() body = q.readBody() resp = new HttpResponseBox() resp.setStatus(202)