Skip to content

Commit

Permalink
add failing httpServerStreamingRequest test
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Apr 7, 2021
1 parent a78972b commit 0be87c8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cli/tests/unit/http_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,38 @@ unitTest(
},
);

unitTest(
{ perms: { net: true } },
async function httpServerStreamingRequest() {
const stream = new TransformStream();
const writer = stream.writable.getWriter();
writer.write(new TextEncoder().encode("hello "));
writer.write(new TextEncoder().encode("world"));
writer.close();

const promise = (async () => {
const listener = Deno.listen({ port: 4501 });
for await (const conn of listener) {
const requests = Deno.startHttp(conn);
for await (const { request, respondWith } of requests) {
const reqBody = await request.text();
assertEquals("hello world", reqBody);
await respondWith(new Response(""));
break;
}
break;
}
})();

const resp = await fetch("http://127.0.0.1:4501/", {
body: stream.readable,
method: "POST",
});
await resp.arrayBuffer();
await promise;
},
);

/*
unitTest({ perms: { net: true } }, async function httpServerStreaming() {
const promise = (async () => {
Expand Down

0 comments on commit 0be87c8

Please sign in to comment.