production fix
This commit is contained in:
@@ -315,6 +315,54 @@ impl Requester {
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// Like [`get_raw`], but disables redirect-following so a 3xx response's
|
||||
/// `Location` header can be inspected directly. Uses the same
|
||||
/// Cloudflare-resilient client (Firefox emulation, shared cookie jar,
|
||||
/// FlareSolverr-derived user agent) as every other request path — unlike
|
||||
/// a bare `wreq::Client`, which Cloudflare is far more likely to flag,
|
||||
/// especially from datacenter/production IPs.
|
||||
pub async fn get_no_redirect_raw(&mut self, url: &str) -> Result<Response, wreq::Error> {
|
||||
let cookie_preview = self
|
||||
.cookie_header_for_url(url)
|
||||
.map(|cookie| crate::util::flow_debug::preview(&cookie, 160))
|
||||
.unwrap_or_else(|| "none".to_string());
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = &cookie_preview;
|
||||
crate::flow_debug!(
|
||||
"trace={} requester get_no_redirect_raw url={} cookies={} proxy={}",
|
||||
self.debug_trace_id().unwrap_or("none"),
|
||||
crate::util::flow_debug::preview(url, 120),
|
||||
cookie_preview,
|
||||
self.proxy
|
||||
);
|
||||
let mut builder = Client::builder()
|
||||
.cert_verification(false)
|
||||
.emulation(Emulation::Firefox136)
|
||||
.cookie_provider(self.cookie_jar.clone())
|
||||
.redirect(Policy::none());
|
||||
if let Some(user_agent) = self.user_agent.as_deref() {
|
||||
let mut headers = HeaderMap::new();
|
||||
if let Ok(value) = HeaderValue::from_str(user_agent) {
|
||||
headers.insert(USER_AGENT, value);
|
||||
builder = builder.default_headers(headers);
|
||||
}
|
||||
}
|
||||
let client = builder.build().expect("Failed to create HTTP client");
|
||||
|
||||
let mut request = client.get(url).version(Version::HTTP_11);
|
||||
|
||||
if self.proxy {
|
||||
if let Ok(proxy_url) = env::var("BURP_URL") {
|
||||
let proxy = Proxy::all(&proxy_url).unwrap();
|
||||
request = request.proxy(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
let response = request.send().await?;
|
||||
self.store_response_cookies(url, &response);
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
pub async fn get_raw_with_headers(
|
||||
&mut self,
|
||||
url: &str,
|
||||
|
||||
Reference in New Issue
Block a user