Qualify hyper enums.

This commit is contained in:
Ms2ger 2015-01-04 11:53:35 +01:00
parent 3be587606f
commit b16f9cea09
8 changed files with 33 additions and 32 deletions

View file

@ -9,7 +9,7 @@ use geom::rect::Rect;
use geom::size::TypedSize2D; use geom::size::TypedSize2D;
use geom::scale_factor::ScaleFactor; use geom::scale_factor::ScaleFactor;
use hyper::header::Headers; use hyper::header::Headers;
use hyper::method::{Method, Get}; use hyper::method::Method;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use servo_util::cursor::Cursor; use servo_util::cursor::Cursor;
use servo_util::geometry::{PagePx, ViewportPx}; use servo_util::geometry::{PagePx, ViewportPx};
@ -228,7 +228,7 @@ impl LoadData {
pub fn new(url: Url) -> LoadData { pub fn new(url: Url) -> LoadData {
LoadData { LoadData {
url: url, url: url,
method: Get, method: Method::Get,
headers: Headers::new(), headers: Headers::new(),
data: None, data: None,
} }

View file

@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use url::Url; use url::Url;
use hyper::method::{Get, Method}; use hyper::method::Method;
use hyper::mime::{Mime, Text, Html, Charset, Utf8}; use hyper::mime::{mod, Mime};
use hyper::header::Headers; use hyper::header::Headers;
use hyper::header::common::ContentType; use hyper::header::common::ContentType;
use fetch::cors_cache::CORSCache; use fetch::cors_cache::CORSCache;
@ -87,7 +87,7 @@ pub struct Request {
impl Request { impl Request {
pub fn new(url: Url, context: Context) -> Request { pub fn new(url: Url, context: Context) -> Request {
Request { Request {
method: Get, method: Method::Get,
url: url, url: url,
headers: Headers::new(), headers: Headers::new(),
unsafe_request: false, unsafe_request: false,
@ -118,7 +118,9 @@ impl Request {
"about" => match self.url.non_relative_scheme_data() { "about" => match self.url.non_relative_scheme_data() {
Some(s) if s.as_slice() == "blank" => { Some(s) if s.as_slice() == "blank" => {
let mut response = Response::new(); let mut response = Response::new();
response.headers.set(ContentType(Mime(Text, Html, vec![(Charset, Utf8)]))); response.headers.set(ContentType(Mime(
mime::TopLevel::Text, mime::SubLevel::Html,
vec![(mime::Attr::Charset, mime::Value::Utf8)])));
response response
}, },
_ => Response::network_error() _ => Response::network_error()

View file

@ -4,7 +4,6 @@
use url::Url; use url::Url;
use hyper::status::StatusCode; use hyper::status::StatusCode;
use hyper::status::Ok as StatusOk;
use hyper::header::Headers; use hyper::header::Headers;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::comm::Receiver; use std::comm::Receiver;
@ -70,7 +69,7 @@ impl Response {
response_type: ResponseType::Default, response_type: ResponseType::Default,
termination_reason: None, termination_reason: None,
url: None, url: None,
status: Some(StatusOk), status: Some(StatusCode::Ok),
headers: Headers::new(), headers: Headers::new(),
body: ResponseBody::Empty, body: ResponseBody::Empty,
internal_response: None internal_response: None

View file

@ -9,8 +9,8 @@ use log;
use std::collections::HashSet; use std::collections::HashSet;
use hyper::client::Request; use hyper::client::Request;
use hyper::header::common::{ContentLength, ContentType, Host, Location}; use hyper::header::common::{ContentLength, ContentType, Host, Location};
use hyper::method::{Get, Head}; use hyper::method::Method;
use hyper::status::Redirection; use hyper::status::StatusClass;
use std::io::Reader; use std::io::Reader;
use servo_util::task::spawn_named; use servo_util::task::spawn_named;
use url::{Url, UrlParser}; use url::{Url, UrlParser};
@ -108,7 +108,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
}, },
None => { None => {
match load_data.method { match load_data.method {
Get | Head => (), Method::Get | Method::Head => (),
_ => req.headers_mut().set(ContentLength(0)) _ => req.headers_mut().set(ContentLength(0))
} }
match req.start() { match req.start() {
@ -136,7 +136,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) {
} }
} }
if response.status.class() == Redirection { if response.status.class() == StatusClass::Redirection {
match response.headers.get::<Location>() { match response.headers.get::<Location>() {
Some(&Location(ref new_url)) => { Some(&Location(ref new_url)) => {
// CORS (http://fetch.spec.whatwg.org/#http-fetch, status section, point 9, 10) // CORS (http://fetch.spec.whatwg.org/#http-fetch, status section, point 9, 10)

View file

@ -16,8 +16,8 @@ use servo_util::task::spawn_named;
use hyper::header::common::UserAgent; use hyper::header::common::UserAgent;
use hyper::header::Headers; use hyper::header::Headers;
use hyper::http::RawStatus; use hyper::http::RawStatus;
use hyper::method::{Method, Get}; use hyper::method::Method;
use hyper::mime::{Mime, Charset}; use hyper::mime::{Mime, Attr};
use url::Url; use url::Url;
use std::comm::{channel, Receiver, Sender}; use std::comm::{channel, Receiver, Sender};
@ -43,7 +43,7 @@ impl LoadData {
pub fn new(url: Url, consumer: Sender<LoadResponse>) -> LoadData { pub fn new(url: Url, consumer: Sender<LoadResponse>) -> LoadData {
LoadData { LoadData {
url: url, url: url,
method: Get, method: Method::Get,
headers: Headers::new(), headers: Headers::new(),
data: None, data: None,
cors: None, cors: None,
@ -97,7 +97,7 @@ impl Metadata {
Some(&Mime(ref type_, ref subtype, ref parameters)) => { Some(&Mime(ref type_, ref subtype, ref parameters)) => {
self.content_type = Some((type_.to_string(), subtype.to_string())); self.content_type = Some((type_.to_string(), subtype.to_string()));
for &(ref k, ref v) in parameters.iter() { for &(ref k, ref v) in parameters.iter() {
if &Charset == k { if &Attr::Charset == k {
self.charset = Some(v.to_string()); self.charset = Some(v.to_string());
} }
} }

View file

@ -18,10 +18,10 @@ use time::{now, Timespec};
use hyper::header::{Headers, Header, HeaderFormat, HeaderView}; use hyper::header::{Headers, Header, HeaderFormat, HeaderView};
use hyper::header::common::util as header_util; use hyper::header::common::util as header_util;
use hyper::client::Request; use hyper::client::Request;
use hyper::mime::{mod, Mime}; use hyper::mime::{Mime, TopLevel, SubLevel};
use hyper::header::common::{ContentType, Host}; use hyper::header::common::{ContentType, Host};
use hyper::method::{Method, Get, Head, Post, Options}; use hyper::method::Method;
use hyper::status::Success; use hyper::status::StatusClass::Success;
use url::{SchemeData, Url}; use url::{SchemeData, Url};
@ -118,7 +118,7 @@ impl CORSRequest {
let mut cors_response = CORSResponse::new(); let mut cors_response = CORSResponse::new();
let mut preflight = self.clone(); // Step 1 let mut preflight = self.clone(); // Step 1
preflight.method = Options; // Step 2 preflight.method = Method::Options; // Step 2
preflight.headers = Headers::new(); // Step 3 preflight.headers = Headers::new(); // Step 3
// Step 4 // Step 4
preflight.headers.set(AccessControlRequestMethod(self.method.clone())); preflight.headers.set(AccessControlRequestMethod(self.method.clone()));
@ -364,9 +364,9 @@ fn is_simple_header(h: &HeaderView) -> bool {
match h.name().to_ascii_lower().as_slice() { match h.name().to_ascii_lower().as_slice() {
"accept" | "accept-language" | "content-language" => true, "accept" | "accept-language" | "content-language" => true,
"content-type" => match h.value() { "content-type" => match h.value() {
Some(&ContentType(Mime(mime::Text, mime::Plain, _))) | Some(&ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) |
Some(&ContentType(Mime(mime::Application, mime::WwwFormUrlEncoded, _))) | Some(&ContentType(Mime(TopLevel::Application, SubLevel::WwwFormUrlEncoded, _))) |
Some(&ContentType(Mime(mime::Multipart, mime::FormData, _))) => true, Some(&ContentType(Mime(TopLevel::Multipart, SubLevel::FormData, _))) => true,
_ => false _ => false
@ -377,7 +377,7 @@ fn is_simple_header(h: &HeaderView) -> bool {
fn is_simple_method(m: &Method) -> bool { fn is_simple_method(m: &Method) -> bool {
match *m { match *m {
Get | Head | Post => true, Method::Get | Method::Head | Method::Post => true,
_ => false _ => false
} }
} }

View file

@ -20,7 +20,7 @@ use dom::htmlelement::HTMLElement;
use dom::htmlinputelement::HTMLInputElement; use dom::htmlinputelement::HTMLInputElement;
use dom::htmltextareaelement::HTMLTextAreaElement; use dom::htmltextareaelement::HTMLTextAreaElement;
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node}; use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
use hyper::method::Post; use hyper::method::Method;
use servo_msg::constellation_msg::LoadData; use servo_msg::constellation_msg::LoadData;
use servo_util::str::DOMString; use servo_util::str::DOMString;
use script_task::{ScriptChan, ScriptMsg}; use script_task::{ScriptChan, ScriptMsg};
@ -195,7 +195,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
load_data.url.query = Some(parsed_data); load_data.url.query = Some(parsed_data);
}, },
("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => { ("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => {
load_data.method = Post; load_data.method = Method::Post;
load_data.data = Some(parsed_data.into_bytes()); load_data.data = Some(parsed_data.into_bytes());
}, },
// https://html.spec.whatwg.org/multipage/forms.html#submit-get-action // https://html.spec.whatwg.org/multipage/forms.html#submit-get-action

View file

@ -36,7 +36,7 @@ use hyper::header::Headers;
use hyper::header::common::{Accept, ContentLength, ContentType}; use hyper::header::common::{Accept, ContentLength, ContentType};
use hyper::http::RawStatus; use hyper::http::RawStatus;
use hyper::mime::{mod, Mime}; use hyper::mime::{mod, Mime};
use hyper::method::{Method, Get, Head, Connect, Trace, Extension}; use hyper::method::Method;
use js::jsapi::{JS_ParseJSON, JSContext}; use js::jsapi::{JS_ParseJSON, JSContext};
use js::jsapi::JS_ClearPendingException; use js::jsapi::JS_ClearPendingException;
@ -173,7 +173,7 @@ impl XMLHttpRequest {
response_xml: Default::default(), response_xml: Default::default(),
response_headers: DOMRefCell::new(Headers::new()), response_headers: DOMRefCell::new(Headers::new()),
request_method: DOMRefCell::new(Get), request_method: DOMRefCell::new(Method::Get),
request_url: DOMRefCell::new(None), request_url: DOMRefCell::new(None),
request_headers: DOMRefCell::new(Headers::new()), request_headers: DOMRefCell::new(Headers::new()),
request_body_len: Cell::new(0), request_body_len: Cell::new(0),
@ -360,8 +360,8 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
// Step 2 // Step 2
match maybe_method { match maybe_method {
// Step 4 // Step 4
Some(Connect) | Some(Trace) => Err(Security), Some(Method::Connect) | Some(Method::Trace) => Err(Security),
Some(Extension(ref t)) if t.as_slice() == "TRACK" => Err(Security), Some(Method::Extension(ref t)) if t.as_slice() == "TRACK" => Err(Security),
Some(_) if method.is_token() => { Some(_) if method.is_token() => {
*self.request_method.borrow_mut() = maybe_method.unwrap(); *self.request_method.borrow_mut() = maybe_method.unwrap();
@ -493,7 +493,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
} }
let data = match *self.request_method.borrow() { let data = match *self.request_method.borrow() {
Get | Head => None, // Step 3 Method::Get | Method::Head => None, // Step 3
_ => data _ => data
}; };
let extracted = data.as_ref().map(|d| d.extract()); let extracted = data.as_ref().map(|d| d.extract());
@ -955,7 +955,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
match self.response_headers.borrow().get() { match self.response_headers.borrow().get() {
Some(&ContentType(mime::Mime(_, _, ref params))) => { Some(&ContentType(mime::Mime(_, _, ref params))) => {
for &(ref name, ref value) in params.iter() { for &(ref name, ref value) in params.iter() {
if name == &mime::Charset { if name == &mime::Attr::Charset {
encoding = encoding_from_whatwg_label(value.to_string().as_slice()).unwrap_or(encoding); encoding = encoding_from_whatwg_label(value.to_string().as_slice()).unwrap_or(encoding);
} }
} }