Auto merge of #23838 - servo:url-2.0, r=Manishearth

Update the url crate to 2.0

Blocked on:

* [x] https://github.com/housleyjk/ws-rs/pull/283 + undoing corresponding `[patch.crates-io]` entry

Soft-blocked on: (we could add to the crate duplication allow-list instead)

* [x] ~https://github.com/rust-windowing/winit/pull/1066~
  - [x] https://github.com/rust-windowing/winit/pull/1076
* [x] https://github.com/servo/media/pull/288
* [ ] https://github.com/servo/webrender/pull/3720
* [x] https://github.com/gobwas/influent.rs/pull/22
* [ ] https://bugzilla.mozilla.org/show_bug.cgi?id=1568540
  - [x] https://github.com/seanmonstar/warp/pull/260
  - [ ] https://github.com/abonander/multipart/pull/121

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23838)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-08-17 04:14:32 -04:00 committed by GitHub
commit 9bba14cb43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 96 additions and 362 deletions

View file

@ -79,6 +79,7 @@ msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.2"
parking_lot = "0.8"
percent-encoding = "2.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"}

View file

@ -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;

View file

@ -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)

View file

@ -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};