Implement Subresource Integrity

Implemented response validation part of
https://w3c.github.io/webappsec-subresource-integrity/.
Implemented step eighteen of the main fetch. If a request has integrity
metadata, then following steps are performed
*Wait for response body
*If the response does not have a termination reason and response does not
match request’s integrity metadata, set response to a
network error.# Please enter the commit message for your changes. Lines starting
This commit is contained in:
mrnayak 2017-01-08 08:52:18 +05:30
parent 496447a363
commit a3026499f4
19 changed files with 439 additions and 260 deletions

View file

@ -158,6 +158,7 @@ pub struct RequestInit {
pub referrer_policy: Option<ReferrerPolicy>,
pub pipeline_id: Option<PipelineId>,
pub redirect_mode: RedirectMode,
pub integrity_metadata: String,
}
impl Default for RequestInit {
@ -181,6 +182,7 @@ impl Default for RequestInit {
referrer_policy: None,
pipeline_id: None,
redirect_mode: RedirectMode::Follow,
integrity_metadata: "".to_owned(),
}
}
}
@ -291,6 +293,7 @@ impl Request {
req.referrer_policy.set(init.referrer_policy);
req.pipeline_id.set(init.pipeline_id);
req.redirect_mode.set(init.redirect_mode);
*req.integrity_metadata.borrow_mut() = init.integrity_metadata;
req
}