Skip to content

Commit

Permalink
add check for node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 25, 2023
1 parent 5c5027e commit a6e8c65
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions test/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,25 @@ describe("", () => {
})
);

const stream = new ReadableStream({
start(controller) {
controller.enqueue("This ");
controller.enqueue("is ");
controller.enqueue("a ");
controller.enqueue("streamed ");
controller.enqueue("request.");
controller.close();
},
}).pipeThrough(new TextEncoderStream());
const isNode16 = process.version.startsWith("v16.");
const body = isNode16
? "This is a streamed request."
: new ReadableStream({
start(controller) {
controller.enqueue("This ");
controller.enqueue("is ");
controller.enqueue("a ");
controller.enqueue("streamed ");
controller.enqueue("request.");
controller.close();
},
}).pipeThrough(new TextEncoderStream());

const res = await fetch(url + "/", {
method: "POST",
// @ts-ignore
duplex: "half",
body: stream,
body,
headers: {
"content-type": "application/octet-stream",
"x-custom": "hello",
Expand Down

0 comments on commit a6e8c65

Please sign in to comment.