testing this fix

This commit is contained in:
Simon
2025-08-28 17:53:02 +00:00
parent f10491dd73
commit 44b42170be
2 changed files with 13 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ pub struct Requester {
impl Requester {
pub fn new() -> Self {
let client = Client::builder()
let mut client = Client::builder()
.cert_verification(false)
.emulation(Emulation::Firefox136)
.cookie_store(true)
@@ -54,7 +54,7 @@ impl Requester {
}
}
pub async fn get(&self, url: &str) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
pub async fn get(&mut self, url: &str) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
let mut request = self.client.get(url).version(Version::HTTP_11);
let mut proxy;
if self.proxy {
@@ -83,12 +83,14 @@ impl Requester {
.await;
match result {
Ok(res) => {
self.client.update()
.headers(|headers| {
headers.insert("Cookie", HeaderValue::from_str("").unwrap());
})
.apply()
.unwrap();
let cookie_url = url.split("/").collect::<Vec<&str>>()[..3].join("/");
self.client = Client::builder()
.cert_verification(false)
.emulation(Emulation::Firefox136)
.cookie_store(true)
.redirect(Policy::default())
.build()
.expect("Failed to create HTTP client");
let useragent = res.solution.userAgent;
self.client.update()
.headers(|headers| {
@@ -99,7 +101,6 @@ impl Requester {
for cookie in res.solution.cookies {
let header = HeaderValue::from_str(&format!("{}={}", cookie.name, cookie.value)).unwrap();
// Parse the domain string into a Url
let cookie_url = url.split("/").collect::<Vec<&str>>()[..3].join("/");
if let Ok(url) = url::Url::parse(cookie_url.as_str()) {
self.client.set_cookie(&url, header);
}