How to make a streaming POST request on Firefox?

The Google Chrome browser has recently been updated, it has added the ability to send the request body in a stream. You can send data to an open POST request at the speed that you need.

How do I make a similar request on Firefox?

https://developer.chrome.com/articles/fetch-streaming-requests/

function wait(milliseconds) {
  return new Promise(resolve => setTimeout(resolve, milliseconds));
}

const stream = new ReadableStream({
  async start(controller) {
    await wait(1000);
    controller.enqueue('This ');
    await wait(1000);
    controller.enqueue('is ');
    await wait(1000);
    controller.enqueue('a ');
    await wait(1000);
    controller.enqueue('slow ');
    await wait(1000);
    controller.enqueue('request.');
    controller.close();
  },
}).pipeThrough(new TextEncoderStream());

fetch('/', {
  method: 'POST',
  headers: {'Content-Type': 'text/plain'},
  body: stream,
  duplex: 'half',
});

Thanks in advance to everyone who will answer.

Upvotes: 3

Views: 503

Answers (1)

Aine Luxia
Aine Luxia

Reputation: 11

Firefox currently doesn't support streaming requests

Upvotes: 1

Related Questions