http-rs / http-rs/http-types

Convert from/into web_sys::Request/Response

Open
#317 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
209
Forks
91
PR merge metrics
No merged PRs in 30d

Description

It's nice that `http-types` compiles to WASM in the browser, even nicer would be to have a way to convert back and forth between the Request/Response types in this crate and the "native" JS Request/Response to avoid wrapping with a new type. The feature can be gated with a flag(e.g. `web`).
This is probably better and more general purpose than what I proposed in https://github.com/http-rs/http-client/issues/60 and can eventually simplify the code over there. I also think conversion could be made more efficient if the JS Request/Response body that is a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)(implements the `asyncIterator` protocol) is converted to a [Stream](https://github.com/rustwasm/wasm-bindgen/pull/2401)/AsyncReader, modern Chrome even allows transferring those streams with the postMessage API so for my use case of intercepting requests from a ServiceWorker to be handled in a Worker(Using Rust and `http-types`) could be made much more efficient in the future.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.