Bug 1396824 - Handle head requests by sending 200 in event of WebDriverMessage existing
MozReview-Commit-ID: AewTGNsLWZs
--- 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);
{