Repository: seanmonstar/reqwest (language: rust)

Issue:
WASM: translate over response headers



Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index b1aecc6d1..d47e3bdad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -115,7 +115,7 @@ winreg = "0.6"
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 js-sys = "0.3.28"
-wasm-bindgen = "0.2.51"
+wasm-bindgen = { version = "0.2.51", features = ["serde-serialize"] }
 wasm-bindgen-futures = "0.4.1"
 
 [target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
diff --git a/src/wasm/client.rs b/src/wasm/client.rs
index 95b424684..a38b16fde 100644
--- a/src/wasm/client.rs
+++ b/src/wasm/client.rs
@@ -129,8 +129,6 @@ async fn fetch(req: Request) -> crate::Result<Response> {
     let mut resp = http::Response::builder();
     resp.status(js_resp.status());
 
-    // TODO: translate js_resp.headers()
-    /*
     let js_headers = js_resp.headers();
     let js_iter = js_sys::try_iter(&js_headers)
         .expect_throw("headers try_iter")
@@ -138,8 +136,12 @@ async fn fetch(req: Request) -> crate::Result<Response> {
 
     for item in js_iter {
         let item = item.expect_throw("headers iterator doesn't throw");
+        let v: Vec<String> = item.into_serde().expect_throw("headers into_serde");
+        resp.header(
+            v.get(0).expect_throw("headers name"),
+            v.get(1).expect_throw("headers value"),
+        );
     }
-    */
 
     resp.body(js_resp)
         .map(Response::new)


Test patch: