Rename 'HSTS*' structures to 'Hsts*'.

"In CamelCase, acronyms count as one word: use Uuid rather than UUID."

-- https://doc.rust-lang.org/style/style/naming/README.html
This commit is contained in:
Corey Farwell 2016-04-17 12:35:51 -04:00
parent faa3d8724b
commit 08fc002f41
5 changed files with 69 additions and 69 deletions

View file

@ -11,19 +11,19 @@ use url::Url;
use util::resource_files::read_resource_file;
#[derive(RustcDecodable, RustcEncodable, Clone)]
pub struct HSTSEntry {
pub struct HstsEntry {
pub host: String,
pub include_subdomains: bool,
pub max_age: Option<u64>,
pub timestamp: Option<u64>
}
impl HSTSEntry {
pub fn new(host: String, subdomains: IncludeSubdomains, max_age: Option<u64>) -> Option<HSTSEntry> {
impl HstsEntry {
pub fn new(host: String, subdomains: IncludeSubdomains, max_age: Option<u64>) -> Option<HstsEntry> {
if host.parse::<Ipv4Addr>().is_ok() || host.parse::<Ipv6Addr>().is_ok() {
None
} else {
Some(HSTSEntry {
Some(HstsEntry {
host: host,
include_subdomains: (subdomains == IncludeSubdomains::Included),
max_age: max_age,
@ -52,28 +52,28 @@ impl HSTSEntry {
}
#[derive(RustcDecodable, RustcEncodable, Clone)]
pub struct HSTSList {
pub entries: Vec<HSTSEntry>
pub struct HstsList {
pub entries: Vec<HstsEntry>
}
impl HSTSList {
pub fn new() -> HSTSList {
HSTSList {
impl HstsList {
pub fn new() -> HstsList {
HstsList {
entries: vec![]
}
}
/// Create an `HSTSList` from the bytes of a JSON preload file.
pub fn from_preload(preload_content: &[u8]) -> Option<HSTSList> {
/// Create an `HstsList` from the bytes of a JSON preload file.
pub fn from_preload(preload_content: &[u8]) -> Option<HstsList> {
from_utf8(&preload_content)
.ok()
.and_then(|c| decode(c).ok())
}
pub fn from_servo_preload() -> HSTSList {
pub fn from_servo_preload() -> HstsList {
let file_bytes = read_resource_file("hsts_preload.json")
.expect("Could not find Servo HSTS preload file");
HSTSList::from_preload(&file_bytes)
HstsList::from_preload(&file_bytes)
.expect("Servo HSTS preload file is invalid")
}
@ -104,7 +104,7 @@ impl HSTSList {
})
}
pub fn push(&mut self, entry: HSTSEntry) {
pub fn push(&mut self, entry: HstsEntry) {
let have_domain = self.has_domain(&entry.host);
let have_subdomain = self.has_subdomain(&entry.host);

View file

@ -10,7 +10,7 @@ use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpReques
use devtools_traits::{HttpResponse as DevtoolsHttpResponse, NetworkEvent};
use file_loader;
use flate2::read::{DeflateDecoder, GzDecoder};
use hsts::{HSTSEntry, HSTSList, secure_url};
use hsts::{HstsEntry, HstsList, secure_url};
use hyper::Error as HttpError;
use hyper::client::{Pool, Request, Response};
use hyper::header::{Accept, AcceptEncoding, ContentLength, ContentType, Host};
@ -125,7 +125,7 @@ fn inner_url(url: &Url) -> Url {
}
pub struct HttpState {
pub hsts_list: Arc<RwLock<HSTSList>>,
pub hsts_list: Arc<RwLock<HstsList>>,
pub cookie_jar: Arc<RwLock<CookieStorage>>,
pub auth_cache: Arc<RwLock<HashMap<Url, AuthCacheEntry>>>,
}
@ -133,7 +133,7 @@ pub struct HttpState {
impl HttpState {
pub fn new() -> HttpState {
HttpState {
hsts_list: Arc::new(RwLock::new(HSTSList::new())),
hsts_list: Arc::new(RwLock::new(HstsList::new())),
cookie_jar: Arc::new(RwLock::new(CookieStorage::new())),
auth_cache: Arc::new(RwLock::new(HashMap::new())),
}
@ -401,7 +401,7 @@ fn set_cookies_from_response(url: Url, response: &HttpResponse, cookie_jar: &Arc
}
}
fn update_sts_list_from_response(url: &Url, response: &HttpResponse, hsts_list: &Arc<RwLock<HSTSList>>) {
fn update_sts_list_from_response(url: &Url, response: &HttpResponse, hsts_list: &Arc<RwLock<HstsList>>) {
if url.scheme != "https" {
return;
}
@ -415,7 +415,7 @@ fn update_sts_list_from_response(url: &Url, response: &HttpResponse, hsts_list:
IncludeSubdomains::NotIncluded
};
if let Some(entry) = HSTSEntry::new(host.to_owned(), include_subdomains, Some(header.max_age)) {
if let Some(entry) = HstsEntry::new(host.to_owned(), include_subdomains, Some(header.max_age)) {
info!("adding host {} to the strict transport security list", host);
info!("- max-age {}", header.max_age);
if header.include_subdomains {
@ -518,7 +518,7 @@ fn send_response_to_devtools(devtools_chan: Option<Sender<DevtoolsControlMsg>>,
}
}
fn request_must_be_secured(url: &Url, hsts_list: &Arc<RwLock<HSTSList>>) -> bool {
fn request_must_be_secured(url: &Url, hsts_list: &Arc<RwLock<HstsList>>) -> bool {
match url.domain() {
Some(domain) => hsts_list.read().unwrap().is_host_secure(domain),
None => false
@ -597,7 +597,7 @@ fn auth_from_url(doc_url: &Url) -> Option<Authorization<Basic>> {
pub fn process_response_headers(response: &HttpResponse,
url: &Url,
cookie_jar: &Arc<RwLock<CookieStorage>>,
hsts_list: &Arc<RwLock<HSTSList>>,
hsts_list: &Arc<RwLock<HstsList>>,
load_data: &LoadData) {
info!("got HTTP response {}, headers:", response.status());
if log_enabled!(log::LogLevel::Info) {

View file

@ -10,7 +10,7 @@ use cookie_storage::CookieStorage;
use data_loader;
use devtools_traits::{DevtoolsControlMsg};
use file_loader;
use hsts::HSTSList;
use hsts::HstsList;
use http_loader::{self, Connector, create_http_connector, HttpState};
use hyper::client::pool::Pool;
use hyper::header::{ContentType, Header, SetCookie};
@ -148,7 +148,7 @@ fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result<Pro
/// Create a ResourceThread
pub fn new_resource_thread(user_agent: String,
devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceThread {
let hsts_preload = HSTSList::from_servo_preload();
let hsts_preload = HstsList::from_servo_preload();
let (setup_chan, setup_port) = ipc::channel().unwrap();
let setup_chan_clone = setup_chan.clone();
spawn_named("ResourceManager".to_owned(), move || {
@ -276,7 +276,7 @@ pub struct ResourceManager {
auth_cache: Arc<RwLock<HashMap<Url, AuthCacheEntry>>>,
mime_classifier: Arc<MIMEClassifier>,
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
hsts_list: Arc<RwLock<HSTSList>>,
hsts_list: Arc<RwLock<HstsList>>,
connector: Arc<Pool<Connector>>,
cancel_load_map: HashMap<ResourceId, Sender<()>>,
next_resource_id: ResourceId,
@ -284,7 +284,7 @@ pub struct ResourceManager {
impl ResourceManager {
pub fn new(user_agent: String,
hsts_list: HSTSList,
hsts_list: HstsList,
devtools_channel: Option<Sender<DevtoolsControlMsg>>) -> ResourceManager {
ResourceManager {
user_agent: user_agent,