Bug 1396824 - Handle head requests by sending 200 in event of WebDriverMessage existing draft
authorGreg Fraley <gsfraley@gmail.com>
Tue, 06 Mar 2018 22:39:35 -0500
changeset 764068 ee26fee4848794745390e715cdb0495af7e9a242
parent 763942 bccdc684210431c233622650a91454c09f6af9eb
push id101653
push userbmo:gsfraley@gmail.com
push dateWed, 07 Mar 2018 03:40:03 +0000
bugs1396824
milestone60.0a1
Bug 1396824 - Handle head requests by sending 200 in event of WebDriverMessage existing MozReview-Commit-ID: AewTGNsLWZs
testing/webdriver/src/server.rs
--- a/testing/webdriver/src/server.rs
+++ b/testing/webdriver/src/server.rs
@@ -177,48 +177,53 @@ impl<U: WebDriverExtensionRoute> Handler
         debug!("-> {} {} {}", req.method, req.uri, body);
 
         match req.uri {
             AbsolutePath(path) => {
                 let msg_result = {
                     // The fact that this locks for basically the whole request doesn't
                     // matter as long as we are only handling one request at a time.
                     match self.api.lock() {
-                        Ok(ref api) => api.decode_request(req.method, &path[..], &body[..]),
+                        Ok(ref api) => api.decode_request(req.method.clone(), &path[..], &body[..]),
                         Err(_) => return,
                     }
                 };
                 let (status, resp_body) = match msg_result {
                     Ok(message) => {
-                        let (send_res, recv_res) = channel();
-                        match self.chan.lock() {
-                            Ok(ref c) => {
-                                let res =
-                                    c.send(DispatchMessage::HandleWebDriver(message, send_res));
-                                match res {
-                                    Ok(x) => x,
+                        match req.method {
+                            Method::Head => (StatusCode::Ok, String::new()),
+                            _ => {
+                                let (send_res, recv_res) = channel();
+                                match self.chan.lock() {
+                                    Ok(ref c) => {
+                                        let res =
+                                            c.send(DispatchMessage::HandleWebDriver(message, send_res));
+                                        match res {
+                                            Ok(x) => x,
+                                            Err(_) => {
+                                                error!("Something terrible happened");
+                                                return;
+                                            }
+                                        }
+                                    }
                                     Err(_) => {
                                         error!("Something terrible happened");
                                         return;
                                     }
                                 }
-                            }
-                            Err(_) => {
-                                error!("Something terrible happened");
-                                return;
-                            }
-                        }
-                        match recv_res.recv() {
-                            Ok(data) => {
-                                match data {
-                                    Ok(response) => (StatusCode::Ok, response.to_json_string()),
-                                    Err(err) => (err.http_status(), err.to_json_string()),
+                                match recv_res.recv() {
+                                    Ok(data) => {
+                                        match data {
+                                            Ok(response) => (StatusCode::Ok, response.to_json_string()),
+                                            Err(err) => (err.http_status(), err.to_json_string()),
+                                        }
+                                    }
+                                    Err(e) => panic!("Error reading response: {:?}", e),
                                 }
                             }
-                            Err(e) => panic!("Error reading response: {:?}", e),
                         }
                     }
                     Err(err) => (err.http_status(), err.to_json_string()),
                 };
 
                 debug!("<- {} {}", status, resp_body);
 
                 {