aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/fetch/cors_cache.rs
diff options
context:
space:
mode:
authorBastien Orivel <eijebong@bananium.fr>2018-08-27 18:36:52 +0200
committerBastien Orivel <eijebong@bananium.fr>2018-11-01 19:17:36 +0100
commit024b40b39d3848f1a1f7020bd7ed8c901817f09c (patch)
tree27508f102b0973cbae3dca22143ea4aedd349f4b /components/net/fetch/cors_cache.rs
parent95bfaa0a770479fb3bf6bf0b1f85c9ae343e66ff (diff)
downloadservo-024b40b39d3848f1a1f7020bd7ed8c901817f09c.tar.gz
servo-024b40b39d3848f1a1f7020bd7ed8c901817f09c.zip
Update hyper to 0.12
Diffstat (limited to 'components/net/fetch/cors_cache.rs')
-rw-r--r--components/net/fetch/cors_cache.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/components/net/fetch/cors_cache.rs b/components/net/fetch/cors_cache.rs
index 8962dd2c998..95e070cfc8e 100644
--- a/components/net/fetch/cors_cache.rs
+++ b/components/net/fetch/cors_cache.rs
@@ -9,7 +9,8 @@
//! This library will eventually become the core of the Fetch crate
//! with CORSRequest being expanded into FetchRequest (etc)
-use hyper::method::Method;
+use http::header::HeaderName;
+use hyper::Method;
use net_traits::request::{CredentialsMode, Origin, Request};
use servo_url::ServoUrl;
use time::{self, Timespec};
@@ -19,14 +20,14 @@ use time::{self, Timespec};
/// Each entry might pertain to a header or method
#[derive(Clone, Debug)]
pub enum HeaderOrMethod {
- HeaderData(String),
+ HeaderData(HeaderName),
MethodData(Method)
}
impl HeaderOrMethod {
- fn match_header(&self, header_name: &str) -> bool {
+ fn match_header(&self, header_name: &HeaderName) -> bool {
match *self {
- HeaderOrMethod::HeaderData(ref s) => (&**s).eq_ignore_ascii_case(header_name),
+ HeaderOrMethod::HeaderData(ref n) => n == header_name,
_ => false
}
}
@@ -80,7 +81,7 @@ impl CorsCache {
}
fn find_entry_by_header<'a>(&'a mut self, request: &Request,
- header_name: &str) -> Option<&'a mut CorsCacheEntry> {
+ header_name: &HeaderName) -> Option<&'a mut CorsCacheEntry> {
self.cleanup();
self.0.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_header(header_name))
}
@@ -113,7 +114,7 @@ impl CorsCache {
/// Returns true if an entry with a
/// [matching header](https://fetch.spec.whatwg.org/#concept-cache-match-header) is found
- pub fn match_header(&mut self, request: &Request, header_name: &str) -> bool {
+ pub fn match_header(&mut self, request: &Request, header_name: &HeaderName) -> bool {
self.find_entry_by_header(&request, header_name).is_some()
}
@@ -122,13 +123,13 @@ impl CorsCache {
///
/// If not, it will insert an equivalent entry
pub fn match_header_and_update(&mut self, request: &Request,
- header_name: &str, new_max_age: u32) -> bool {
+ header_name: &HeaderName, new_max_age: u32) -> bool {
match self.find_entry_by_header(&request, header_name).map(|e| e.max_age = new_max_age) {
Some(_) => true,
None => {
self.insert(CorsCacheEntry::new(request.origin.clone(), request.current_url(), new_max_age,
request.credentials_mode == CredentialsMode::Include,
- HeaderOrMethod::HeaderData(header_name.to_owned())));
+ HeaderOrMethod::HeaderData(header_name.clone())));
false
}
}