aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/hsts.rs
diff options
context:
space:
mode:
authorSam Gibson <sam@ifdown.net>2015-07-18 17:23:46 +1000
committerSam Gibson <sam@ifdown.net>2015-07-22 11:49:08 +1200
commitf2148f06b1f67d18be471288824fd3a30348efcb (patch)
tree472c415a31962a460a6858c335d896cf5a927ff8 /components/net/hsts.rs
parent826f56bdf3f73bc9105a252f909acd4de28fcc07 (diff)
downloadservo-f2148f06b1f67d18be471288824fd3a30348efcb.tar.gz
servo-f2148f06b1f67d18be471288824fd3a30348efcb.zip
Moves the HSTS replacement code to http_loader
This respects STS for redirects as well.
Diffstat (limited to 'components/net/hsts.rs')
-rw-r--r--components/net/hsts.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/components/net/hsts.rs b/components/net/hsts.rs
index 8fcaa907b2c..74756a63afa 100644
--- a/components/net/hsts.rs
+++ b/components/net/hsts.rs
@@ -9,7 +9,6 @@ use url::Url;
use std::str::{from_utf8};
-use net_traits::LoadData;
use util::resource_files::read_resource_file;
static IPV4_REGEX: Regex = regex!(
@@ -64,7 +63,7 @@ impl HSTSEntry {
}
}
-#[derive(RustcDecodable, RustcEncodable)]
+#[derive(RustcDecodable, RustcEncodable, Clone)]
pub struct HSTSList {
pub entries: Vec<HSTSEntry>
}
@@ -126,20 +125,13 @@ pub fn preload_hsts_domains() -> Option<HSTSList> {
})
}
-pub fn secure_load_data(load_data: &LoadData) -> LoadData {
- if &*load_data.url.scheme == "http" {
- let mut secure_load_data = load_data.clone();
- let mut secure_url = load_data.url.clone();
+pub fn secure_url(url: &Url) -> Url {
+ if &*url.scheme == "http" {
+ let mut secure_url = url.clone();
secure_url.scheme = "https".to_string();
- // The Url struct parses the port for a known scheme only once.
- // Updating the scheme doesn't update the port internally, resulting in
- // HTTPS connections attempted on port 80. Serialising and re-parsing
- // the Url is a hack to get around this.
- secure_load_data.url = Url::parse(&secure_url.serialize()).unwrap();
-
- secure_load_data
+ Url::parse(&secure_url.serialize()).unwrap()
} else {
- load_data.clone()
+ url.clone()
}
}