From 9e6cd91014ac4a0d34556b0d09cbe25e4e0930c6 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 20 Apr 2021 14:47:22 +0200 Subject: 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). --- runtime/ops/http.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'runtime/ops') 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, + 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; -- cgit v1.2.3