mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Fixed some deprecation errors in components/net.
This commit is contained in:
parent
5ce7d8accf
commit
cf0657a403
3 changed files with 18 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
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();
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
_ => return Err(e.desc.to_string()),
|
||||
}
|
||||
},
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#![feature(core)]
|
||||
#![feature(int_uint)]
|
||||
#![feature(io)]
|
||||
#![feature(old_io)]
|
||||
#![feature(old_path)]
|
||||
#![feature(path)]
|
||||
#![feature(path_ext)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue