You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide "mid-level" bindings to the XMLHttpRequest API. "mid-level" in this case would mean a callback-based API to cover the whole of XHR, mirroring web_sys::XmlHttpRequest with more idiomatic Rust types and ergonomic improvements where possible without compromising fidelity to the original.
Motivation
The "blessed" browser API for HTTP going forward is fetch, but fetch does not provide all the features XMLHttpRequest does at the moment (one notable example being download/upload progress events).
This could also be used as a base for higher level bindings providing a more ergonomic interface from Rust, but I propose leaving it to a future discussion.
Detailed Explanation
The bindings would be implemented inside a new gloo-xhr crate in a callback top-level module, to leave room for a potential future-based wrapper built on of it.
Two examples to motivate why we would benefit from "mid-level" bindings, compared to raw web_sys:
Callbacks would be typed Rust closures.
We wouldn't have many methods to set the body of a request, like in web_sys, but a set_body method generic over a (for example) XhrRequestBody trait implemented by all valid body types.
The documentation should mention that fetch is the API that is currently being pushed forward in browsers and will eventually supersede XmlHttpRequest.
Drawbacks, Rationale, and Alternatives
Alternatively, these bindings could be grouped with the fetch bindings in a common gloo-http or gloo-ajax crate.
The implementation would aim to map as close as possible to the original web API; as such few design decisions should be necessary.
Unresolved Questions
Providing nice, ideally typed errors could be challenging, as the error cases in networking APIs are many.
The text was updated successfully, but these errors were encountered:
Summary
Provide "mid-level" bindings to the XMLHttpRequest API. "mid-level" in this case would mean a callback-based API to cover the whole of XHR, mirroring
web_sys::XmlHttpRequest
with more idiomatic Rust types and ergonomic improvements where possible without compromising fidelity to the original.Motivation
The "blessed" browser API for HTTP going forward is
fetch
, but fetch does not provide all the features XMLHttpRequest does at the moment (one notable example being download/upload progress events).This could also be used as a base for higher level bindings providing a more ergonomic interface from Rust, but I propose leaving it to a future discussion.
Detailed Explanation
The bindings would be implemented inside a new
gloo-xhr
crate in acallback
top-level module, to leave room for a potential future-based wrapper built on of it.Two examples to motivate why we would benefit from "mid-level" bindings, compared to raw
web_sys
:web_sys
, but aset_body
method generic over a (for example)XhrRequestBody
trait implemented by all valid body types.The documentation should mention that
fetch
is the API that is currently being pushed forward in browsers and will eventually supersede XmlHttpRequest.Drawbacks, Rationale, and Alternatives
Alternatively, these bindings could be grouped with the
fetch
bindings in a commongloo-http
orgloo-ajax
crate.The implementation would aim to map as close as possible to the original web API; as such few design decisions should be necessary.
Unresolved Questions
Providing nice, ideally typed errors could be challenging, as the error cases in networking APIs are many.
The text was updated successfully, but these errors were encountered: