diff --git a/testing/webdriver/src/command.rs b/testing/webdriver/src/command.rs index 2c683d84ca39..70dfe9c4a5f0 100644 --- a/testing/webdriver/src/command.rs +++ b/testing/webdriver/src/command.rs @@ -100,7 +100,7 @@ impl WebDriverMessage { } pub fn from_http( - match_type: Route, + match_type: &Route, params: &Captures, raw_body: &str, requires_body: bool, diff --git a/testing/webdriver/src/httpapi.rs b/testing/webdriver/src/httpapi.rs index c975790a92b5..1581b4b62757 100644 --- a/testing/webdriver/src/httpapi.rs +++ b/testing/webdriver/src/httpapi.rs @@ -323,7 +323,7 @@ impl RequestMatcher { } } - pub fn get_match<'t>(&'t self, method: Method, path: &'t str) -> (bool, Option) { + pub fn get_match<'t>(&'t self, method: &Method, path: &'t str) -> (bool, Option) { let captures = self.path_regexp.captures(path); (method == self.method, captures) } @@ -342,10 +342,10 @@ impl RequestMatcher { rv.push_str(&format!("{}/", component)[..]); } } - //Remove the trailing / + // Remove the trailing / rv.pop(); rv.push_str("$"); - //This will fail at runtime if the regexp is invalid + // This will fail at runtime if the regexp is invalid Regex::new(&rv[..]).unwrap() } } @@ -379,18 +379,18 @@ impl WebDriverHttpApi { pub fn decode_request( &self, - method: Method, + method: &Method, path: &str, body: &str, ) -> WebDriverResult> { let mut error = ErrorStatus::UnknownPath; for &(ref match_method, ref matcher) in self.routes.iter() { if method == *match_method { - let (method_match, captures) = matcher.get_match(method.clone(), path); + let (method_match, captures) = matcher.get_match(method, path); if captures.is_some() { if method_match { return WebDriverMessage::from_http( - matcher.match_type.clone(), + &matcher.match_type, &captures.unwrap(), body, method == Method::POST, diff --git a/testing/webdriver/src/server.rs b/testing/webdriver/src/server.rs index 3032d56ca7b1..702c9fed32fc 100644 --- a/testing/webdriver/src/server.rs +++ b/testing/webdriver/src/server.rs @@ -63,7 +63,7 @@ impl, U: WebDriverExtensionRoute> Dispatcher { } } - fn run(&mut self, msg_chan: Receiver>) { + fn run(&mut self, msg_chan: &Receiver>) { loop { match msg_chan.recv() { Ok(DispatchMessage::HandleWebDriver(msg, resp_chan)) => { @@ -190,7 +190,8 @@ impl Service for HttpHandler { // 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 api.lock() { - Ok(ref api) => api.decode_request(method, &uri.path(), &body[..]), + + Ok(ref api) => api.decode_request(&method, &uri.path(), &body[..]), Err(e) => panic!("Error decoding request: {:?}", e), } }; @@ -284,7 +285,7 @@ where let builder = thread::Builder::new().name("webdriver dispatcher".to_string()); builder.spawn(move || { let mut dispatcher = Dispatcher::new(handler); - dispatcher.run(msg_recv); + dispatcher.run(&msg_recv); })?; Ok(Listener { _guard: Some(handle), socket: addr })