- From: nenge123 <notifications@github.com>
- Date: Tue, 19 Apr 2022 01:19:11 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 19 April 2022 08:19:23 UTC
if i use json() text() havesize !=headers['content-length']; ```javascrpt let response = await fetch(request),havesize=0; for (const [key, value] of response.headers.entries()) { headers[key] = value; } const reader = response.body.getReader(); const stream = new ReadableStream({ start(controller) { let push = e => { reader.read().then(({done,value}) => { if (done) { controller.close(); push = null; return; } havesize += value.length; let statussize = '0%'; if(headers['content-length'])statussize = Math.floor(havesize / Number(headers['content-cength']) * 100) + '%'; controller.enqueue(value); push(); }); } push(); } }); ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/1425 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/1425@github.com>
Received on Tuesday, 19 April 2022 08:19:23 UTC