aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/net_traits/filemanager_thread.rs35
-rw-r--r--components/net_traits/image/base.rs48
-rw-r--r--components/net_traits/image_cache.rs15
-rw-r--r--components/net_traits/lib.rs137
-rw-r--r--components/net_traits/pub_domains.rs17
-rw-r--r--components/net_traits/quality.rs10
-rw-r--r--components/net_traits/request.rs46
-rw-r--r--components/net_traits/response.rs39
-rw-r--r--components/net_traits/storage_thread.rs8
-rw-r--r--components/net_traits/tests/pub_domains.rs5
10 files changed, 229 insertions, 131 deletions
diff --git a/components/net_traits/filemanager_thread.rs b/components/net_traits/filemanager_thread.rs
index 5dd37953995..a2cb6cce29d 100644
--- a/components/net_traits/filemanager_thread.rs
+++ b/components/net_traits/filemanager_thread.rs
@@ -114,21 +114,46 @@ pub struct SelectedFile {
#[derive(Debug, Deserialize, Serialize)]
pub enum FileManagerThreadMsg {
/// Select a single file. Last field is pre-selected file path for testing
- SelectFile(Vec<FilterPattern>, IpcSender<FileManagerResult<SelectedFile>>, FileOrigin, Option<String>),
+ SelectFile(
+ Vec<FilterPattern>,
+ IpcSender<FileManagerResult<SelectedFile>>,
+ FileOrigin,
+ Option<String>,
+ ),
/// Select multiple files. Last field is pre-selected file paths for testing
- SelectFiles(Vec<FilterPattern>, IpcSender<FileManagerResult<Vec<SelectedFile>>>, FileOrigin, Option<Vec<String>>),
+ SelectFiles(
+ Vec<FilterPattern>,
+ IpcSender<FileManagerResult<Vec<SelectedFile>>>,
+ FileOrigin,
+ Option<Vec<String>>,
+ ),
/// Read FileID-indexed file in chunks, optionally check URL validity based on boolean flag
- ReadFile(IpcSender<FileManagerResult<ReadFileProgress>>, Uuid, bool, FileOrigin),
+ ReadFile(
+ IpcSender<FileManagerResult<ReadFileProgress>>,
+ Uuid,
+ bool,
+ FileOrigin,
+ ),
/// Add an entry as promoted memory-based blob and send back the associated FileID
/// as part of a valid/invalid Blob URL depending on the boolean flag
- PromoteMemory(BlobBuf, bool, IpcSender<Result<Uuid, BlobURLStoreError>>, FileOrigin),
+ PromoteMemory(
+ BlobBuf,
+ bool,
+ IpcSender<Result<Uuid, BlobURLStoreError>>,
+ FileOrigin,
+ ),
/// Add a sliced entry pointing to the parent FileID, and send back the associated FileID
/// as part of a valid Blob URL
- AddSlicedURLEntry(Uuid, RelativePos, IpcSender<Result<Uuid, BlobURLStoreError>>, FileOrigin),
+ AddSlicedURLEntry(
+ Uuid,
+ RelativePos,
+ IpcSender<Result<Uuid, BlobURLStoreError>>,
+ FileOrigin,
+ ),
/// Decrease reference count and send back the acknowledgement
DecRef(Uuid, FileOrigin, IpcSender<Result<(), BlobURLStoreError>>),
diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs
index 40d79b9ea74..d09131341d3 100644
--- a/components/net_traits/image/base.rs
+++ b/components/net_traits/image/base.rs
@@ -33,8 +33,11 @@ pub struct Image {
impl fmt::Debug for Image {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Image {{ width: {}, height: {}, format: {:?}, ..., id: {:?} }}",
- self.width, self.height, self.format, self.id)
+ write!(
+ f,
+ "Image {{ width: {}, height: {}, format: {:?}, ..., id: {:?} }}",
+ self.width, self.height, self.format, self.id
+ )
}
}
@@ -58,32 +61,29 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
debug!("{}", msg);
None
},
- Ok(_) => {
- match piston_image::load_from_memory(buffer) {
- Ok(image) => {
- let mut rgba = match image {
- DynamicImage::ImageRgba8(rgba) => rgba,
- image => image.to_rgba(),
- };
- pixels::byte_swap_colors_inplace(&mut *rgba);
- Some(Image {
- width: rgba.width(),
- height: rgba.height(),
- format: PixelFormat::BGRA8,
- bytes: IpcSharedMemory::from_bytes(&*rgba),
- id: None,
- })
- },
- Err(e) => {
- debug!("Image decoding error: {:?}", e);
- None
- },
- }
+ Ok(_) => match piston_image::load_from_memory(buffer) {
+ Ok(image) => {
+ let mut rgba = match image {
+ DynamicImage::ImageRgba8(rgba) => rgba,
+ image => image.to_rgba(),
+ };
+ pixels::byte_swap_colors_inplace(&mut *rgba);
+ Some(Image {
+ width: rgba.width(),
+ height: rgba.height(),
+ format: PixelFormat::BGRA8,
+ bytes: IpcSharedMemory::from_bytes(&*rgba),
+ id: None,
+ })
+ },
+ Err(e) => {
+ debug!("Image decoding error: {:?}", e);
+ None
+ },
},
}
}
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
pub fn detect_image_format(buffer: &[u8]) -> Result<ImageFormat, &str> {
if is_gif(buffer) {
diff --git a/components/net_traits/image_cache.rs b/components/net_traits/image_cache.rs
index ca6df6ee516..6e7f55d2233 100644
--- a/components/net_traits/image_cache.rs
+++ b/components/net_traits/image_cache.rs
@@ -101,16 +101,19 @@ pub enum UsePlaceholder {
// ======================================================================
pub trait ImageCache: Sync + Send {
- fn new(webrender_api: webrender_api::RenderApi) -> Self where Self: Sized;
+ fn new(webrender_api: webrender_api::RenderApi) -> Self
+ where
+ Self: Sized;
/// Return any available metadata or image for the given URL,
/// or an indication that the image is not yet available if it is in progress,
/// or else reserve a slot in the cache for the URL if the consumer can request images.
- fn find_image_or_metadata(&self,
- url: ServoUrl,
- use_placeholder: UsePlaceholder,
- can_request: CanRequestImages)
- -> Result<ImageOrMetadataAvailable, ImageState>;
+ fn find_image_or_metadata(
+ &self,
+ url: ServoUrl,
+ use_placeholder: UsePlaceholder,
+ can_request: CanRequestImages,
+ ) -> Result<ImageOrMetadataAvailable, ImageState>;
/// Add a new listener for the given pending image id. If the image is already present,
/// the responder will still receive the expected response.
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index 5a6a1364fbf..f3e4a0c0858 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
#![deny(unsafe_code)]
extern crate cookie as cookie_rs;
@@ -14,18 +13,24 @@ extern crate hyper;
extern crate hyper_serde;
extern crate image as piston_image;
extern crate ipc_channel;
-#[macro_use] extern crate lazy_static;
-#[macro_use] extern crate log;
-#[macro_use] extern crate malloc_size_of;
-#[macro_use] extern crate malloc_size_of_derive;
+#[macro_use]
+extern crate lazy_static;
+#[macro_use]
+extern crate log;
+#[macro_use]
+extern crate malloc_size_of;
+#[macro_use]
+extern crate malloc_size_of_derive;
extern crate mime;
extern crate msg;
extern crate num_traits;
extern crate pixels;
-#[macro_use] extern crate serde;
+#[macro_use]
+extern crate serde;
extern crate servo_arc;
extern crate servo_url;
-#[macro_use] extern crate url;
+#[macro_use]
+extern crate url;
extern crate uuid;
extern crate webrender_api;
@@ -86,18 +91,26 @@ pub enum LoadContext {
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct CustomResponse {
#[ignore_malloc_size_of = "Defined in hyper"]
- #[serde(deserialize_with = "::hyper_serde::deserialize",
- serialize_with = "::hyper_serde::serialize")]
+ #[serde(
+ deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize"
+ )]
pub headers: HeaderMap,
#[ignore_malloc_size_of = "Defined in hyper"]
- #[serde(deserialize_with = "::hyper_serde::deserialize",
- serialize_with = "::hyper_serde::serialize")]
+ #[serde(
+ deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize"
+ )]
pub raw_status: (StatusCode, String),
pub body: Vec<u8>,
}
impl CustomResponse {
- pub fn new(headers: HeaderMap, raw_status: (StatusCode, String), body: Vec<u8>) -> CustomResponse {
+ pub fn new(
+ headers: HeaderMap,
+ raw_status: (StatusCode, String),
+ body: Vec<u8>,
+ ) -> CustomResponse {
CustomResponse {
headers: headers,
raw_status: raw_status,
@@ -137,22 +150,18 @@ pub enum ReferrerPolicy {
impl From<ReferrerPolicyHeader> for ReferrerPolicy {
fn from(policy: ReferrerPolicyHeader) -> Self {
match policy {
- ReferrerPolicyHeader::NO_REFERRER =>
- ReferrerPolicy::NoReferrer,
- ReferrerPolicyHeader::NO_REFERRER_WHEN_DOWNGRADE =>
- ReferrerPolicy::NoReferrerWhenDowngrade,
- ReferrerPolicyHeader::SAME_ORIGIN =>
- ReferrerPolicy::SameOrigin,
- ReferrerPolicyHeader::ORIGIN =>
- ReferrerPolicy::Origin,
- ReferrerPolicyHeader::ORIGIN_WHEN_CROSS_ORIGIN =>
- ReferrerPolicy::OriginWhenCrossOrigin,
- ReferrerPolicyHeader::UNSAFE_URL =>
- ReferrerPolicy::UnsafeUrl,
- ReferrerPolicyHeader::STRICT_ORIGIN =>
- ReferrerPolicy::StrictOrigin,
- ReferrerPolicyHeader::STRICT_ORIGIN_WHEN_CROSS_ORIGIN =>
- ReferrerPolicy::StrictOriginWhenCrossOrigin,
+ ReferrerPolicyHeader::NO_REFERRER => ReferrerPolicy::NoReferrer,
+ ReferrerPolicyHeader::NO_REFERRER_WHEN_DOWNGRADE => {
+ ReferrerPolicy::NoReferrerWhenDowngrade
+ },
+ ReferrerPolicyHeader::SAME_ORIGIN => ReferrerPolicy::SameOrigin,
+ ReferrerPolicyHeader::ORIGIN => ReferrerPolicy::Origin,
+ ReferrerPolicyHeader::ORIGIN_WHEN_CROSS_ORIGIN => ReferrerPolicy::OriginWhenCrossOrigin,
+ ReferrerPolicyHeader::UNSAFE_URL => ReferrerPolicy::UnsafeUrl,
+ ReferrerPolicyHeader::STRICT_ORIGIN => ReferrerPolicy::StrictOrigin,
+ ReferrerPolicyHeader::STRICT_ORIGIN_WHEN_CROSS_ORIGIN => {
+ ReferrerPolicy::StrictOriginWhenCrossOrigin
+ },
}
}
}
@@ -198,7 +207,7 @@ pub enum FilteredMetadata {
Basic(Metadata),
Cors(Metadata),
Opaque,
- OpaqueRedirect
+ OpaqueRedirect,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -244,7 +253,6 @@ impl FetchTaskTarget for IpcSender<FetchResponseMsg> {
}
}
-
pub trait Action<Listener> {
fn process(self, listener: &mut Listener);
}
@@ -271,7 +279,8 @@ pub type IpcSendResult = Result<(), IpcError>;
/// used by net_traits::ResourceThreads to ease the use its IpcSender sub-fields
/// XXX: If this trait will be used more in future, some auto derive might be appealing
pub trait IpcSend<T>
- where T: serde::Serialize + for<'de> serde::Deserialize<'de>,
+where
+ T: serde::Serialize + for<'de> serde::Deserialize<'de>,
{
/// send message T
fn send(&self, T) -> IpcSendResult;
@@ -342,9 +351,7 @@ pub enum WebSocketDomAction {
#[derive(Debug, Deserialize, Serialize)]
pub enum WebSocketNetworkEvent {
- ConnectionEstablished {
- protocol_in_use: Option<String>,
- },
+ ConnectionEstablished { protocol_in_use: Option<String> },
MessageReceived(MessageData),
Close(Option<u16>, String),
Fail,
@@ -353,18 +360,26 @@ pub enum WebSocketNetworkEvent {
#[derive(Debug, Deserialize, Serialize)]
/// IPC channels to communicate with the script thread about network or DOM events.
pub enum FetchChannels {
- ResponseMsg(IpcSender<FetchResponseMsg>, /* cancel_chan */ Option<IpcReceiver<()>>),
+ ResponseMsg(
+ IpcSender<FetchResponseMsg>,
+ /* cancel_chan */ Option<IpcReceiver<()>>,
+ ),
WebSocket {
event_sender: IpcSender<WebSocketNetworkEvent>,
action_receiver: IpcReceiver<WebSocketDomAction>,
- }
+ },
}
#[derive(Debug, Deserialize, Serialize)]
pub enum CoreResourceMsg {
Fetch(RequestInit, FetchChannels),
/// Initiate a fetch in response to processing a redirection
- FetchRedirect(RequestInit, ResponseInit, IpcSender<FetchResponseMsg>, /* cancel_chan */ Option<IpcReceiver<()>>),
+ FetchRedirect(
+ RequestInit,
+ ResponseInit,
+ IpcSender<FetchResponseMsg>,
+ /* cancel_chan */ Option<IpcReceiver<()>>,
+ ),
/// Store a cookie for a given originating URL
SetCookieForUrl(ServoUrl, Serde<Cookie<'static>>, CookieSource),
/// Store a set of cookies for a given originating URL
@@ -372,7 +387,11 @@ pub enum CoreResourceMsg {
/// Retrieve the stored cookies for a given URL
GetCookiesForUrl(ServoUrl, IpcSender<Option<String>>, CookieSource),
/// Get a cookie by name for a given originating URL
- GetCookiesDataForUrl(ServoUrl, IpcSender<Vec<Serde<Cookie<'static>>>>, CookieSource),
+ GetCookiesDataForUrl(
+ ServoUrl,
+ IpcSender<Vec<Serde<Cookie<'static>>>>,
+ CookieSource,
+ ),
/// Get a history state by a given history state id
GetHistoryState(HistoryStateId, IpcSender<Option<Vec<u8>>>),
/// Set a history state for a given history state id
@@ -392,13 +411,20 @@ pub enum CoreResourceMsg {
/// Instruct the resource thread to make a new request.
pub fn fetch_async<F>(request: RequestInit, core_resource_thread: &CoreResourceThread, f: F)
- where F: Fn(FetchResponseMsg) + Send + 'static,
+where
+ F: Fn(FetchResponseMsg) + Send + 'static,
{
let (action_sender, action_receiver) = ipc::channel().unwrap();
- ROUTER.add_route(action_receiver.to_opaque(),
- Box::new(move |message| f(message.to().unwrap())));
- core_resource_thread.send(
- CoreResourceMsg::Fetch(request, FetchChannels::ResponseMsg(action_sender, None))).unwrap();
+ ROUTER.add_route(
+ action_receiver.to_opaque(),
+ Box::new(move |message| f(message.to().unwrap())),
+ );
+ core_resource_thread
+ .send(CoreResourceMsg::Fetch(
+ request,
+ FetchChannels::ResponseMsg(action_sender, None),
+ ))
+ .unwrap();
}
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
@@ -466,7 +492,10 @@ impl Metadata {
}
if let Some(mime) = content_type {
- self.headers.as_mut().unwrap().typed_insert(ContentType::from(mime.clone()));
+ self.headers
+ .as_mut()
+ .unwrap()
+ .typed_insert(ContentType::from(mime.clone()));
self.content_type = Some(Serde(ContentType::from(mime.clone())));
for (name, value) in mime.params() {
if mime::CHARSET == name {
@@ -487,19 +516,23 @@ pub enum CookieSource {
}
/// Convenience function for synchronously loading a whole resource.
-pub fn load_whole_resource(request: RequestInit,
- core_resource_thread: &CoreResourceThread)
- -> Result<(Metadata, Vec<u8>), NetworkError> {
+pub fn load_whole_resource(
+ request: RequestInit,
+ core_resource_thread: &CoreResourceThread,
+) -> Result<(Metadata, Vec<u8>), NetworkError> {
let (action_sender, action_receiver) = ipc::channel().unwrap();
- core_resource_thread.send(
- CoreResourceMsg::Fetch(request, FetchChannels::ResponseMsg(action_sender, None))).unwrap();
+ core_resource_thread
+ .send(CoreResourceMsg::Fetch(
+ request,
+ FetchChannels::ResponseMsg(action_sender, None),
+ ))
+ .unwrap();
let mut buf = vec![];
let mut metadata = None;
loop {
match action_receiver.recv().unwrap() {
- FetchResponseMsg::ProcessRequestBody |
- FetchResponseMsg::ProcessRequestEOF => (),
+ FetchResponseMsg::ProcessRequestBody | FetchResponseMsg::ProcessRequestEOF => (),
FetchResponseMsg::ProcessResponse(Ok(m)) => {
metadata = Some(match m {
FetchMetadata::Unfiltered(m) => m,
@@ -534,7 +567,6 @@ impl NetworkError {
}
}
-
/// Normalize `slice`, as defined by
/// [the Fetch Spec](https://fetch.spec.whatwg.org/#concept-header-value-normalize).
pub fn trim_http_whitespace(mut slice: &[u8]) -> &[u8] {
@@ -569,4 +601,3 @@ pub fn http_percent_encode(bytes: &[u8]) -> String {
url::percent_encoding::percent_encode(bytes, HTTP_VALUE).to_string()
}
-
diff --git a/components/net_traits/pub_domains.rs b/components/net_traits/pub_domains.rs
index afe70023856..636790f8ea4 100644
--- a/components/net_traits/pub_domains.rs
+++ b/components/net_traits/pub_domains.rs
@@ -32,7 +32,8 @@ lazy_static! {
impl<'a> FromIterator<&'a str> for PubDomainRules {
fn from_iter<T>(iter: T) -> Self
- where T: IntoIterator<Item = &'a str>,
+ where
+ T: IntoIterator<Item = &'a str>,
{
let mut result = PubDomainRules::new();
for item in iter {
@@ -57,7 +58,8 @@ impl PubDomainRules {
}
}
pub fn parse(content: &str) -> PubDomainRules {
- content.lines()
+ content
+ .lines()
.map(str::trim)
.filter(|s| !s.is_empty())
.filter(|s| !s.starts_with("//"))
@@ -99,7 +101,7 @@ impl PubDomainRules {
None => !domain.is_empty(),
Some(index) => {
!self.exceptions.contains(domain) && self.wildcards.contains(&domain[index + 1..]) ||
- self.rules.contains(domain)
+ self.rules.contains(domain)
},
}
}
@@ -112,8 +114,9 @@ impl PubDomainRules {
None => false,
Some(index) => {
self.exceptions.contains(domain) ||
- !self.wildcards.contains(&domain[index + 1..]) && !self.rules.contains(domain) &&
- self.is_public_suffix(&domain[index + 1..])
+ !self.wildcards.contains(&domain[index + 1..]) &&
+ !self.rules.contains(domain) &&
+ self.is_public_suffix(&domain[index + 1..])
},
}
}
@@ -145,7 +148,9 @@ pub fn is_reg_domain(domain: &str) -> bool {
/// Leaves the host name alone if it is an IP address.
pub fn reg_host(url: &ServoUrl) -> Option<Host> {
match url.origin() {
- ImmutableOrigin::Tuple(_, Host::Domain(domain), _) => Some(Host::Domain(String::from(reg_suffix(&*domain)))),
+ ImmutableOrigin::Tuple(_, Host::Domain(domain), _) => {
+ Some(Host::Domain(String::from(reg_suffix(&*domain))))
+ },
ImmutableOrigin::Tuple(_, ip, _) => Some(ip),
ImmutableOrigin::Opaque(_) => None,
}
diff --git a/components/net_traits/quality.rs b/components/net_traits/quality.rs
index 72fed2304ca..6543cb11e8d 100644
--- a/components/net_traits/quality.rs
+++ b/components/net_traits/quality.rs
@@ -70,11 +70,17 @@ where
let s = str::from_utf8(&digits[..]).unwrap();
fmt.write_str(s.trim_right_matches('0'))
- }
+ },
}
}
}
pub fn quality_to_value(q: Vec<QualityItem<Mime>>) -> HeaderValue {
- HeaderValue::from_str(&q.iter().map(|q| q.to_string()).collect::<Vec<String>>().join(", ")).unwrap()
+ HeaderValue::from_str(
+ &q.iter()
+ .map(|q| q.to_string())
+ .collect::<Vec<String>>()
+ .join(", "),
+ )
+ .unwrap()
}
diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs
index 4113037a672..998740efbcc 100644
--- a/components/net_traits/request.rs
+++ b/components/net_traits/request.rs
@@ -46,9 +46,9 @@ impl Destination {
#[inline]
pub fn is_script_like(&self) -> bool {
*self == Destination::Script ||
- *self == Destination::ServiceWorker ||
- *self == Destination::SharedWorker ||
- *self == Destination::Worker
+ *self == Destination::ServiceWorker ||
+ *self == Destination::SharedWorker ||
+ *self == Destination::Worker
}
}
@@ -75,7 +75,7 @@ pub enum RequestMode {
SameOrigin,
NoCors,
CorsMode,
- WebSocket { protocols: Vec<String> }
+ WebSocket { protocols: Vec<String> },
}
/// Request [credentials mode](https://fetch.spec.whatwg.org/#concept-request-credentials-mode)
@@ -137,13 +137,17 @@ pub enum CorsSettings {
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct RequestInit {
- #[serde(deserialize_with = "::hyper_serde::deserialize",
- serialize_with = "::hyper_serde::serialize")]
+ #[serde(
+ deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize"
+ )]
#[ignore_malloc_size_of = "Defined in hyper"]
pub method: Method,
pub url: ServoUrl,
- #[serde(deserialize_with = "::hyper_serde::deserialize",
- serialize_with = "::hyper_serde::serialize")]
+ #[serde(
+ deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize"
+ )]
#[ignore_malloc_size_of = "Defined in hyper"]
pub headers: HeaderMap,
pub unsafe_request: bool,
@@ -259,10 +263,7 @@ pub struct Request {
}
impl Request {
- pub fn new(url: ServoUrl,
- origin: Option<Origin>,
- pipeline_id: Option<PipelineId>)
- -> Request {
+ pub fn new(url: ServoUrl, origin: Option<Origin>, pipeline_id: Option<PipelineId>) -> Request {
Request {
method: Method::GET,
local_urls_only: false,
@@ -294,9 +295,11 @@ impl Request {
}
pub fn from_init(init: RequestInit) -> Request {
- let mut req = Request::new(init.url.clone(),
- Some(Origin::Origin(init.origin)),
- init.pipeline_id);
+ let mut req = Request::new(
+ init.url.clone(),
+ Some(Origin::Origin(init.origin)),
+ init.pipeline_id,
+ );
req.method = init.method;
req.headers = init.headers;
req.unsafe_request = init.unsafe_request;
@@ -350,9 +353,16 @@ impl Request {
/// <https://fetch.spec.whatwg.org/#subresource-request>
pub fn is_subresource_request(&self) -> bool {
match self.destination {
- Destination::Audio | Destination::Font | Destination::Image | Destination::Manifest |
- Destination::Script | Destination::Style | Destination::Track | Destination::Video |
- Destination::Xslt | Destination::None => true,
+ Destination::Audio |
+ Destination::Font |
+ Destination::Image |
+ Destination::Manifest |
+ Destination::Script |
+ Destination::Style |
+ Destination::Track |
+ Destination::Video |
+ Destination::Xslt |
+ Destination::None => true,
_ => false,
}
}
diff --git a/components/net_traits/response.rs b/components/net_traits/response.rs
index e7f39358c5a..05729e1a05c 100644
--- a/components/net_traits/response.rs
+++ b/components/net_traits/response.rs
@@ -46,13 +46,11 @@ impl ResponseBody {
pub fn is_done(&self) -> bool {
match *self {
ResponseBody::Done(..) => true,
- ResponseBody::Empty |
- ResponseBody::Receiving(..) => false,
+ ResponseBody::Empty | ResponseBody::Receiving(..) => false,
}
}
}
-
/// [Cache state](https://fetch.spec.whatwg.org/#concept-response-cache-state)
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub enum CacheState {
@@ -79,8 +77,10 @@ pub enum ResponseMsg {
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct ResponseInit {
pub url: ServoUrl,
- #[serde(deserialize_with = "::hyper_serde::deserialize",
- serialize_with = "::hyper_serde::serialize")]
+ #[serde(
+ deserialize_with = "::hyper_serde::deserialize",
+ serialize_with = "::hyper_serde::serialize"
+ )]
#[ignore_malloc_size_of = "Defined in hyper"]
pub headers: HeaderMap,
pub status_code: u16,
@@ -149,7 +149,9 @@ impl Response {
res.location_url = init.location_url;
res.headers = init.headers;
res.referrer = init.referrer;
- res.status = StatusCode::from_u16(init.status_code).map(|s| (s, s.to_string())).ok();
+ res.status = StatusCode::from_u16(init.status_code)
+ .map(|s| (s, s.to_string()))
+ .ok();
res
}
@@ -292,7 +294,13 @@ impl Response {
pub fn metadata(&self) -> Result<FetchMetadata, NetworkError> {
fn init_metadata(response: &Response, url: &ServoUrl) -> Metadata {
let mut metadata = Metadata::default(url.clone());
- metadata.set_content_type(response.headers.typed_get::<ContentType>().map(|v| v.into()).as_ref());
+ metadata.set_content_type(
+ response
+ .headers
+ .typed_get::<ContentType>()
+ .map(|v| v.into())
+ .as_ref(),
+ );
metadata.location_url = response.location_url.clone();
metadata.headers = Some(Serde(response.headers.clone()));
metadata.status = response.raw_status.clone();
@@ -316,26 +324,27 @@ impl Response {
match self.response_type {
ResponseType::Basic => Ok(FetchMetadata::Filtered {
filtered: FilteredMetadata::Basic(metadata.unwrap()),
- unsafe_: unsafe_metadata
+ unsafe_: unsafe_metadata,
}),
ResponseType::Cors => Ok(FetchMetadata::Filtered {
filtered: FilteredMetadata::Cors(metadata.unwrap()),
- unsafe_: unsafe_metadata
+ unsafe_: unsafe_metadata,
}),
ResponseType::Default => unreachable!(),
- ResponseType::Error(ref network_err) =>
- Err(network_err.clone()),
+ ResponseType::Error(ref network_err) => Err(network_err.clone()),
ResponseType::Opaque => Ok(FetchMetadata::Filtered {
filtered: FilteredMetadata::Opaque,
- unsafe_: unsafe_metadata
+ unsafe_: unsafe_metadata,
}),
ResponseType::OpaqueRedirect => Ok(FetchMetadata::Filtered {
filtered: FilteredMetadata::OpaqueRedirect,
- unsafe_: unsafe_metadata
- })
+ unsafe_: unsafe_metadata,
+ }),
}
},
- None => Err(NetworkError::Internal("No url found in unsafe response".to_owned()))
+ None => Err(NetworkError::Internal(
+ "No url found in unsafe response".to_owned(),
+ )),
}
} else {
assert_eq!(self.response_type, ResponseType::Default);
diff --git a/components/net_traits/storage_thread.rs b/components/net_traits/storage_thread.rs
index af7a8cbde92..ec636a810a6 100644
--- a/components/net_traits/storage_thread.rs
+++ b/components/net_traits/storage_thread.rs
@@ -27,7 +27,13 @@ pub enum StorageThreadMsg {
GetItem(IpcSender<Option<String>>, ServoUrl, StorageType, String),
/// sets the value of the given key in the associated storage data
- SetItem(IpcSender<Result<(bool, Option<String>), ()>>, ServoUrl, StorageType, String, String),
+ SetItem(
+ IpcSender<Result<(bool, Option<String>), ()>>,
+ ServoUrl,
+ StorageType,
+ String,
+ String,
+ ),
/// removes the key/value pair for the given key in the associated storage data
RemoveItem(IpcSender<Option<String>>, ServoUrl, StorageType, String),
diff --git a/components/net_traits/tests/pub_domains.rs b/components/net_traits/tests/pub_domains.rs
index fa298633f6c..307dd2d81dc 100644
--- a/components/net_traits/tests/pub_domains.rs
+++ b/components/net_traits/tests/pub_domains.rs
@@ -116,6 +116,9 @@ fn test_reg_suffix() {
#[test]
fn test_weirdness() {
// These are weird results, but AFAICT they are spec-compliant.
- assert_ne!(pub_suffix("city.yokohama.jp"), pub_suffix(pub_suffix("city.yokohama.jp")));
+ assert_ne!(
+ pub_suffix("city.yokohama.jp"),
+ pub_suffix(pub_suffix("city.yokohama.jp"))
+ );
assert!(!is_pub_domain(pub_suffix("city.yokohama.jp")));
}