fix(rustup): update io import, Writer::write

Make it build with the latest rust-nightly (2015-01-27)

Renamed io import to old_io.
Renamed Writer::write to Writer::write_all
This commit is contained in:
Christian Stefanescu
2015-01-28 19:52:18 +01:00
committed by Sean McArthur
parent 537d691d61
commit f606b6039d
18 changed files with 81 additions and 81 deletions

View File

@@ -4,7 +4,7 @@ extern crate hyper;
extern crate test; extern crate test;
use std::fmt; use std::fmt;
use std::io::net::ip::Ipv4Addr; use std::old_io::net::ip::Ipv4Addr;
use hyper::server::{Request, Response, Server}; use hyper::server::{Request, Response, Server};
use hyper::header::Headers; use hyper::header::Headers;
use hyper::Client; use hyper::Client;
@@ -26,7 +26,7 @@ macro_rules! try_return(
fn handle(_r: Request, res: Response) { fn handle(_r: Request, res: Response) {
static BODY: &'static [u8] = b"Benchmarking hyper vs others!"; static BODY: &'static [u8] = b"Benchmarking hyper vs others!";
let mut res = try_return!(res.start()); let mut res = try_return!(res.start());
try_return!(res.write(BODY)); try_return!(res.write_all(BODY));
try_return!(res.end()); try_return!(res.end());
} }

View File

@@ -4,8 +4,8 @@ extern crate hyper;
extern crate test; extern crate test;
use std::fmt; use std::fmt;
use std::io::{IoResult, MemReader}; use std::old_io::{IoResult, MemReader};
use std::io::net::ip::SocketAddr; use std::old_io::net::ip::SocketAddr;
use hyper::net; use hyper::net;
@@ -40,7 +40,7 @@ impl Reader for MockStream {
} }
impl Writer for MockStream { impl Writer for MockStream {
fn write(&mut self, _msg: &[u8]) -> IoResult<()> { fn write_all(&mut self, _msg: &[u8]) -> IoResult<()> {
// we're mocking, what do we care. // we're mocking, what do we care.
Ok(()) Ok(())
} }

View File

@@ -3,7 +3,7 @@ extern crate hyper;
extern crate test; extern crate test;
use test::Bencher; use test::Bencher;
use std::io::net::ip::Ipv4Addr; use std::old_io::net::ip::Ipv4Addr;
use hyper::method::Method::Get; use hyper::method::Method::Get;
use hyper::server::{Request, Response}; use hyper::server::{Request, Response};
@@ -17,7 +17,7 @@ fn request(url: hyper::Url) {
fn hyper_handle(_: Request, res: Response) { fn hyper_handle(_: Request, res: Response) {
let mut res = res.start().unwrap(); let mut res = res.start().unwrap();
res.write(PHRASE).unwrap(); res.write_all(PHRASE).unwrap();
res.end().unwrap(); res.end().unwrap();
} }

View File

@@ -2,8 +2,8 @@
extern crate hyper; extern crate hyper;
use std::os; use std::os;
use std::io::stdout; use std::old_io::stdout;
use std::io::util::copy; use std::old_io::util::copy;
use hyper::Client; use hyper::Client;

View File

@@ -1,14 +1,14 @@
#![allow(unstable)] #![allow(unstable)]
extern crate hyper; extern crate hyper;
use std::io::net::ip::Ipv4Addr; use std::old_io::net::ip::Ipv4Addr;
use hyper::server::{Request, Response}; use hyper::server::{Request, Response};
static PHRASE: &'static [u8] = b"Hello World!"; static PHRASE: &'static [u8] = b"Hello World!";
fn hello(_: Request, res: Response) { fn hello(_: Request, res: Response) {
let mut res = res.start().unwrap(); let mut res = res.start().unwrap();
res.write(PHRASE).unwrap(); res.write_all(PHRASE).unwrap();
res.end().unwrap(); res.end().unwrap();
} }

View File

@@ -2,8 +2,8 @@
extern crate hyper; extern crate hyper;
#[macro_use] extern crate log; #[macro_use] extern crate log;
use std::io::util::copy; use std::old_io::util::copy;
use std::io::net::ip::Ipv4Addr; use std::old_io::net::ip::Ipv4Addr;
use hyper::{Get, Post}; use hyper::{Get, Post};
use hyper::header::ContentLength; use hyper::header::ContentLength;
@@ -27,7 +27,7 @@ fn echo(mut req: Request, mut res: Response) {
res.headers_mut().set(ContentLength(out.len() as u64)); res.headers_mut().set(ContentLength(out.len() as u64));
let mut res = try_return!(res.start()); let mut res = try_return!(res.start());
try_return!(res.write(out)); try_return!(res.write_all(out));
try_return!(res.end()); try_return!(res.end());
return; return;
}, },

View File

@@ -18,8 +18,8 @@
//! to the `status`, the `headers`, and the response body via the `Writer` //! to the `status`, the `headers`, and the response body via the `Writer`
//! trait. //! trait.
use std::default::Default; use std::default::Default;
use std::io::IoResult; use std::old_io::IoResult;
use std::io::util::copy; use std::old_io::util::copy;
use std::iter::Extend; use std::iter::Extend;
use url::UrlParser; use url::UrlParser;

View File

@@ -1,5 +1,5 @@
//! Client Requests //! Client Requests
use std::io::{BufferedWriter, IoResult}; use std::old_io::{BufferedWriter, IoResult};
use url::Url; use url::Url;
@@ -157,8 +157,8 @@ impl Request<Streaming> {
impl Writer for Request<Streaming> { impl Writer for Request<Streaming> {
#[inline] #[inline]
fn write(&mut self, msg: &[u8]) -> IoResult<()> { fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
self.body.write(msg) self.body.write_all(msg)
} }
#[inline] #[inline]

View File

@@ -1,6 +1,6 @@
//! Client Responses //! Client Responses
use std::num::FromPrimitive; use std::num::FromPrimitive;
use std::io::{BufferedReader, IoResult}; use std::old_io::{BufferedReader, IoResult};
use header; use header;
use header::{ContentLength, TransferEncoding}; use header::{ContentLength, TransferEncoding};
@@ -97,7 +97,7 @@ impl Reader for Response {
mod tests { mod tests {
use std::borrow::Cow::Borrowed; use std::borrow::Cow::Borrowed;
use std::boxed::BoxAny; use std::boxed::BoxAny;
use std::io::BufferedReader; use std::old_io::BufferedReader;
use header::Headers; use header::Headers;
use header::TransferEncoding; use header::TransferEncoding;

View File

@@ -141,7 +141,7 @@ impl FromStr for Basic {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io::MemReader; use std::old_io::MemReader;
use super::{Authorization, Basic}; use super::{Authorization, Basic};
use super::super::super::{Headers}; use super::super::super::{Headers};

View File

@@ -505,7 +505,7 @@ impl<'a, H: HeaderFormat> fmt::Debug for HeaderFormatter<'a, H> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io::MemReader; use std::old_io::MemReader;
use std::fmt; use std::fmt;
use std::borrow::Cow::Borrowed; use std::borrow::Cow::Borrowed;
use std::hash::{SipHasher, hash}; use std::hash::{SipHasher, hash};

View File

@@ -2,7 +2,7 @@
use std::borrow::Cow::{Borrowed, Owned}; use std::borrow::Cow::{Borrowed, Owned};
use std::borrow::IntoCow; use std::borrow::IntoCow;
use std::cmp::min; use std::cmp::min;
use std::io::{self, Reader, IoResult, BufWriter}; use std::old_io::{self, Reader, IoResult, BufWriter};
use std::num::from_u16; use std::num::from_u16;
use std::str::{self, FromStr}; use std::str::{self, FromStr};
use std::string::CowString; use std::string::CowString;
@@ -72,7 +72,7 @@ impl<R: Reader> Reader for HttpReader<R> {
SizedReader(ref mut body, ref mut remaining) => { SizedReader(ref mut body, ref mut remaining) => {
debug!("Sized read, remaining={:?}", remaining); debug!("Sized read, remaining={:?}", remaining);
if *remaining == 0 { if *remaining == 0 {
Err(io::standard_error(io::EndOfFile)) Err(old_io::standard_error(old_io::EndOfFile))
} else { } else {
let num = try!(body.read(buf)) as u64; let num = try!(body.read(buf)) as u64;
if num > *remaining { if num > *remaining {
@@ -98,7 +98,7 @@ impl<R: Reader> Reader for HttpReader<R> {
// if the 0 digit was missing from the stream, it would // if the 0 digit was missing from the stream, it would
// be an InvalidInput error instead. // be an InvalidInput error instead.
debug!("end of chunked"); debug!("end of chunked");
return Err(io::standard_error(io::EndOfFile)); return Err(old_io::standard_error(old_io::EndOfFile));
} }
let to_read = min(rem as usize, buf.len()); let to_read = min(rem as usize, buf.len());
@@ -116,7 +116,7 @@ impl<R: Reader> Reader for HttpReader<R> {
EofReader(ref mut body) => { EofReader(ref mut body) => {
body.read(buf) body.read(buf)
}, },
EmptyReader(_) => Err(io::standard_error(io::EndOfFile)) EmptyReader(_) => Err(old_io::standard_error(old_io::EndOfFile))
} }
} }
} }
@@ -125,7 +125,7 @@ fn eat<R: Reader>(rdr: &mut R, bytes: &[u8]) -> IoResult<()> {
for &b in bytes.iter() { for &b in bytes.iter() {
match try!(rdr.read_byte()) { match try!(rdr.read_byte()) {
byte if byte == b => (), byte if byte == b => (),
_ => return Err(io::standard_error(io::InvalidInput)) _ => return Err(old_io::standard_error(old_io::InvalidInput))
} }
} }
Ok(()) Ok(())
@@ -154,7 +154,7 @@ fn read_chunk_size<R: Reader>(rdr: &mut R) -> IoResult<u64> {
CR => { CR => {
match try!(rdr.read_byte()) { match try!(rdr.read_byte()) {
LF => break, LF => break,
_ => return Err(io::standard_error(io::InvalidInput)) _ => return Err(old_io::standard_error(old_io::InvalidInput))
} }
}, },
// If we weren't in the extension yet, the ";" signals its start // If we weren't in the extension yet, the ";" signals its start
@@ -178,7 +178,7 @@ fn read_chunk_size<R: Reader>(rdr: &mut R) -> IoResult<u64> {
// Finally, if we aren't in the extension and we're reading any // Finally, if we aren't in the extension and we're reading any
// other octet, the chunk size line is invalid! // other octet, the chunk size line is invalid!
_ => { _ => {
return Err(io::standard_error(io::InvalidInput)); return Err(old_io::standard_error(old_io::InvalidInput));
} }
} }
} }
@@ -239,11 +239,11 @@ impl<W: Writer> HttpWriter<W> {
/// Ends the HttpWriter, and returns the underlying Writer. /// Ends the HttpWriter, and returns the underlying Writer.
/// ///
/// A final `write()` is called with an empty message, and then flushed. /// A final `write_all()` is called with an empty message, and then flushed.
/// The ChunkedWriter variant will use this to write the 0-sized last-chunk. /// The ChunkedWriter variant will use this to write the 0-sized last-chunk.
#[inline] #[inline]
pub fn end(mut self) -> IoResult<W> { pub fn end(mut self) -> IoResult<W> {
try!(self.write(&[])); try!(self.write_all(&[]));
try!(self.flush()); try!(self.flush());
Ok(self.unwrap()) Ok(self.unwrap())
} }
@@ -251,14 +251,14 @@ impl<W: Writer> HttpWriter<W> {
impl<W: Writer> Writer for HttpWriter<W> { impl<W: Writer> Writer for HttpWriter<W> {
#[inline] #[inline]
fn write(&mut self, msg: &[u8]) -> IoResult<()> { fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
match *self { match *self {
ThroughWriter(ref mut w) => w.write(msg), ThroughWriter(ref mut w) => w.write_all(msg),
ChunkedWriter(ref mut w) => { ChunkedWriter(ref mut w) => {
let chunk_size = msg.len(); let chunk_size = msg.len();
debug!("chunked write, size = {:?}", chunk_size); debug!("chunked write, size = {:?}", chunk_size);
try!(write!(w, "{:X}{}", chunk_size, LINE_ENDING)); try!(write!(w, "{:X}{}", chunk_size, LINE_ENDING));
try!(w.write(msg)); try!(w.write_all(msg));
w.write_str(LINE_ENDING) w.write_str(LINE_ENDING)
}, },
SizedWriter(ref mut w, ref mut remaining) => { SizedWriter(ref mut w, ref mut remaining) => {
@@ -266,11 +266,11 @@ impl<W: Writer> Writer for HttpWriter<W> {
if len > *remaining { if len > *remaining {
let len = *remaining; let len = *remaining;
*remaining = 0; *remaining = 0;
try!(w.write(&msg[..len as usize])); try!(w.write_all(&msg[..len as usize]));
Err(io::standard_error(io::ShortWrite(len as usize))) Err(old_io::standard_error(old_io::ShortWrite(len as usize)))
} else { } else {
*remaining -= len; *remaining -= len;
w.write(msg) w.write_all(msg)
} }
}, },
EmptyWriter(..) => { EmptyWriter(..) => {
@@ -278,8 +278,8 @@ impl<W: Writer> Writer for HttpWriter<W> {
if bytes == 0 { if bytes == 0 {
Ok(()) Ok(())
} else { } else {
Err(io::IoError { Err(old_io::IoError {
kind: io::ShortWrite(bytes), kind: old_io::ShortWrite(bytes),
desc: "EmptyWriter cannot write any bytes", desc: "EmptyWriter cannot write any bytes",
detail: Some("Cannot include a body with this kind of message".to_string()) detail: Some("Cannot include a body with this kind of message".to_string())
}) })
@@ -347,7 +347,7 @@ pub fn is_token(b: u8) -> bool {
/// ///
/// The remaining contents of `buf` are left untouched. /// The remaining contents of `buf` are left untouched.
fn read_token_until_space<R: Reader>(stream: &mut R, buf: &mut [u8]) -> HttpResult<bool> { fn read_token_until_space<R: Reader>(stream: &mut R, buf: &mut [u8]) -> HttpResult<bool> {
use std::io::BufWriter; use std::old_io::BufWriter;
let mut bufwrt = BufWriter::new(buf); let mut bufwrt = BufWriter::new(buf);
loop { loop {
@@ -697,7 +697,7 @@ fn expect(r: IoResult<u8>, expected: u8) -> HttpResult<()> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io::{self, MemReader, MemWriter, IoResult}; use std::old_io::{self, MemReader, MemWriter, IoResult};
use std::borrow::Cow::{Borrowed, Owned}; use std::borrow::Cow::{Borrowed, Owned};
use test::Bencher; use test::Bencher;
use uri::RequestUri; use uri::RequestUri;
@@ -800,8 +800,8 @@ mod tests {
fn test_write_chunked() { fn test_write_chunked() {
use std::str::from_utf8; use std::str::from_utf8;
let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new()); let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new());
w.write(b"foo bar").unwrap(); w.write_all(b"foo bar").unwrap();
w.write(b"baz quux herp").unwrap(); w.write_all(b"baz quux herp").unwrap();
let buf = w.end().unwrap().into_inner(); let buf = w.end().unwrap().into_inner();
let s = from_utf8(buf.as_slice()).unwrap(); let s = from_utf8(buf.as_slice()).unwrap();
assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n"); assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n");
@@ -811,8 +811,8 @@ mod tests {
fn test_write_sized() { fn test_write_sized() {
use std::str::from_utf8; use std::str::from_utf8;
let mut w = super::HttpWriter::SizedWriter(MemWriter::new(), 8); let mut w = super::HttpWriter::SizedWriter(MemWriter::new(), 8);
w.write(b"foo bar").unwrap(); w.write_all(b"foo bar").unwrap();
assert_eq!(w.write(b"baz"), Err(io::standard_error(io::ShortWrite(1)))); assert_eq!(w.write_all(b"baz"), Err(old_io::standard_error(old_io::ShortWrite(1))));
let buf = w.end().unwrap().into_inner(); let buf = w.end().unwrap().into_inner();
let s = from_utf8(buf.as_slice()).unwrap(); let s = from_utf8(buf.as_slice()).unwrap();
@@ -834,13 +834,13 @@ mod tests {
read("Ff\r\n", Ok(255)); read("Ff\r\n", Ok(255));
read("Ff \r\n", Ok(255)); read("Ff \r\n", Ok(255));
// Missing LF or CRLF // Missing LF or CRLF
read("F\rF", Err(io::standard_error(io::InvalidInput))); read("F\rF", Err(old_io::standard_error(old_io::InvalidInput)));
read("F", Err(io::standard_error(io::EndOfFile))); read("F", Err(old_io::standard_error(old_io::EndOfFile)));
// Invalid hex digit // Invalid hex digit
read("X\r\n", Err(io::standard_error(io::InvalidInput))); read("X\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
read("1X\r\n", Err(io::standard_error(io::InvalidInput))); read("1X\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
read("-\r\n", Err(io::standard_error(io::InvalidInput))); read("-\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
read("-1\r\n", Err(io::standard_error(io::InvalidInput))); read("-1\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
// Acceptable (if not fully valid) extensions do not influence the size // Acceptable (if not fully valid) extensions do not influence the size
read("1;extension\r\n", Ok(1)); read("1;extension\r\n", Ok(1));
read("a;ext name=value\r\n", Ok(10)); read("a;ext name=value\r\n", Ok(10));
@@ -851,9 +851,9 @@ mod tests {
read("3 ;\r\n", Ok(3)); read("3 ;\r\n", Ok(3));
read("3 ; \r\n", Ok(3)); read("3 ; \r\n", Ok(3));
// Invalid extensions cause an error // Invalid extensions cause an error
read("1 invalid extension\r\n", Err(io::standard_error(io::InvalidInput))); read("1 invalid extension\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
read("1 A\r\n", Err(io::standard_error(io::InvalidInput))); read("1 A\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
read("1;no CRLF", Err(io::standard_error(io::EndOfFile))); read("1;no CRLF", Err(old_io::standard_error(old_io::EndOfFile)));
} }
#[bench] #[bench]

View File

@@ -136,7 +136,7 @@ extern crate cookie;
extern crate mucell; extern crate mucell;
extern crate unicase; extern crate unicase;
pub use std::io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr, Port}; pub use std::old_io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr, Port};
pub use mimewrapper::mime; pub use mimewrapper::mime;
pub use url::Url; pub use url::Url;
pub use client::Client; pub use client::Client;
@@ -146,7 +146,7 @@ pub use server::Server;
use std::error::{Error, FromError}; use std::error::{Error, FromError};
use std::fmt; use std::fmt;
use std::io::IoError; use std::old_io::IoError;
use self::HttpError::{HttpMethodError, HttpUriError, HttpVersionError, use self::HttpError::{HttpMethodError, HttpUriError, HttpVersionError,
HttpHeaderError, HttpStatusError, HttpIoError}; HttpHeaderError, HttpStatusError, HttpIoError};

View File

@@ -1,6 +1,6 @@
use std::fmt; use std::fmt;
use std::io::{IoResult, MemReader, MemWriter}; use std::old_io::{IoResult, MemReader, MemWriter};
use std::io::net::ip::SocketAddr; use std::old_io::net::ip::SocketAddr;
use net::{NetworkStream, NetworkConnector}; use net::{NetworkStream, NetworkConnector};
@@ -55,8 +55,8 @@ impl Reader for MockStream {
} }
impl Writer for MockStream { impl Writer for MockStream {
fn write(&mut self, msg: &[u8]) -> IoResult<()> { fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
self.write.write(msg) self.write.write_all(msg)
} }
} }
@@ -86,7 +86,7 @@ macro_rules! mock_connector (
impl ::net::NetworkConnector for $name { impl ::net::NetworkConnector for $name {
type Stream = ::mock::MockStream; type Stream = ::mock::MockStream;
fn connect(&mut self, host: &str, port: u16, scheme: &str) -> ::std::io::IoResult<::mock::MockStream> { fn connect(&mut self, host: &str, port: u16, scheme: &str) -> ::std::old_io::IoResult<::mock::MockStream> {
use std::collections::HashMap; use std::collections::HashMap;
debug!("MockStream::connect({:?}, {:?}, {:?})", host, port, scheme); debug!("MockStream::connect({:?}, {:?}, {:?})", host, port, scheme);
let mut map = HashMap::new(); let mut map = HashMap::new();
@@ -95,10 +95,10 @@ macro_rules! mock_connector (
let key = format!("{}://{}", scheme, host); let key = format!("{}://{}", scheme, host);
// ignore port for now // ignore port for now
match map.get(&&*key) { match map.get(&*key) {
Some(res) => Ok(::mock::MockStream { Some(res) => Ok(::mock::MockStream {
write: ::std::io::MemWriter::new(), write: ::std::old_io::MemWriter::new(),
read: ::std::io::MemReader::new(res.to_string().into_bytes()) read: ::std::old_io::MemReader::new(res.to_string().into_bytes())
}), }),
None => panic!("{:?} doesn't know url {}", stringify!($name), key) None => panic!("{:?} doesn't know url {}", stringify!($name), key)
} }

View File

@@ -1,10 +1,10 @@
//! A collection of traits abstracting over Listeners and Streams. //! A collection of traits abstracting over Listeners and Streams.
use std::any::{Any, TypeId}; use std::any::{Any, TypeId};
use std::fmt; use std::fmt;
use std::io::{IoResult, IoError, ConnectionAborted, InvalidInput, OtherIoError, use std::old_io::{IoResult, IoError, ConnectionAborted, InvalidInput, OtherIoError,
Stream, Listener, Acceptor}; Stream, Listener, Acceptor};
use std::io::net::ip::{SocketAddr, ToSocketAddr, Port}; use std::old_io::net::ip::{SocketAddr, ToSocketAddr, Port};
use std::io::net::tcp::{TcpStream, TcpListener, TcpAcceptor}; use std::old_io::net::tcp::{TcpStream, TcpListener, TcpAcceptor};
use std::mem; use std::mem;
use std::raw::{self, TraitObject}; use std::raw::{self, TraitObject};
use std::sync::Arc; use std::sync::Arc;
@@ -112,7 +112,7 @@ impl Reader for Box<NetworkStream + Send> {
impl Writer for Box<NetworkStream + Send> { impl Writer for Box<NetworkStream + Send> {
#[inline] #[inline]
fn write(&mut self, msg: &[u8]) -> IoResult<()> { (**self).write(msg) } fn write_all(&mut self, msg: &[u8]) -> IoResult<()> { (**self).write_all(msg) }
#[inline] #[inline]
fn flush(&mut self) -> IoResult<()> { (**self).flush() } fn flush(&mut self) -> IoResult<()> { (**self).flush() }
@@ -125,7 +125,7 @@ impl<'a> Reader for &'a mut NetworkStream {
impl<'a> Writer for &'a mut NetworkStream { impl<'a> Writer for &'a mut NetworkStream {
#[inline] #[inline]
fn write(&mut self, msg: &[u8]) -> IoResult<()> { (**self).write(msg) } fn write_all(&mut self, msg: &[u8]) -> IoResult<()> { (**self).write_all(msg) }
#[inline] #[inline]
fn flush(&mut self) -> IoResult<()> { (**self).flush() } fn flush(&mut self) -> IoResult<()> { (**self).flush() }
@@ -282,10 +282,10 @@ impl Reader for HttpStream {
impl Writer for HttpStream { impl Writer for HttpStream {
#[inline] #[inline]
fn write(&mut self, msg: &[u8]) -> IoResult<()> { fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
match *self { match *self {
HttpStream::Http(ref mut inner) => inner.write(msg), HttpStream::Http(ref mut inner) => inner.write_all(msg),
HttpStream::Https(ref mut inner) => inner.write(msg) HttpStream::Https(ref mut inner) => inner.write_all(msg)
} }
} }
#[inline] #[inline]

View File

@@ -1,6 +1,6 @@
//! HTTP Server //! HTTP Server
use std::io::{Listener, EndOfFile, BufferedReader, BufferedWriter}; use std::old_io::{Listener, EndOfFile, BufferedReader, BufferedWriter};
use std::io::net::ip::{IpAddr, Port, SocketAddr}; use std::old_io::net::ip::{IpAddr, Port, SocketAddr};
use std::os; use std::os;
use std::sync::{Arc, TaskPool}; use std::sync::{Arc, TaskPool};
use std::thread::{Builder, JoinGuard}; use std::thread::{Builder, JoinGuard};

View File

@@ -2,8 +2,8 @@
//! //!
//! These are requests that a `hyper::Server` receives, and include its method, //! These are requests that a `hyper::Server` receives, and include its method,
//! target URI, headers, and message body. //! target URI, headers, and message body.
use std::io::IoResult; use std::old_io::IoResult;
use std::io::net::ip::SocketAddr; use std::old_io::net::ip::SocketAddr;
use {HttpResult}; use {HttpResult};
use version::{HttpVersion}; use version::{HttpVersion};
@@ -84,7 +84,7 @@ mod tests {
use mock::MockStream; use mock::MockStream;
use super::Request; use super::Request;
use std::io::net::ip::SocketAddr; use std::old_io::net::ip::SocketAddr;
fn sock(s: &str) -> SocketAddr { fn sock(s: &str) -> SocketAddr {
s.parse().unwrap() s.parse().unwrap()

View File

@@ -2,7 +2,7 @@
//! //!
//! These are responses sent by a `hyper::Server` to clients, after //! These are responses sent by a `hyper::Server` to clients, after
//! receiving a request. //! receiving a request.
use std::io::IoResult; use std::old_io::IoResult;
use time::now_utc; use time::now_utc;
@@ -141,9 +141,9 @@ impl<'a> Response<'a, Streaming> {
} }
impl<'a> Writer for Response<'a, Streaming> { impl<'a> Writer for Response<'a, Streaming> {
fn write(&mut self, msg: &[u8]) -> IoResult<()> { fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
debug!("write {:?} bytes", msg.len()); debug!("write {:?} bytes", msg.len());
self.body.write(msg) self.body.write_all(msg)
} }
fn flush(&mut self) -> IoResult<()> { fn flush(&mut self) -> IoResult<()> {