mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 14:00:01 -04:00
fix readablestream bodies
This commit is contained in:
parent
903d5a6720
commit
eca9d42da6
5 changed files with 17 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -511,7 +511,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epoxy-client"
|
name = "epoxy-client"
|
||||||
version = "2.0.3"
|
version = "2.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-compression",
|
"async-compression",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "epoxy-client"
|
name = "epoxy-client"
|
||||||
version = "2.0.3"
|
version = "2.0.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
|
@ -63,10 +63,20 @@ onmessage = async (msg) => {
|
||||||
return t1 - t0;
|
return t1 - t0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const readableStream = (buffer) => {
|
||||||
|
return new ReadableStream({
|
||||||
|
start(controller) {
|
||||||
|
controller.enqueue(buffer);
|
||||||
|
controller.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (should_feature_test) {
|
if (should_feature_test) {
|
||||||
let formdata = new FormData();
|
let formdata = new FormData();
|
||||||
formdata.append("a", "b");
|
formdata.append("a", "b");
|
||||||
for (const url of [
|
for (const url of [
|
||||||
|
["https://httpbin.org/post", { method: "POST", body: readableStream((new TextEncoder()).encode("abc")) }],
|
||||||
["https://httpbin.org/get", {}],
|
["https://httpbin.org/get", {}],
|
||||||
["https://httpbin.org/gzip", {}],
|
["https://httpbin.org/gzip", {}],
|
||||||
["https://httpbin.org/brotli", {}],
|
["https://httpbin.org/brotli", {}],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@mercuryworkshop/epoxy-tls",
|
"name": "@mercuryworkshop/epoxy-tls",
|
||||||
"version": "2.0.3-5",
|
"version": "2.0.4-1",
|
||||||
"description": "A wasm library for using raw encrypted tls/ssl/https/websocket streams on the browser",
|
"description": "A wasm library for using raw encrypted tls/ssl/https/websocket streams on the browser",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./build.sh"
|
"build": "./build.sh"
|
||||||
|
|
|
@ -102,10 +102,10 @@ pub fn object_set(obj: &Object, key: &JsValue, value: &JsValue) -> Result<(), Ep
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn convert_body(val: JsValue) -> Result<(Uint8Array, web_sys::Request), JsValue> {
|
pub async fn convert_body(val: JsValue) -> Result<(Uint8Array, web_sys::Request), JsValue> {
|
||||||
let req = web_sys::Request::new_with_str_and_init(
|
let mut request_init = web_sys::RequestInit::new();
|
||||||
"/",
|
request_init.method("POST").body(Some(&val));
|
||||||
web_sys::RequestInit::new().method("POST").body(Some(&val)),
|
object_set(&request_init, &"duplex".into(), &"half".into())?;
|
||||||
)?;
|
let req = web_sys::Request::new_with_str_and_init("/", &request_init)?;
|
||||||
Ok((
|
Ok((
|
||||||
JsFuture::from(req.array_buffer()?)
|
JsFuture::from(req.array_buffer()?)
|
||||||
.await?
|
.await?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue