diff options
author | Avi Weinstock <aweinstock314@gmail.com> | 2015-03-23 14:33:55 -0400 |
---|---|---|
committer | Avi Weinstock <aweinstock314@gmail.com> | 2015-03-23 18:28:44 -0400 |
commit | cf0657a4030a3401845c83fe45c7e466d361292b (patch) | |
tree | 4a6582e75cd273ae8fe4237b0d468d6b64fdf631 | |
parent | 5ce7d8accfc52dd37b19b4400a643a980412bb2f (diff) | |
download | servo-cf0657a4030a3401845c83fe45c7e466d361292b.tar.gz servo-cf0657a4030a3401845c83fe45c7e466d361292b.zip |
Fixed some deprecation errors in components/net.
-rw-r--r-- | components/net/cookie.rs | 6 | ||||
-rw-r--r-- | components/net/file_loader.rs | 32 | ||||
-rw-r--r-- | components/net/lib.rs | 1 |
3 files changed, 18 insertions, 21 deletions
diff --git a/components/net/cookie.rs b/components/net/cookie.rs index a6390bf35c6..46094ac00a3 100644 --- a/components/net/cookie.rs +++ b/components/net/cookie.rs @@ -13,8 +13,9 @@ use time::{Tm, now, at, Timespec}; use url::Url; use std::borrow::ToOwned; use std::i64; -use std::old_io::net::ip::IpAddr; +use std::net::{Ipv4Addr, Ipv6Addr}; use std::time::Duration; +use std::str::FromStr; /// A stored cookie that wraps the definition in cookie-rs. This is used to implement /// various behaviours defined in the spec that rely on an associated request URL, @@ -121,7 +122,8 @@ impl Cookie { } if string.ends_with(domain_string) && string.char_at(string.len()-domain_string.len()-1) == '.' - && string.parse::<IpAddr>().is_err() { + && Ipv4Addr::from_str(string).is_err() + && Ipv6Addr::from_str(string).is_err() { return true; } false diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index 2ee1b3b076d..e35f195a7a1 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -6,28 +6,24 @@ use resource_task::{ProgressMsg, Metadata, LoadData, start_sending, TargetedLoad use resource_task::ProgressMsg::{Payload, Done}; use std::borrow::ToOwned; -use std::old_io as io; -use std::old_io::File; +use std::io; +use std::fs::File; use std::sync::mpsc::Sender; use util::task::spawn_named; static READ_SIZE: uint = 8192; -fn read_all(reader: &mut io::Stream, progress_chan: &Sender<ProgressMsg>) +fn read_all(reader: &mut io::Read, progress_chan: &Sender<ProgressMsg>) -> Result<(), String> { loop { - let mut buf = vec!(); - match reader.push_at_least(READ_SIZE, READ_SIZE, &mut buf) { - Ok(_) => progress_chan.send(Payload(buf)).unwrap(), - Err(e) => match e.kind { - io::EndOfFile => { - if buf.len() > 0 { - progress_chan.send(Payload(buf)).unwrap(); - } - return Ok(()); - } - _ => return Err(e.desc.to_string()), - } + let mut buf = vec![0; READ_SIZE]; + match reader.read(buf.as_mut_slice()) { + Ok(0) => return Ok(()), + Ok(n) => { + buf.truncate(n); + progress_chan.send(Payload(buf)).unwrap(); + }, + Err(e) => return Err(e.description().to_string()), } } } @@ -44,13 +40,13 @@ pub fn factory(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) { let file_path: Result<Path, ()> = url.to_file_path(); match file_path { Ok(file_path) => { - match File::open_mode(&Path::new(file_path), io::Open, io::Read) { + match File::open(&Path::new(file_path)) { Ok(ref mut reader) => { - let res = read_all(reader as &mut io::Stream, &progress_chan); + let res = read_all(reader, &progress_chan); progress_chan.send(Done(res)).unwrap(); } Err(e) => { - progress_chan.send(Done(Err(e.desc.to_string()))).unwrap(); + progress_chan.send(Done(Err(e.description().to_string()))).unwrap(); } } } diff --git a/components/net/lib.rs b/components/net/lib.rs index c7dc87a538c..410e8ab1556 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -8,7 +8,6 @@ #![feature(core)] #![feature(int_uint)] #![feature(io)] -#![feature(old_io)] #![feature(old_path)] #![feature(path)] #![feature(path_ext)] |