[meta] Support ReadableStream as Request.body in fetch API
Categories
(Core :: DOM: Networking, enhancement, P2)
Tracking
()
People
(Reporter: bkelly, Unassigned)
References
(Depends on 2 open bugs, Blocks 2 open bugs)
Details
(4 keywords, Whiteboard: [necko-triaged] webcompat:risk-high)
Attachments
(1 obsolete file)
Updated•8 years ago
|
Updated•7 years ago
|
Reporter | ||
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Comment 5•6 years ago
|
||
At the moment passing ReadableStream
as body to a fetch
or a Request
constructor produces request that has body that is just body.toStrin()
:
const encoder = new TextEncoder()
const request = new Request('about:blank', {
method: "PUT",
body: new ReadableStream({
pull(c) {
c.enqueue(encoder.encode("hello"))
c.close()
}
})
})
await request.text() // -> "[object ReadableStream]"
I think we should at least error until support for body has landed, especially given that Response
accepts ReadableStream
just fine.
const encoder = new TextEncoder()
const response = new Response(new ReadableStream({
pull(c) {
c.enqueue(encoder.encode("hello"))
c.close()
}
}))
await response.text() // -> "hello"
Comment 6•6 years ago
|
||
Migrating Webcompat whiteboard priorities to project flags. See bug 1547409.
Comment 7•6 years ago
|
||
See bug 1547409. Migrating whiteboard priority tags to program flags.
Updated•6 years ago
|
Are there any plans to implement this in FF? whatwg seems to be considering removing it from the standard as no browser is implementing it.
I think this would be a huge loss for the web, as even things like firefox send need to resort to hacks like uploading large files via websockets.
Hi,
Chrome 85 includes this feature.
Here are links.
- Chrome Platform Status: fetch() upload streaming
- web.dev: Streaming requests with the fetch API
- Chromium Blog:
Chrome 85: Upload Streaming, Human Interface Devices, Custom Properties with Inheritance and More
Comment 10•3 years ago
•
|
||
It seems Chrome people now think this may not be so useful.
Comment 11•2 years ago
|
||
I read through the (now closed) issue on github and it seems that they'll keep the feature, as many people found it very useful (me included). I did give it a try in Chrome 105 and found it to be working pretty well - with the limitations that the web server needs to run on HTTP2, HTTPS must be used, and only the "half-duplex" mode is supported. But even so, it's very useful and I would really love to see this in Firefox as well.
As many people can't imagine why this would be worth the effort, let me give you an example: I am currently working on a end-to-end encryption of files, completely done in the browser. You can imagine why loading the entire file into memory, encrypting it there and then sending it to a server in one piece isn't feasible - for anything but small image files, that is. I managed to come up with a relatively simple proof-of-concept that encrypts any file on the client side and sends this with a single fetch (POST) to a Kestrel server - and later downloads and decrypts the same file again. It works perfectly in Chrome (both on desktop and smartphone) but not on Firefox, which is a shame. As the whole idea behind this project is privacy, I wouldn't want to depend on Chrome for using it.
tl;dr: Please bring this to Firefox - even with limitations (like half-duplex HTTPS 2 only), it's pretty useful.
Updated•2 years ago
|
Updated•2 years ago
|
Comment hidden (advocacy) |
Updated•1 year ago
|
Comment hidden (advocacy) |
Comment 15•10 months ago
|
||
Fetch API thing probably fits better in DOM: Networking.
Comment 16•10 months ago
|
||
Note: potential webcompat issue
Updated•10 months ago
|
Updated•10 months ago
|
Comment 18•8 months ago
|
||
Hi, I'm currently working on something that would benefit from this and would like to eventually submit a patch. Any reason I shouldn't start work on this?
Comment 19•7 months ago
|
||
Patches are very welcome.
Comment 20•7 months ago
|
||
I think Necko team wants to write a patch very soon, so it might be better to talk with :smayya first.
Updated•3 months ago
|
Comment 21•1 month ago
|
||
Hi! Any news on this?
Comment 22•1 month ago
|
||
Hi! I've been talking to Luc Fauvel about a solution. I wonder if I could get assigned to this issue. If he's alright with it. Thanks!
Comment 23•14 days ago
|
||
Hello Mauro B,
Thank you so much for your interest in contributing to Firefox! 🎉
Apologies for the delay in responding.
We’d love to see patches for this, as it's not something we have planned to work on anytime soon.
It would be great to hear how you plan to approach the implementation, and we’re happy to support you in any way we can.
Let us know if you'd like to discuss this over a Zoom call—we’d be more than happy to chat!
you can reach out to us via matrix at #necko:mozilla.org as well.
Looking forward to hear back from you!
Description
•