fix handling of request bodies

This commit is contained in:
ading2210 2024-03-20 18:38:13 -04:00
parent 3a50060e07
commit 5e9f26f818
6 changed files with 32 additions and 8 deletions

View file

@ -55,5 +55,8 @@ class JSTest(unittest.TestCase):
def test_http_session(self):
self.run_test("test_http_session.js")
def test_post(self):
self.run_test("test_post.js")
if __name__ == "__main__":
unittest.main()

View file

@ -0,0 +1,10 @@
async function test() {
let payload = "hello".repeat(100);
let r = await libcurl.fetch("https://httpbin.org/anything", {
method: "POST",
body: new Blob([payload], {type: "text/plain"})
});
assert(r.status === 200, "wrong status");
let json = await r.json();
assert(json.data === payload, "server reports wrong payload");
}