Comments (4)
Hi @brandonros! Welcome to ureq!
I have never used WebAssembly myself, so I don't actually know what would be required to make that work. The Duration
here are ultimately used as socket timeouts. Those sockets are std::net::TcpStream
, and I'll imagine that even if we get past the Duration
problems, we will get to a dead end for the sockets. I don't know if it would be possible to solve that – blocking sockets at the bottom of the call stack?
A possible direction for a ureq 3.0, would be to isolate the HTTP request/response function into a Sans IO pattern backing library without allocations, deliberately target no_std and webassembly. Then make nice higher level wrappers for std, no_std and webasm that sits on the same core.
from ureq.
I'm curious @brandonros, what's the use case for using ureq in WebAssembly?
If it's useful, we could probably do something where all the meaningful features are stubbed out to fetch
, but we'd need some motivating use cases.
I do really like the idea of making a no_std version of ureq (with more user-friendly features stacked on top when std is present).
from ureq.
@jsha i've been thinking about the no_std thing.
Here's an experiment just fleshing out what a no_std low level API could look like: https://github.com/algesten/h1-call
Design goals:
no_std
and no alloc crate. Stack is enough- Sans-IO. Bring your own transport.
- Allow flushing the buffer to the transport at any point. I.e. do not require all headers to be in the borrowed buffer at the same time.
- Encode protocol as types, i.e. let
State
mean "the state the call is currently in",Version
means Http/1.0 or 1.1.Method
means GET/HEAD/etc... - Using types, constraint operations to only those that are valid. I.e.
Version
HTTP/1.0
cannot send a body unless theMethod
isPOST
(the others are GET/HEAD which cannot have a body).
I've fleshed out how this could look with HTTP/1.0 – but it looks pretty promising, albeit it's a type soup.
from ureq.
I'm curious @brandonros, what's the use case for using ureq in WebAssembly?
If it's useful, we could probably do something where all the meaningful features are stubbed out to
fetch
, but we'd need some motivating use cases.I do really like the idea of making a no_std version of ureq (with more user-friendly features stacked on top when std is present).
You're probably right. My "vision"/idea was probably due to a lack of understanding on how things should be done in wasm
land but the argument was:
write once, be able to run it backend (native Rust binary) and/or in the browser with wasm
without having to add logic like if backend, use ureq, otherwise, use web-sys fetch
https://github.com/search?q=repo%3Arustwasm%2Fwasm-bindgen%20fetch_with_request&type=code
from ureq.
Related Issues (20)
- Timeout not working when having packet losses HOT 1
- Support Multipart Forms HOT 1
- Timeout not always respected HOT 5
- Invalid transformation to http::Response<Vec<u8>> for non utf8 response bodies HOT 3
- Example of requesting a continuous stream HOT 1
- Timeout not taking in consideration TimeoutConnect HOT 2
- ureq 2.9.3 fails to compile with errors in `hoot` HOT 3
- `ureq` 2.9.3 compilation fails due to `hoot` requiring rustc 1.65 HOT 4
- Keep-alive is disabled when using SOCKS HOT 1
- Update requirement of `url=2.3.1` HOT 3
- hootbin is a required dependency HOT 2
- Stream panics in drop during test
- Redirect history not available HOT 2
- Add support for configuring default headers in AgentBuilder HOT 1
- Potential to modify ordering for IS_TEST in lib module HOT 1
- Change `send_json` `data` argument HOT 4
- Add `Error::as_response` HOT 3
- Middleware cannot modify query string parameters? HOT 2
- Decide what to do about rustls defaulting to aws-lc-rs instead of ring HOT 12
- Agent should be able to accept `http::Request` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ureq.