servo: Merge #16311 - Do not return an error for non-GET data: requests (fixes #13293) (from nox:data-method); r=KiChjang
authorAnthony Ramine <n.oxyde@gmail.com>
Sat, 08 Apr 2017 23:17:26 -0500
changeset 559335 f9d73f9d668fab6f6d9641ca9171a56a253d6852
parent 559334 1c1a99d972f1c2f4a35d35f928089ac548f5cdad
child 559336 d41a55de7efd83424fd4cfa96b47c1502a8e179f
push id53058
push userarchaeopteryx@coole-files.de
push dateSun, 09 Apr 2017 21:36:26 +0000
reviewersKiChjang
milestone55.0a1
servo: Merge #16311 - Do not return an error for non-GET data: requests (fixes #13293) (from nox:data-method); r=KiChjang Source-Repo: https://github.com/servo/servo Source-Revision: 3a5ed1797f8db21b5d90c90c509b16f0535691a8
servo/components/net/fetch/methods.rs
--- a/servo/components/net/fetch/methods.rs
+++ b/servo/components/net/fetch/methods.rs
@@ -390,28 +390,24 @@ fn basic_fetch(request: &mut Request,
             response
         },
 
         "http" | "https" => {
             http_fetch(request, cache, false, false, false, target, done_chan, context)
         },
 
         "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()))
             }
         },
 
         "file" => {
             if request.method == Method::Get {
                 match url.to_file_path() {
                     Ok(file_path) => {
                         match File::open(file_path.clone()) {