blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Add `ureq` backend for `blitz-net`

Open SpikeHD opened this issue 10 months ago • 2 comments

Addresses #181

TODO

(These are just copied from the above issue :P)

  • [x] Be part of the existing blitz-net crate with feature flags for each backend
  • [x] Use the new 3.x version of ureq
  • [x] Split the reqwest and ureq implementations in separate files/modules
  • [x] Use a threadpool to allow for multiple concurrent requests
  • [x] Implement the blitz_net::get_text method as well as blitz_net::Provider

SpikeHD avatar Feb 28 '25 20:02 SpikeHD

To test this, set ureq as the default feature in blitz-net, then change packages/blitz/src/lib.rs@L36 like so:

- let html = rt.block_on(blitz_net::get_text(&url));
+ let html = blitz_net::get_text(&url));

SpikeHD avatar Feb 28 '25 22:02 SpikeHD

@nicoburns I know you'll be gone, but once you're back, I have a couple architecture questions:

  • Is there a better way to handle the two Providers? Right now they are almost the same, except for the fact that fetch_inner is async on the reqwest backend. I'd like to ofc prevent repeated code but my little brain can't conceptualize how that might look
  • How should the other packages be modified to not use tokio (in the case someone is gonna use the ureq backend to avoid an async runtime, for example)? From what I can tell, three packages use it, blitz, blitz-shell, and dioxus-native. Or is that out of scope for this PR (I would be very okay with this :P)?

"Allow edits by maintainers" should be on if you feel inspired haha

SpikeHD avatar Feb 28 '25 22:02 SpikeHD