Update to compile with rustc d3c49d2140fc65e8bb7d7cf25bfe74dda6ce5ecf/rustc-1.0.0-dev.
This commit is contained in:
Родитель
6c891a2099
Коммит
71f8d591e6
11
Cargo.toml
11
Cargo.toml
|
@ -6,10 +6,7 @@ authors = ["James Graham <james@hoppipolla.co.uk>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.2.4"
|
log = "0.2.4"
|
||||||
regex = "0.1.15"
|
regex = "0.1.18"
|
||||||
rustc-serialize = "0.2.15"
|
rustc-serialize = "0.3.4"
|
||||||
uuid = "0.1.10"
|
uuid = "0.1.11"
|
||||||
|
hyper = "0.3"
|
||||||
[dependencies.hyper]
|
|
||||||
git = "https://github.com/hyperium/hyper"
|
|
||||||
branch = "master"
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![feature(old_io)]
|
#![feature(io)]
|
||||||
|
#![feature(net)]
|
||||||
#![feature(core)]
|
#![feature(core)]
|
||||||
#![feature(collections)]
|
#![feature(collections)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::old_io::net::ip::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::num::FromPrimitive;
|
use std::num::FromPrimitive;
|
||||||
|
use std::io::{Write, Read};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -153,10 +154,10 @@ impl Handler for HttpHandler {
|
||||||
let mut req = req;
|
let mut req = req;
|
||||||
let mut res = res;
|
let mut res = res;
|
||||||
|
|
||||||
let body = match req.method {
|
let mut body = String::new();
|
||||||
Method::Post => req.read_to_string().unwrap(),
|
if let Method::Post = req.method {
|
||||||
_ => "".to_string()
|
req.read_to_string(&mut body).unwrap();
|
||||||
};
|
}
|
||||||
debug!("Got request {} {:?}", req.method, req.uri);
|
debug!("Got request {} {:?}", req.method, req.uri);
|
||||||
match req.uri {
|
match req.uri {
|
||||||
AbsolutePath(path) => {
|
AbsolutePath(path) => {
|
||||||
|
@ -214,9 +215,9 @@ impl Handler for HttpHandler {
|
||||||
*status_code = FromPrimitive::from_u32(status).unwrap();
|
*status_code = FromPrimitive::from_u32(status).unwrap();
|
||||||
}
|
}
|
||||||
res.headers_mut().set(ContentLength(resp_body.len() as u64));
|
res.headers_mut().set(ContentLength(resp_body.len() as u64));
|
||||||
let mut stream = res.start();
|
let mut stream = res.start().unwrap();
|
||||||
stream.write_str(&resp_body[..]).unwrap();
|
stream.write_all(&resp_body.as_bytes()).unwrap();
|
||||||
stream.unwrap().end().unwrap();
|
stream.end().unwrap();
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -224,15 +225,15 @@ impl Handler for HttpHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start<T: 'static+WebDriverHandler>(ip_address: IpAddr, port: u16, handler: T) {
|
pub fn start<T: 'static+WebDriverHandler>(ip_address: IpAddr, port: u16, handler: T) {
|
||||||
let server = Server::http(ip_address, port);
|
|
||||||
|
|
||||||
let (msg_send, msg_recv) = channel();
|
let (msg_send, msg_recv) = channel();
|
||||||
|
|
||||||
|
let api = WebDriverHttpApi::new();
|
||||||
|
let http_handler = HttpHandler::new(api, msg_send);
|
||||||
|
let server = Server::http(http_handler);
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut dispatcher = Dispatcher::new(handler);
|
let mut dispatcher = Dispatcher::new(handler);
|
||||||
dispatcher.run(msg_recv)
|
dispatcher.run(msg_recv)
|
||||||
});
|
});
|
||||||
let api = WebDriverHttpApi::new();
|
server.listen(ip_address, port).unwrap();
|
||||||
let http_handler = HttpHandler::new(api, msg_send.clone());
|
|
||||||
server.listen(http_handler).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче