diff options
Diffstat (limited to 'components/net/fetch')
-rw-r--r-- | components/net/fetch/cors_cache.rs | 26 | ||||
-rw-r--r-- | components/net/fetch/request.rs | 10 | ||||
-rw-r--r-- | components/net/fetch/response.rs | 14 |
3 files changed, 25 insertions, 25 deletions
diff --git a/components/net/fetch/cors_cache.rs b/components/net/fetch/cors_cache.rs index 23a6a8450e5..e3b79b48c24 100644 --- a/components/net/fetch/cors_cache.rs +++ b/components/net/fetch/cors_cache.rs @@ -11,7 +11,7 @@ use hyper::method::Method; use std::ascii::AsciiExt; -use std::comm::{Sender, Receiver, channel}; +use std::sync::mpsc::{Sender, Receiver, channel}; use time; use time::{now, Timespec}; use url::Url; @@ -19,7 +19,7 @@ use url::Url; /// Union type for CORS cache entries /// /// Each entry might pertain to a header or method -#[deriving(Clone)] +#[derive(Clone)] pub enum HeaderOrMethod { HeaderData(String), MethodData(Method) @@ -42,7 +42,7 @@ impl HeaderOrMethod { } /// An entry in the CORS cache -#[deriving(Clone)] +#[derive(Clone)] pub struct CORSCacheEntry { pub origin: Url, pub url: Url, @@ -100,7 +100,7 @@ pub trait CORSCache { } /// A simple, vector-based CORS Cache -#[deriving(Clone)] +#[derive(Clone)] #[unstable = "This might later be replaced with a HashMap-like entity, though that requires a separate Origin struct"] pub struct BasicCORSCache(Vec<CORSCacheEntry>); @@ -207,43 +207,43 @@ impl CORSCache for CORSCacheSender { fn clear (&mut self, request: CacheRequestDetails) { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::Clear(request, tx)); - let _ = rx.recv_opt(); + let _ = rx.recv(); } fn cleanup(&mut self) { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::Cleanup(tx)); - let _ = rx.recv_opt(); + let _ = rx.recv(); } fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_string(), tx)); - rx.recv_opt().unwrap_or(false) + rx.recv().unwrap_or(false) } fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: uint) -> bool { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_string(), new_max_age, tx)); - rx.recv_opt().unwrap_or(false) + rx.recv().unwrap_or(false) } fn match_method(&mut self, request: CacheRequestDetails, method: Method) -> bool { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::MatchMethod(request, method, tx)); - rx.recv_opt().unwrap_or(false) + rx.recv().unwrap_or(false) } fn match_method_and_update(&mut self, request: CacheRequestDetails, method: Method, new_max_age: uint) -> bool { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::MatchMethodUpdate(request, method, new_max_age, tx)); - rx.recv_opt().unwrap_or(false) + rx.recv().unwrap_or(false) } fn insert(&mut self, entry: CORSCacheEntry) { let (tx, rx) = channel(); self.send(CORSCacheTaskMsg::Insert(entry, tx)); - let _ = rx.recv_opt(); + let _ = rx.recv(); } } @@ -254,7 +254,7 @@ impl CORSCache for CORSCacheSender { /// let task = CORSCacheTask::new(); /// let builder = TaskBuilder::new().named("XHRTask"); /// let mut sender = task.get_sender(); -/// builder.spawn(proc() { task.run() }); +/// builder.spawn(move || { task.run() }); /// sender.insert(CORSCacheEntry::new(/* parameters here */)); /// ``` pub struct CORSCacheTask { @@ -284,7 +284,7 @@ impl CORSCacheTask { /// Send ExitMsg to the associated Sender to exit pub fn run(&mut self) { loop { - match self.receiver.recv() { + match self.receiver.recv().unwrap() { CORSCacheTaskMsg::Clear(request, tx) => { self.cache.clear(request); tx.send(()); diff --git a/components/net/fetch/request.rs b/components/net/fetch/request.rs index 050ed9b892b..1c7b51566ad 100644 --- a/components/net/fetch/request.rs +++ b/components/net/fetch/request.rs @@ -11,7 +11,7 @@ use fetch::cors_cache::CORSCache; use fetch::response::Response; /// A [request context](http://fetch.spec.whatwg.org/#concept-request-context) -#[deriving(Copy)] +#[derive(Copy)] pub enum Context { Audio, Beacon, CSPreport, Download, Embed, Eventsource, Favicon, Fetch, Font, Form, Frame, Hyperlink, IFrame, Image, @@ -21,7 +21,7 @@ pub enum Context { } /// A [request context frame type](http://fetch.spec.whatwg.org/#concept-request-context-frame-type) -#[deriving(Copy)] +#[derive(Copy)] pub enum ContextFrameType { Auxiliary, TopLevel, @@ -37,7 +37,7 @@ pub enum Referer { } /// A [request mode](http://fetch.spec.whatwg.org/#concept-request-mode) -#[deriving(Copy)] +#[derive(Copy)] pub enum RequestMode { SameOrigin, NoCORS, @@ -46,7 +46,7 @@ pub enum RequestMode { } /// Request [credentials mode](http://fetch.spec.whatwg.org/#concept-request-credentials-mode) -#[deriving(Copy)] +#[derive(Copy)] pub enum CredentialsMode { Omit, CredentialsSameOrigin, @@ -54,7 +54,7 @@ pub enum CredentialsMode { } /// [Response tainting](http://fetch.spec.whatwg.org/#concept-request-response-tainting) -#[deriving(Copy)] +#[derive(Copy)] pub enum ResponseTainting { Basic, CORSTainting, diff --git a/components/net/fetch/response.rs b/components/net/fetch/response.rs index 2c1817de338..7380f3e7ad6 100644 --- a/components/net/fetch/response.rs +++ b/components/net/fetch/response.rs @@ -6,10 +6,10 @@ use url::Url; use hyper::status::StatusCode; use hyper::header::Headers; use std::ascii::AsciiExt; -use std::comm::Receiver; +use std::sync::mpsc::Receiver; /// [Response type](http://fetch.spec.whatwg.org/#concept-response-type) -#[deriving(Clone, PartialEq, Copy)] +#[derive(Clone, PartialEq, Copy)] pub enum ResponseType { Basic, CORS, @@ -19,7 +19,7 @@ pub enum ResponseType { } /// [Response termination reason](http://fetch.spec.whatwg.org/#concept-response-termination-reason) -#[deriving(Clone, Copy)] +#[derive(Clone, Copy)] pub enum TerminationReason { EndUserAbort, Fatal, @@ -29,7 +29,7 @@ pub enum TerminationReason { /// The response body can still be pushed to after fetch /// This provides a way to store unfinished response bodies #[unstable = "I haven't yet decided exactly how the interface for this will be"] -#[deriving(Clone)] +#[derive(Clone)] pub enum ResponseBody { Empty, // XXXManishearth is this necessary, or is Done(vec![]) enough? Receiving(Vec<u8>), @@ -50,7 +50,7 @@ pub struct ResponseLoader { } /// A [Response](http://fetch.spec.whatwg.org/#concept-response) as defined by the Fetch spec -#[deriving(Clone)] +#[derive(Clone)] pub struct Response { pub response_type: ResponseType, pub termination_reason: Option<TerminationReason>, @@ -110,7 +110,7 @@ impl Response { ResponseType::Default | ResponseType::Error => unreachable!(), ResponseType::Basic => { let headers = old_headers.iter().filter(|header| { - match header.name().to_ascii_lower().as_slice() { + match header.name().to_ascii_lowercase().as_slice() { "set-cookie" | "set-cookie2" => false, _ => true } @@ -120,7 +120,7 @@ impl Response { }, ResponseType::CORS => { let headers = old_headers.iter().filter(|header| { - match header.name().to_ascii_lower().as_slice() { + match header.name().to_ascii_lowercase().as_slice() { "cache-control" | "content-language" | "content-type" | "expires" | "last-modified" | "Pragma" => false, // XXXManishearth handle Access-Control-Expose-Headers |