From 031ee5c339bbf24a8915fd12f84fa5aa18707cad Mon Sep 17 00:00:00 2001 From: Bernard Aboba Date: Fri, 5 Nov 2021 12:40:56 -0700 Subject: [PATCH 1/2] Fix pipeThrough error and track API changes --- webtransport/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webtransport/client.js b/webtransport/client.js index 50c4729698..43fd5c5a12 100644 --- a/webtransport/client.js +++ b/webtransport/client.js @@ -69,7 +69,7 @@ async function sendData() { case 'bidi': { let stream = await transport.createBidirectionalStream(); let number = streamNumber++; - readFromIncomingStream(stream, number); + readFromIncomingStream(stream.readable, number); let writer = stream.writable.getWriter(); await writer.write(data); @@ -129,9 +129,9 @@ async function acceptUnidirectionalStreams(transport) { } } -async function readFromIncomingStream(stream, number) { +async function readFromIncomingStream(readable, number) { let decoder = new TextDecoderStream('utf-8'); - let reader = stream.pipeThrough(decoder).getReader(); + let reader = readable.getReader(); try { while (true) { const { value, done } = await reader.read(); @@ -139,7 +139,7 @@ async function readFromIncomingStream(stream, number) { addToEventLog('Stream #' + number + ' closed'); return; } - let data = value; + let data = decoder.decode(value); addToEventLog('Received data on stream #' + number + ': ' + data); } } catch (e) { From 7de9d938204f0b53f68edbb31ff971404a450aa0 Mon Sep 17 00:00:00 2001 From: Bernard Aboba Date: Thu, 11 Nov 2021 05:30:57 -0500 Subject: [PATCH 2/2] Use TextDecoderStream() --- webtransport/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webtransport/client.js b/webtransport/client.js index 43fd5c5a12..25669fa899 100644 --- a/webtransport/client.js +++ b/webtransport/client.js @@ -131,7 +131,7 @@ async function acceptUnidirectionalStreams(transport) { async function readFromIncomingStream(readable, number) { let decoder = new TextDecoderStream('utf-8'); - let reader = readable.getReader(); + let reader = readable.pipeThrough(decoder).getReader(); try { while (true) { const { value, done } = await reader.read(); @@ -139,7 +139,7 @@ async function readFromIncomingStream(readable, number) { addToEventLog('Stream #' + number + ' closed'); return; } - let data = decoder.decode(value); + let data = value; addToEventLog('Received data on stream #' + number + ': ' + data); } } catch (e) {