diff options
author | Jae-Heon Ji <32578710+jaeheonji@users.noreply.github.com> | 2020-12-10 00:48:06 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 16:48:06 +0100 |
commit | d492fb0eac8296513f003cf32edf80ec99bf8f2b (patch) | |
tree | e6dadd7afe1f72aab9860f64f13e94cfa343c7ad /op_crates/fetch/lib.rs | |
parent | b200e6fc3e591f67646832adb9bbf129ee2b2761 (diff) |
fix(op_crates/fetch): support non-ascii response headers value (#8600)
Diffstat (limited to 'op_crates/fetch/lib.rs')
-rw-r--r-- | op_crates/fetch/lib.rs | 15 |
1 files changed, 14 insertions, 1 deletions
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::<String>(), + )); + } } let rid = state |