From d492fb0eac8296513f003cf32edf80ec99bf8f2b Mon Sep 17 00:00:00 2001 From: Jae-Heon Ji <32578710+jaeheonji@users.noreply.github.com> Date: Thu, 10 Dec 2020 00:48:06 +0900 Subject: fix(op_crates/fetch): support non-ascii response headers value (#8600) --- op_crates/fetch/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'op_crates/fetch/lib.rs') diff --git a/op_crates/fetch/lib.rs b/op_crates/fetch/lib.rs index 49d951d8f..8a4c1ee16 100644 --- a/op_crates/fetch/lib.rs +++ b/op_crates/fetch/lib.rs @@ -156,7 +156,20 @@ where let status = res.status(); let mut res_headers = Vec::new(); for (key, val) in res.headers().iter() { - res_headers.push((key.to_string(), val.to_str().unwrap().to_owned())); + let key_string = key.to_string(); + + if val.as_bytes().is_ascii() { + res_headers.push((key_string, val.to_str().unwrap().to_owned())) + } else { + res_headers.push(( + key_string, + val + .as_bytes() + .iter() + .map(|&c| c as char) + .collect::(), + )); + } } let rid = state -- cgit v1.2.3