From c0f9fb8f552d70494fbbad9f1363c9c8ee91334b Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 8 Apr 2017 21:47:55 +0200 Subject: [PATCH] Do not return an error for non-GET data: requests (fixes #13293) --- components/net/fetch/methods.rs | 20 ++++++++----------- .../metadata/XMLHttpRequest/data-uri.htm.ini | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index eb740a1cb53..a073056ee56 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -395,18 +395,14 @@ fn basic_fetch(request: &mut Request, }, "data" => { - if request.method == Method::Get { - match decode(&url) { - Ok((mime, bytes)) => { - let mut response = Response::new(url); - *response.body.lock().unwrap() = ResponseBody::Done(bytes); - response.headers.set(ContentType(mime)); - response - }, - Err(_) => Response::network_error(NetworkError::Internal("Decoding data URL failed".into())) - } - } else { - Response::network_error(NetworkError::Internal("Unexpected method for data".into())) + match decode(&url) { + Ok((mime, bytes)) => { + let mut response = Response::new(url); + *response.body.lock().unwrap() = ResponseBody::Done(bytes); + response.headers.set(ContentType(mime)); + response + }, + Err(_) => Response::network_error(NetworkError::Internal("Decoding data URL failed".into())) } }, diff --git a/tests/wpt/metadata/XMLHttpRequest/data-uri.htm.ini b/tests/wpt/metadata/XMLHttpRequest/data-uri.htm.ini index a26e5693e32..b27f5116d93 100644 --- a/tests/wpt/metadata/XMLHttpRequest/data-uri.htm.ini +++ b/tests/wpt/metadata/XMLHttpRequest/data-uri.htm.ini @@ -3,3 +3,23 @@ [XHR method GET with charset text/html;charset=UTF-8] expected: FAIL + [XHR method POST with charset text/plain] + bug: https://github.com/w3c/web-platform-tests/issues/3738 + expected: FAIL + + [XHR method PUT with charset text/plain] + bug: https://github.com/w3c/web-platform-tests/issues/3738 + expected: FAIL + + [XHR method DELETE with charset text/plain] + bug: https://github.com/w3c/web-platform-tests/issues/3738 + expected: FAIL + + [XHR method HEAD with charset text/plain] + bug: https://github.com/w3c/web-platform-tests/issues/3738 + expected: FAIL + + [XHR method UNICORN with charset text/plain] + bug: https://github.com/w3c/web-platform-tests/issues/3738 + expected: FAIL +