mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
updated basic auth cache to key off of url origin
This commit is contained in:
parent
e3d946bb29
commit
82e45a403f
4 changed files with 9 additions and 8 deletions
|
@ -827,7 +827,7 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
let mut authorization_value = None;
|
||||
|
||||
// Substep 4
|
||||
if let Some(basic) = auth_from_cache(&context.state.auth_cache, ¤t_url) {
|
||||
if let Some(basic) = auth_from_cache(&context.state.auth_cache, ¤t_url.origin()) {
|
||||
if !http_request.use_url_credentials || !has_credentials(¤t_url) {
|
||||
authorization_value = Some(basic);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ use time;
|
|||
use time::Tm;
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
use tinyfiledialogs;
|
||||
use url::{Position, Url};
|
||||
use url::{Position, Url, Origin};
|
||||
use util::prefs::PREFS;
|
||||
use util::thread::spawn_named;
|
||||
use uuid;
|
||||
|
@ -688,15 +688,15 @@ fn set_auth_header(headers: &mut Headers,
|
|||
if let Some(auth) = auth_from_url(url) {
|
||||
headers.set(auth);
|
||||
} else {
|
||||
if let Some(basic) = auth_from_cache(auth_cache, url) {
|
||||
if let Some(basic) = auth_from_cache(auth_cache, &url.origin()) {
|
||||
headers.set(Authorization(basic));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn auth_from_cache(auth_cache: &Arc<RwLock<AuthCache>>, url: &Url) -> Option<Basic> {
|
||||
if let Some(ref auth_entry) = auth_cache.read().unwrap().entries.get(url) {
|
||||
pub fn auth_from_cache(auth_cache: &Arc<RwLock<AuthCache>>, origin: &Origin) -> Option<Basic> {
|
||||
if let Some(ref auth_entry) = auth_cache.read().unwrap().entries.get(&origin.ascii_serialization()) {
|
||||
let user_name = auth_entry.user_name.clone();
|
||||
let password = Some(auth_entry.password.clone());
|
||||
Some(Basic { username: user_name, password: password })
|
||||
|
@ -1023,7 +1023,8 @@ pub fn load<A, B>(load_data: &LoadData,
|
|||
password: auth_header.password.to_owned().unwrap(),
|
||||
};
|
||||
|
||||
http_state.auth_cache.write().unwrap().entries.insert(doc_url.clone(), auth_entry);
|
||||
let serialized_origin = doc_url.origin().ascii_serialization();
|
||||
http_state.auth_cache.write().unwrap().entries.insert(serialized_origin, auth_entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -466,7 +466,7 @@ impl AuthCache {
|
|||
#[derive(RustcDecodable, RustcEncodable, Clone)]
|
||||
pub struct AuthCache {
|
||||
pub version: u32,
|
||||
pub entries: HashMap<Url, AuthCacheEntry>,
|
||||
pub entries: HashMap<String, AuthCacheEntry>,
|
||||
}
|
||||
|
||||
pub struct CoreResourceManager {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue