3 ms·
I want response from Firefox/Servo devs. They need async http requests and they have experience in using those.
by slezyr 9y ago
I want response from Firefox/Servo devs. They need async http requests and they have experience in using those.
- kibwen 9y agoI don't believe that Firefox's http code is using Rust at all, and Servo's http code is notoriously neglected due to prioritizing development on the layout engine and style engine. At the moment I expect they're in the same boat as ekidd, waiting for the async/await experiments to yield fruit.
- slezyr 9y ago> Servo's http code is notoriously neglected due to prioritizing development Is it? It's freaking hard to make http code in rust at all. I just checked it's source and they use some old hyper's methods inside, which aren't available in recent versions. So you can use it only with tokio. Tokio is nightmare who those, who tries to learn rust. And I can't find a way around it. > At the moment I expect they're in the same boat as ekidd, waiting for the async/await experiments to yield fruit. I think that almost all rust users/devs there right now.
- tomjakubowski 9y agoIf you just want to do an occasional one-off async http request, then tokio is probably overkill, at least until async/await end up in the language. The simple way is: spawn a background thread, make a channel, pass the write end to the background thread, issue the http request synchronously using whatever crate you want on the background thread, write the result back over the channel, and exit the background thread. In the main thread, poll the read end of that channel from your event loop. Rust decided not to ship with a scheduler/runtime built in like Go and Node.JS have. This makes you do a little more work for this kind of thing, in exchange for finer control than a language with a runtime can provide.
- metajack 9y agoWe use hyper and rolled our own async support I believe, since it didn't exist at the time, but it is quite neglected and the general plan has been to move to futures and tokio. Firefox's network stack is called necko, and has been async for a long time I believe.
- Manishearth 9y agoNeither Firefox nor Servo use async http requests in the Rust code. The only Rust code in Firefox's network stack is the URL parser. The rest of the stack is in C++, and I believe it handles async. Servo's network code is still pretty premature. I plan to poke at tokio-ifying it at some point, or at least having better thread pooling.