Fix warnings in net.

This commit is contained in:
Ms2ger 2015-02-13 11:24:21 +01:00
parent 2ca59b3f5b
commit b25564440d
5 changed files with 20 additions and 14 deletions

View file

@ -100,7 +100,7 @@ impl Cookie {
request_path.chars().filter(|&c| c == '/').count() == 1 { request_path.chars().filter(|&c| c == '/').count() == 1 {
"/".to_owned() "/".to_owned()
} else if request_path.ends_with("/") { } else if request_path.ends_with("/") {
request_path.slice_to(request_path.len()-1).to_owned() request_path[..request_path.len() - 1].to_owned()
} else { } else {
request_path.to_owned() request_path.to_owned()
} }

View file

@ -55,7 +55,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
let mut ct_str = parts[0]; let mut ct_str = parts[0];
if ct_str.ends_with(";base64") { if ct_str.ends_with(";base64") {
is_base64 = true; is_base64 = true;
ct_str = ct_str.slice_to(ct_str.as_bytes().len() - 7); ct_str = &ct_str[..ct_str.as_bytes().len() - 7];
} }
// Parse the content type using rust-http. // Parse the content type using rust-http.

View file

@ -126,7 +126,7 @@ reason: \"certificate verify failed\" }]";
req.headers_mut().set(host); req.headers_mut().set(host);
let (tx, rx) = channel(); let (tx, rx) = channel();
cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx, CookieSource::HTTP)); cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx, CookieSource::HTTP)).unwrap();
if let Some(cookie_list) = rx.recv().unwrap() { if let Some(cookie_list) = rx.recv().unwrap() {
let mut v = Vec::new(); let mut v = Vec::new();
v.push(cookie_list.into_bytes()); v.push(cookie_list.into_bytes());
@ -157,7 +157,7 @@ reason: \"certificate verify failed\" }]";
return; return;
} }
}; };
match writer.write(data.as_slice()) { match writer.write_all(&*data) {
Err(e) => { Err(e) => {
send_error(url, e.desc.to_string(), senders); send_error(url, e.desc.to_string(), senders);
return; return;
@ -201,7 +201,7 @@ reason: \"certificate verify failed\" }]";
if let Ok(cookies) = String::from_utf8(cookie.clone()) { if let Ok(cookies) = String::from_utf8(cookie.clone()) {
cookies_chan.send(ControlMsg::SetCookiesForUrl(url.clone(), cookies_chan.send(ControlMsg::SetCookiesForUrl(url.clone(),
cookies, cookies,
CookieSource::HTTP)); CookieSource::HTTP)).unwrap();
} }
} }
} }

View file

@ -2,12 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(int_uint)]
#![feature(unboxed_closures)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(env)]
#![feature(int_uint)]
#![feature(io)]
#![feature(path)]
#![feature(rustc_private)]
#![feature(std_misc)]
#![feature(unboxed_closures)]
#![allow(missing_copy_implementations)] #![allow(missing_copy_implementations)]
#![allow(unstable)]
extern crate "cookie" as cookie_rs; extern crate "cookie" as cookie_rs;
extern crate collections; extern crate collections;

View file

@ -23,12 +23,12 @@ use hyper::mime::{Mime, Attr};
use url::Url; use url::Url;
use std::borrow::{ToOwned, IntoCow}; use std::borrow::{ToOwned, IntoCow};
use std::collections::HashMap;
use std::env;
use std::mem;
use std::old_io::{BufferedReader, File};
use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::mpsc::{channel, Receiver, Sender};
use std::thunk::Invoke; use std::thunk::Invoke;
use std::collections::HashMap;
use std::old_io::{BufferedReader, File};
use std::mem;
use std::os;
#[cfg(test)] #[cfg(test)]
use std::old_io::{Listener, Acceptor, TimedOut}; use std::old_io::{Listener, Acceptor, TimedOut};
@ -38,7 +38,7 @@ use std::old_io::net::tcp::TcpListener;
static mut HOST_TABLE: Option<*mut HashMap<String, String>> = None; static mut HOST_TABLE: Option<*mut HashMap<String, String>> = None;
pub fn global_init() { pub fn global_init() {
if let Some(host_file_path) = os::getenv("HOST_FILE") { if let Ok(host_file_path) = env::var_string("HOST_FILE") {
//TODO: handle bad file path and corrupted file //TODO: handle bad file path and corrupted file
let path = Path::new(host_file_path); let path = Path::new(host_file_path);
let mut file = BufferedReader::new(File::open(&path)); let mut file = BufferedReader::new(File::open(&path));
@ -291,7 +291,7 @@ impl ResourceManager {
} }
} }
ControlMsg::GetCookiesForUrl(url, consumer, source) => { ControlMsg::GetCookiesForUrl(url, consumer, source) => {
consumer.send(self.cookie_storage.cookies_for_url(&url, source)); consumer.send(self.cookie_storage.cookies_for_url(&url, source)).unwrap();
} }
ControlMsg::Exit => { ControlMsg::Exit => {
break break