cli: list fetch()/XHR resources in --dump assets
--dump assets only walked static DOM attributes (script[src], img[src], ...), so resources a page pulled in with fetch() or XHR never showed up (issue #301). Record each absolute URL requested through op_fetch_url in ObscuraState, expose it via the runtime and Page, and append those URLs to --dump assets as type "fetch", deduped against URLs already listed from the DOM.
This commit is contained in:
1 parent
d526a4da7d
commit
ab27e9153d
4 files changed
+45
-1
No files matched your search
@@ -66,6 +66,10 @@ pub struct ObscuraState {
|
||||
pub network_response_bodies: HashMap<String, StoredNetworkResponseBody>,
|
||||
pub network_response_body_order: VecDeque<String>,
|
||||
pub network_response_body_counter: u64,
|
||||
// Absolute URLs requested via JS fetch() / XHR (op_fetch_url), in request
|
||||
// order. Surfaced by `--dump assets` so resources pulled in by script, not
|
||||
// just static DOM attributes, are listed (issue #301).
|
||||
pub fetched_urls: Vec<String>,
|
||||
}
|
||||
|
||||
impl ObscuraState {
|
||||
@@ -86,6 +90,7 @@ impl ObscuraState {
|
||||
network_response_bodies: HashMap::new(),
|
||||
network_response_body_order: VecDeque::new(),
|
||||
network_response_body_counter: 0,
|
||||
fetched_urls: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,6 +625,10 @@ async fn op_fetch_url(
|
||||
}).to_string());
|
||||
}
|
||||
}
|
||||
// Record the resource the page pulled in via fetch()/XHR so `--dump
|
||||
// assets` can list it (issue #301). URL is already absolute here, since
|
||||
// reqwest needs an absolute URL to send the request.
|
||||
gs.fetched_urls.push(url.clone());
|
||||
let jar = gs.cookie_jar.clone();
|
||||
let in_flight = gs.http_client.as_ref().map(|c| c.in_flight.clone());
|
||||
// #139: thread the configured proxy through to the per-request
|
||||
|
||||
Reference in new issue
Block a user