add bits to deal with Upgrade requests

This commit is contained in:
Sean McArthur
2014-09-24 17:31:56 -07:00
parent 68e2278339
commit 0ab52c9009
9 changed files with 314 additions and 60 deletions

29
src/mock.rs Normal file
View File

@@ -0,0 +1,29 @@
use std::io::IoResult;
use std::io::net::ip::SocketAddr;
use net::NetworkStream;
#[deriving(Clone, PartialEq, Show)]
pub struct MockStream;
impl Reader for MockStream {
fn read(&mut self, _buf: &mut [u8]) -> IoResult<uint> {
unimplemented!()
}
}
impl Writer for MockStream {
fn write(&mut self, _msg: &[u8]) -> IoResult<()> {
unimplemented!()
}
}
impl NetworkStream for MockStream {
fn connect(_host: &str, _port: u16, _scheme: &str) -> IoResult<MockStream> {
Ok(MockStream)
}
fn peer_name(&mut self) -> IoResult<SocketAddr> {
Ok(from_str("127.0.0.1:1337").unwrap())
}
}