diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-04-20 14:47:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 14:47:22 +0200 |
commit | 9e6cd91014ac4a0d34556b0d09cbe25e4e0930c6 (patch) | |
tree | 4523790510a17676c987039feb03f208a258dc16 /runtime/ops | |
parent | 115197ffb06aad2a3045e8478980ab911b5a5eeb (diff) |
chore: align fetch to spec (#10203)
This commit aligns the `fetch` API and the `Request` / `Response`
classes belonging to it to the spec. This commit enables all the
relevant `fetch` WPT tests. Spec compliance is now at around 90%.
Performance is essentially identical now (within 1% of 1.9.0).
Diffstat (limited to 'runtime/ops')
-rw-r--r-- | runtime/ops/http.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index bdef14594..4d9787cde 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -331,7 +331,7 @@ struct RespondArgs( // status: u16, // headers: - Vec<String>, + Vec<(String, String)>, ); async fn op_http_response( @@ -358,11 +358,9 @@ async fn op_http_response( let mut builder = Response::builder().status(status); - debug_assert_eq!(headers.len() % 2, 0); - let headers_count = headers.len() / 2; - builder.headers_mut().unwrap().reserve(headers_count); - for i in 0..headers_count { - builder = builder.header(&headers[2 * i], &headers[2 * i + 1]); + builder.headers_mut().unwrap().reserve(headers.len()); + for (key, value) in &headers { + builder = builder.header(key, value); } let res; |