Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite test_redirect_from_x_to_y_provides_y_cookies_from_y. #14345

Merged
merged 3 commits into from Nov 23, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Provide an API to replace the host table.

  • Loading branch information
Ms2ger committed Nov 23, 2016
commit 035c35cdcc5f0b8e72678f2ab27d57563cdf4650
@@ -8,9 +8,10 @@ use std::env;
use std::fs::File;
use std::io::{BufReader, Read};
use std::net::IpAddr;
use std::sync::Mutex;

lazy_static! {
static ref HOST_TABLE: Option<HashMap<String, IpAddr>> = create_host_table();
static ref HOST_TABLE: Mutex<Option<HashMap<String, IpAddr>>> = Mutex::new(create_host_table());
}

fn create_host_table() -> Option<HashMap<String, IpAddr>> {
@@ -34,6 +35,10 @@ fn create_host_table() -> Option<HashMap<String, IpAddr>> {
return Some(parse_hostsfile(&lines));
}

pub fn replace_host_table(table: HashMap<String, IpAddr>) {
*HOST_TABLE.lock().unwrap() = Some(table);
}

pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
let mut host_table = HashMap::new();
for line in hostsfile_content.split('\n') {
@@ -53,7 +58,7 @@ pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
}

pub fn replace_hosts(url: &ServoUrl) -> ServoUrl {
HOST_TABLE.as_ref().map_or_else(|| url.clone(), |host_table| {
HOST_TABLE.lock().unwrap().as_ref().map_or_else(|| url.clone(), |host_table| {
host_replacement(host_table, url)
})
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.