aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/fetch
diff options
context:
space:
mode:
Diffstat (limited to 'components/net/fetch')
-rw-r--r--components/net/fetch/cors_cache.rs2
-rw-r--r--components/net/fetch/request.rs12
-rw-r--r--components/net/fetch/response.rs48
3 files changed, 31 insertions, 31 deletions
diff --git a/components/net/fetch/cors_cache.rs b/components/net/fetch/cors_cache.rs
index f7b63b3b339..b287e7999fe 100644
--- a/components/net/fetch/cors_cache.rs
+++ b/components/net/fetch/cors_cache.rs
@@ -9,7 +9,7 @@
//! This library will eventually become the core of the Fetch crate
//! with CORSRequest being expanded into FetchRequest (etc)
-use http::method::Method;
+use hyper::method::Method;
use std::ascii::AsciiExt;
use std::comm::{Sender, Receiver, channel};
use time;
diff --git a/components/net/fetch/request.rs b/components/net/fetch/request.rs
index 95bdc76ca35..aa53337516b 100644
--- a/components/net/fetch/request.rs
+++ b/components/net/fetch/request.rs
@@ -3,8 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use url::Url;
-use http::method::{Get, Method};
-use http::headers::request::HeaderCollection;
+use hyper::method::{Get, Method};
+use hyper::mime::{Mime, Text, Html, Charset, Utf8};
+use hyper::header::Headers;
+use hyper::header::common::ContentType;
use fetch::cors_cache::CORSCache;
use fetch::response::Response;
@@ -58,7 +60,7 @@ pub enum ResponseTainting {
pub struct Request {
pub method: Method,
pub url: Url,
- pub headers: HeaderCollection,
+ pub headers: Headers,
pub unsafe_request: bool,
pub body: Option<Vec<u8>>,
pub preserve_content_codings: bool,
@@ -87,7 +89,7 @@ impl Request {
Request {
method: Get,
url: url,
- headers: HeaderCollection::new(),
+ headers: Headers::new(),
unsafe_request: false,
body: None,
preserve_content_codings: false,
@@ -116,7 +118,7 @@ impl Request {
"about" => match self.url.non_relative_scheme_data() {
Some(s) if s.as_slice() == "blank" => {
let mut response = Response::new();
- let _ = response.headers.insert_raw("Content-Type".to_string(), b"text/html;charset=utf-8");
+ response.headers.set(ContentType(Mime(Text, Html, vec![(Charset, Utf8)])));
response
},
_ => Response::network_error()
diff --git a/components/net/fetch/response.rs b/components/net/fetch/response.rs
index 7b9034166ee..48a2794aed3 100644
--- a/components/net/fetch/response.rs
+++ b/components/net/fetch/response.rs
@@ -3,11 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use url::Url;
-use http::status::{Status, UnregisteredStatus};
-use http::status::Ok as StatusOk;
-use http::headers::HeaderEnum;
-use http::headers::response::HeaderCollection;
-use std::ascii::OwnedAsciiExt;
+use hyper::status::StatusCode;
+use hyper::status::Ok as StatusOk;
+use hyper::header::Headers;
+use std::ascii::AsciiExt;
use std::comm::Receiver;
/// [Response type](http://fetch.spec.whatwg.org/#concept-response-type)
@@ -57,8 +56,9 @@ pub struct Response {
pub response_type: ResponseType,
pub termination_reason: Option<TerminationReason>,
pub url: Option<Url>,
- pub status: Status,
- pub headers: HeaderCollection,
+ /// `None` can be considered a StatusCode of `0`.
+ pub status: Option<StatusCode>,
+ pub headers: Headers,
pub body: ResponseBody,
/// [Internal response](http://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response is a filtered response
pub internal_response: Option<Box<Response>>,
@@ -70,8 +70,8 @@ impl Response {
response_type: Default,
termination_reason: None,
url: None,
- status: StatusOk,
- headers: HeaderCollection::new(),
+ status: Some(StatusOk),
+ headers: Headers::new(),
body: Empty,
internal_response: None
}
@@ -82,8 +82,8 @@ impl Response {
response_type: Error,
termination_reason: None,
url: None,
- status: UnregisteredStatus(0, "".to_string()),
- headers: HeaderCollection::new(),
+ status: None,
+ headers: Headers::new(),
body: Empty,
internal_response: None
}
@@ -110,32 +110,30 @@ impl Response {
match filter_type {
Default | Error => unreachable!(),
Basic => {
- let mut headers = HeaderCollection::new();
- for h in old_headers.iter() {
- match h.header_name().into_ascii_lower().as_slice() {
- "set-cookie" | "set-cookie2" => {},
- _ => headers.insert(h)
+ let headers = old_headers.iter().filter(|header| {
+ match header.name().to_ascii_lower().as_slice() {
+ "set-cookie" | "set-cookie2" => false,
+ _ => true
}
- }
+ }).collect();
response.headers = headers;
response.response_type = filter_type;
},
CORS => {
- let mut headers = HeaderCollection::new();
- for h in old_headers.iter() {
- match h.header_name().into_ascii_lower().as_slice() {
+ let headers = old_headers.iter().filter(|header| {
+ match header.name().to_ascii_lower().as_slice() {
"cache-control" | "content-language" |
- "content-type" | "expires" | "last-modified" | "Pragma" => {},
+ "content-type" | "expires" | "last-modified" | "Pragma" => false,
// XXXManishearth handle Access-Control-Expose-Headers
- _ => headers.insert(h)
+ _ => true
}
- }
+ }).collect();
response.headers = headers;
response.response_type = filter_type;
},
Opaque => {
- response.headers = HeaderCollection::new();
- response.status = UnregisteredStatus(0, "".to_string());
+ response.headers = Headers::new();
+ response.status = None;
response.body = Empty;
}
}