mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update to url 2.0
This commit is contained in:
parent
ff3f3d30c7
commit
9392180007
26 changed files with 74 additions and 355 deletions
|
@ -25,7 +25,7 @@ serde_derive = "1.0"
|
|||
serde_json = "1.0"
|
||||
servo_geometry = {path = "../geometry"}
|
||||
servo_url = {path = "../url"}
|
||||
url = "1.2"
|
||||
url = "2.0"
|
||||
servo_config_plugins = { path = "../config_plugins" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -14,4 +14,4 @@ crate_type = ["rlib"]
|
|||
[dependencies]
|
||||
crossbeam-channel = "0.3"
|
||||
log = "0.4"
|
||||
ws = "0.8"
|
||||
ws = "0.9"
|
||||
|
|
|
@ -41,7 +41,7 @@ smallvec = "0.6"
|
|||
string_cache = { version = "0.7", optional = true }
|
||||
thin-slice = "0.1.0"
|
||||
time = { version = "0.1.17", optional = true }
|
||||
url = { version = "1.2", optional = true }
|
||||
url = { version = "2.0", optional = true }
|
||||
webrender_api = { git = "https://github.com/servo/webrender", features = ["ipc"], optional = true }
|
||||
xml5ever = { version = "0.14", optional = true }
|
||||
void = "1.0.2"
|
||||
|
|
|
@ -42,6 +42,7 @@ mime_guess = "2.0.0-alpha.6"
|
|||
msg = {path = "../msg"}
|
||||
net_traits = {path = "../net_traits"}
|
||||
openssl = "0.10"
|
||||
percent-encoding = "1.0"
|
||||
pixels = {path = "../pixels"}
|
||||
profile_traits = {path = "../profile_traits"}
|
||||
rayon = "1"
|
||||
|
@ -55,10 +56,10 @@ tokio = "0.1"
|
|||
tokio-timer = "0.2"
|
||||
threadpool = "1.0"
|
||||
time = "0.1.17"
|
||||
url = "1.2"
|
||||
url = "2.0"
|
||||
uuid = {version = "0.7", features = ["v4"]}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
ws = { version = "0.8", features = ["ssl"] }
|
||||
ws = { version = "0.9", features = ["ssl"] }
|
||||
|
||||
[dev-dependencies]
|
||||
std_test_override = { path = "../std_test_override" }
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
use base64;
|
||||
use mime::Mime;
|
||||
use percent_encoding::percent_decode;
|
||||
use servo_url::ServoUrl;
|
||||
use url::percent_encoding::percent_decode;
|
||||
use url::Position;
|
||||
|
||||
pub enum DecodeError {
|
||||
|
|
|
@ -29,13 +29,14 @@ malloc_size_of_derive = "0.1"
|
|||
mime = "0.3"
|
||||
msg = {path = "../msg"}
|
||||
num-traits = "0.2"
|
||||
percent-encoding = "1.0"
|
||||
pixels = {path = "../pixels"}
|
||||
serde = "1.0"
|
||||
servo_arc = {path = "../servo_arc"}
|
||||
servo_config = {path = "../config"}
|
||||
servo_url = {path = "../url"}
|
||||
time = "0.1"
|
||||
url = "1.2"
|
||||
url = "2.0"
|
||||
uuid = {version = "0.7", features = ["v4", "serde"]}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@ extern crate malloc_size_of;
|
|||
extern crate malloc_size_of_derive;
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate url;
|
||||
|
||||
use crate::filemanager_thread::FileManagerThreadMsg;
|
||||
use crate::request::{Request, RequestBuilder};
|
||||
|
@ -35,7 +33,6 @@ use msg::constellation_msg::HistoryStateId;
|
|||
use servo_url::ServoUrl;
|
||||
use std::error::Error;
|
||||
use time::precise_time_ns;
|
||||
use url::percent_encoding;
|
||||
|
||||
pub mod blob_url_store;
|
||||
pub mod filemanager_thread;
|
||||
|
@ -656,7 +653,7 @@ pub fn trim_http_whitespace(mut slice: &[u8]) -> &[u8] {
|
|||
}
|
||||
|
||||
pub fn http_percent_encode(bytes: &[u8]) -> String {
|
||||
define_encode_set! {
|
||||
percent_encoding::define_encode_set! {
|
||||
// This encode set is used for HTTP header values and is defined at
|
||||
// https://tools.ietf.org/html/rfc5987#section-3.2
|
||||
pub HTTP_VALUE = [percent_encoding::SIMPLE_ENCODE_SET] | {
|
||||
|
@ -665,5 +662,5 @@ pub fn http_percent_encode(bytes: &[u8]) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
url::percent_encoding::percent_encode(bytes, HTTP_VALUE).to_string()
|
||||
percent_encoding::percent_encode(bytes, HTTP_VALUE).to_string()
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ msg = {path = "../msg"}
|
|||
net_traits = {path = "../net_traits"}
|
||||
num-traits = "0.2"
|
||||
parking_lot = "0.8"
|
||||
percent-encoding = "1.0"
|
||||
phf = "0.7"
|
||||
pixels = {path = "../pixels"}
|
||||
profile_traits = {path = "../profile_traits"}
|
||||
|
@ -107,7 +108,7 @@ tendril = {version = "0.4.1", features = ["encoding_rs"]}
|
|||
time = "0.1.12"
|
||||
typetag = "0.1"
|
||||
unicode-segmentation = "1.1.0"
|
||||
url = "1.6"
|
||||
url = "2.0"
|
||||
utf-8 = "0.7"
|
||||
uuid = {version = "0.7", features = ["v4"]}
|
||||
xml5ever = {version = "0.14"}
|
||||
|
|
|
@ -133,6 +133,7 @@ use net_traits::CookieSource::NonHTTP;
|
|||
use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
||||
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
|
||||
use num_traits::ToPrimitive;
|
||||
use percent_encoding::percent_decode;
|
||||
use profile_traits::ipc as profile_ipc;
|
||||
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType};
|
||||
use ref_slice::ref_slice;
|
||||
|
@ -163,7 +164,6 @@ use style::shared_lock::SharedRwLock as StyleSharedRwLock;
|
|||
use style::str::{split_html_space_chars, str_join};
|
||||
use style::stylesheet_set::DocumentStylesheetSet;
|
||||
use style::stylesheets::{Origin, OriginSet, Stylesheet};
|
||||
use url::percent_encoding::percent_decode;
|
||||
use url::Host;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ use std::borrow::ToOwned;
|
|||
use std::cell::Cell;
|
||||
use style::attr::AttrValue;
|
||||
use style::str::split_html_space_chars;
|
||||
use url::form_urlencoded::Serializer;
|
||||
use url::UrlQuery;
|
||||
|
||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
||||
pub struct GenerationId(u32);
|
||||
|
@ -463,13 +461,12 @@ impl HTMLFormElement {
|
|||
) {
|
||||
let charset = encoding.name();
|
||||
|
||||
self.set_encoding_override(load_data.url.as_mut_url().query_pairs_mut())
|
||||
.clear()
|
||||
.extend_pairs(
|
||||
form_data
|
||||
.into_iter()
|
||||
.map(|field| (field.name.clone(), field.replace_value(charset))),
|
||||
);
|
||||
self.set_url_query_pairs(
|
||||
&mut load_data.url,
|
||||
form_data
|
||||
.iter()
|
||||
.map(|field| (&*field.name, field.replace_value(charset))),
|
||||
);
|
||||
|
||||
self.plan_to_navigate(load_data, target);
|
||||
}
|
||||
|
@ -492,13 +489,12 @@ impl HTMLFormElement {
|
|||
.typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED));
|
||||
|
||||
let mut url = load_data.url.clone();
|
||||
self.set_encoding_override(url.as_mut_url().query_pairs_mut())
|
||||
.clear()
|
||||
.extend_pairs(
|
||||
form_data
|
||||
.into_iter()
|
||||
.map(|field| (field.name.clone(), field.replace_value(charset))),
|
||||
);
|
||||
self.set_url_query_pairs(
|
||||
&mut url,
|
||||
form_data
|
||||
.iter()
|
||||
.map(|field| (&*field.name, field.replace_value(charset))),
|
||||
);
|
||||
|
||||
url.query().unwrap_or("").to_string().into_bytes()
|
||||
},
|
||||
|
@ -521,13 +517,17 @@ impl HTMLFormElement {
|
|||
self.plan_to_navigate(load_data, target);
|
||||
}
|
||||
|
||||
fn set_encoding_override<'a>(
|
||||
fn set_url_query_pairs<'a>(
|
||||
&self,
|
||||
mut serializer: Serializer<UrlQuery<'a>>,
|
||||
) -> Serializer<UrlQuery<'a>> {
|
||||
url: &mut servo_url::ServoUrl,
|
||||
pairs: impl Iterator<Item = (&'a str, String)>,
|
||||
) {
|
||||
let encoding = self.pick_encoding();
|
||||
serializer.custom_encoding_override(move |s| encoding.encode(s).0);
|
||||
serializer
|
||||
url.as_mut_url()
|
||||
.query_pairs_mut()
|
||||
.encoding_override(Some(&|s| encoding.encode(s).0))
|
||||
.clear()
|
||||
.extend_pairs(pairs);
|
||||
}
|
||||
|
||||
/// [Planned navigation](https://html.spec.whatwg.org/multipage/#planned-navigation)
|
||||
|
|
|
@ -123,6 +123,7 @@ use net_traits::{
|
|||
Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceThreads,
|
||||
ResourceTimingType,
|
||||
};
|
||||
use percent_encoding::percent_decode;
|
||||
use profile_traits::mem::{self as profile_mem, OpaqueSender, ReportsChan};
|
||||
use profile_traits::time::{self as profile_time, profile, ProfilerCategory};
|
||||
use script_layout_interface::message::{self, LayoutThreadInit, Msg, ReflowGoal};
|
||||
|
@ -160,7 +161,6 @@ use std::time::{Duration, SystemTime};
|
|||
use style::dom::OpaqueNode;
|
||||
use style::thread_state::{self, ThreadState};
|
||||
use time::{at_utc, get_time, precise_time_ns, Timespec};
|
||||
use url::percent_encoding::percent_decode;
|
||||
use url::Position;
|
||||
use webrender_api::units::LayoutPixel;
|
||||
use webrender_api::{DocumentId, RenderApiSender};
|
||||
|
|
|
@ -37,7 +37,7 @@ servo_atoms = {path = "../atoms"}
|
|||
servo_url = {path = "../url"}
|
||||
style_traits = {path = "../style_traits", features = ["servo"]}
|
||||
time = "0.1.12"
|
||||
url = "1.2"
|
||||
url = "2.0"
|
||||
webdriver = "0.40"
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webvr_traits = {path = "../webvr_traits"}
|
||||
|
|
|
@ -17,6 +17,5 @@ to_shmem = { path = "../to_shmem" }
|
|||
to_shmem_derive = { path = "../to_shmem_derive" }
|
||||
serde = {version = "1.0", features = ["derive"]}
|
||||
servo_rand = {path = "../rand"}
|
||||
url = "1.2"
|
||||
url_serde = {version = "0.2"}
|
||||
url = {version = "2.0", features = ["serde"]}
|
||||
uuid = {version = "0.7", features = ["v4", "serde"]}
|
||||
|
|
|
@ -30,7 +30,7 @@ use url::{Position, Url};
|
|||
|
||||
pub use url::Host;
|
||||
|
||||
#[derive(Clone, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)]
|
||||
#[derive(Clone, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct ServoUrl(#[ignore_malloc_size_of = "Arc"] Arc<Url>);
|
||||
|
||||
impl ToShmem for ServoUrl {
|
||||
|
@ -222,21 +222,3 @@ impl From<Url> for ServoUrl {
|
|||
ServoUrl::from_url(url)
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::Serialize for ServoUrl {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
url_serde::serialize(&*self.0, serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> serde::Deserialize<'de> for ServoUrl {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
url_serde::deserialize(deserializer).map(Self::from_url)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,7 @@ pub enum ImmutableOrigin {
|
|||
Opaque(OpaqueOrigin),
|
||||
|
||||
/// Consists of the URL's scheme, host and port
|
||||
Tuple(
|
||||
String,
|
||||
#[serde(
|
||||
deserialize_with = "url_serde::deserialize",
|
||||
serialize_with = "url_serde::serialize"
|
||||
)]
|
||||
Host,
|
||||
u16,
|
||||
),
|
||||
Tuple(String, Host, u16),
|
||||
}
|
||||
|
||||
impl ImmutableOrigin {
|
||||
|
|
|
@ -29,6 +29,6 @@ serde_json = "1"
|
|||
script_traits = {path = "../script_traits"}
|
||||
servo_config = {path = "../config"}
|
||||
servo_url = {path = "../url"}
|
||||
url = "1.2"
|
||||
url = "2.0"
|
||||
uuid = {version = "0.7", features = ["v4"]}
|
||||
webdriver = "0.40"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue