mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
Update hyper to 0.12
This commit is contained in:
parent
95bfaa0a77
commit
024b40b39d
122 changed files with 3835 additions and 3448 deletions
|
@ -65,9 +65,9 @@ use dom::workletglobalscope::WorkletGlobalScopeInit;
|
|||
use embedder_traits::EmbedderMsg;
|
||||
use euclid::{Point2D, Vector2D, Rect};
|
||||
use fetch::FetchCanceller;
|
||||
use hyper::header::{ContentType, HttpDate, Headers, LastModified};
|
||||
use hyper::header::ReferrerPolicy as ReferrerPolicyHeader;
|
||||
use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use headers_core::HeaderMapExt;
|
||||
use headers_ext::LastModified;
|
||||
use headers_ext::ReferrerPolicy as ReferrerPolicyHeader;
|
||||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::glue::GetWindowProxyClass;
|
||||
|
@ -76,6 +76,7 @@ use js::jsapi::{JSTracer, SetWindowProxyClass};
|
|||
use js::jsval::UndefinedValue;
|
||||
use metrics::{MAX_TASK_NS, PaintTimeMetrics};
|
||||
use microtask::{MicrotaskQueue, Microtask};
|
||||
use mime::{self, Mime};
|
||||
use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId};
|
||||
use msg::constellation_msg::{PipelineNamespace, TopLevelBrowsingContextId};
|
||||
use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg};
|
||||
|
@ -115,6 +116,7 @@ use std::rc::Rc;
|
|||
use std::result::Result;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::SystemTime;
|
||||
use style::thread_state::{self, ThreadState};
|
||||
use task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue};
|
||||
use task_source::TaskSourceName;
|
||||
|
@ -127,7 +129,7 @@ use task_source::performance_timeline::PerformanceTimelineTaskSource;
|
|||
use task_source::remote_event::RemoteEventTaskSource;
|
||||
use task_source::user_interaction::UserInteractionTaskSource;
|
||||
use task_source::websocket::WebsocketTaskSource;
|
||||
use time::{get_time, precise_time_ns, Tm};
|
||||
use time::{at_utc, get_time, precise_time_ns, Timespec};
|
||||
use url::Position;
|
||||
use url::percent_encoding::percent_decode;
|
||||
use webdriver_handlers;
|
||||
|
@ -2611,37 +2613,27 @@ impl ScriptThread {
|
|||
window.init_window_proxy(&window_proxy);
|
||||
|
||||
let last_modified = metadata.headers.as_ref().and_then(|headers| {
|
||||
headers
|
||||
.get()
|
||||
.map(|&LastModified(HttpDate(ref tm))| dom_last_modified(tm))
|
||||
headers.typed_get::<LastModified>()
|
||||
.map(|tm| dom_last_modified(&tm.into()))
|
||||
});
|
||||
|
||||
let content_type = metadata
|
||||
.content_type
|
||||
.as_ref()
|
||||
.map(|&Serde(ContentType(ref mimetype))| mimetype.clone());
|
||||
|
||||
let loader = DocumentLoader::new_with_threads(
|
||||
self.resource_threads.clone(),
|
||||
Some(final_url.clone()),
|
||||
);
|
||||
|
||||
let is_html_document = match metadata.content_type {
|
||||
Some(Serde(ContentType(Mime(
|
||||
TopLevel::Application,
|
||||
SubLevel::Ext(ref sub_level),
|
||||
_,
|
||||
))))
|
||||
if sub_level.ends_with("+xml") =>
|
||||
{
|
||||
IsHTMLDocument::NonHTMLDocument
|
||||
},
|
||||
let content_type: Option<Mime> = metadata.content_type
|
||||
.map(Serde::into_inner)
|
||||
.map(Into::into);
|
||||
|
||||
Some(Serde(ContentType(Mime(TopLevel::Application, SubLevel::Xml, _)))) |
|
||||
Some(Serde(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _)))) => {
|
||||
IsHTMLDocument::NonHTMLDocument
|
||||
},
|
||||
let is_html_document = match content_type {
|
||||
Some(ref mime) if mime.type_() == mime::APPLICATION &&
|
||||
mime.suffix() == Some(mime::XML) => IsHTMLDocument::NonHTMLDocument,
|
||||
|
||||
Some(ref mime) if
|
||||
(mime.type_() == mime::TEXT && mime.subtype() == mime::XML) ||
|
||||
(mime.type_() == mime::APPLICATION && mime.subtype() == mime::XML)
|
||||
=> IsHTMLDocument::NonHTMLDocument,
|
||||
_ => IsHTMLDocument::HTMLDocument,
|
||||
};
|
||||
|
||||
|
@ -2650,28 +2642,25 @@ impl ScriptThread {
|
|||
None => None,
|
||||
};
|
||||
|
||||
let referrer_policy = metadata
|
||||
.headers
|
||||
.as_ref()
|
||||
.map(Serde::deref)
|
||||
.and_then(Headers::get::<ReferrerPolicyHeader>)
|
||||
.map(ReferrerPolicy::from);
|
||||
let referrer_policy = metadata.headers
|
||||
.as_ref()
|
||||
.map(Serde::deref)
|
||||
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
|
||||
.map(ReferrerPolicy::from);
|
||||
|
||||
let document = Document::new(
|
||||
&window,
|
||||
HasBrowsingContext::Yes,
|
||||
Some(final_url.clone()),
|
||||
incomplete.origin,
|
||||
is_html_document,
|
||||
content_type,
|
||||
last_modified,
|
||||
incomplete.activity,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
referrer,
|
||||
referrer_policy,
|
||||
incomplete.canceller,
|
||||
);
|
||||
let document = Document::new(&window,
|
||||
HasBrowsingContext::Yes,
|
||||
Some(final_url.clone()),
|
||||
incomplete.origin,
|
||||
is_html_document,
|
||||
content_type,
|
||||
last_modified,
|
||||
incomplete.activity,
|
||||
DocumentSource::FromParser,
|
||||
loader,
|
||||
referrer,
|
||||
referrer_policy,
|
||||
incomplete.canceller);
|
||||
document.set_ready_state(DocumentReadyState::Loading);
|
||||
|
||||
self.documents
|
||||
|
@ -3112,7 +3101,7 @@ impl ScriptThread {
|
|||
let mut context = ParserContext::new(id, url.clone());
|
||||
|
||||
let mut meta = Metadata::default(url);
|
||||
meta.set_content_type(Some(&mime!(Text / Html)));
|
||||
meta.set_content_type(Some(&mime::TEXT_HTML));
|
||||
|
||||
// If this page load is the result of a javascript scheme url, map
|
||||
// the evaluation result into a response.
|
||||
|
@ -3221,7 +3210,10 @@ impl Drop for ScriptThread {
|
|||
}
|
||||
}
|
||||
|
||||
fn dom_last_modified(tm: &Tm) -> String {
|
||||
fn dom_last_modified(tm: &SystemTime) -> String {
|
||||
let tm = tm.duration_since(SystemTime::UNIX_EPOCH).unwrap();
|
||||
let tm = Timespec::new(tm.as_secs() as i64, 0);
|
||||
let tm = at_utc(tm);
|
||||
tm.to_local()
|
||||
.strftime("%m/%d/%Y %H:%M:%S")
|
||||
.unwrap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue