vidara and cargo updates

This commit is contained in:
Simon
2026-05-05 12:25:43 +00:00
committed by ForgeCode
parent 8ae0fcb544
commit 01306c508a
5 changed files with 40 additions and 43 deletions

View File

@@ -6,9 +6,9 @@ use std::time::Duration;
use wreq::Client;
use wreq::Proxy;
use wreq::Response;
use wreq::Uri;
use wreq::Url;
use wreq::Version;
use wreq::cookie::{CookieStore, Cookies, Jar};
use wreq::cookie::{CookieStore, Jar};
use wreq::header::{HeaderMap, HeaderValue, SET_COOKIE, USER_AGENT};
use wreq::multipart::Form;
use wreq::redirect::Policy;
@@ -67,7 +67,7 @@ impl Requester {
for value in response.headers().get_all(SET_COOKIE).iter() {
if let Ok(cookie) = value.to_str() {
self.cookie_jar.add_cookie_str(cookie, &origin.to_string());
self.cookie_jar.add_cookie_str(cookie, &origin);
}
}
}
@@ -115,7 +115,7 @@ impl Requester {
}
self.cookie_jar
.add_cookie_str(&cookie_string, &origin.to_string());
.add_cookie_str(&cookie_string, &origin);
}
}
@@ -199,7 +199,7 @@ impl Requester {
fn build_client(cookie_jar: Arc<Jar>, user_agent: Option<&str>) -> Client {
let mut builder = Client::builder()
.cert_verification(false)
.emulation(Emulation::Firefox146)
.emulation(Emulation::Firefox136)
.cookie_provider(cookie_jar)
.redirect(Policy::default());
@@ -249,20 +249,13 @@ impl Requester {
}
pub fn cookie_header_for_url(&self, url: &str) -> Option<String> {
let parsed = url.parse::<Uri>().ok()?;
match self.cookie_jar.cookies(&parsed) {
Cookies::Compressed(value) => value.to_str().ok().map(ToOwned::to_owned),
Cookies::Uncompressed(values) => {
let joined = values
.into_iter()
.filter_map(|value| value.to_str().ok().map(ToOwned::to_owned))
.collect::<Vec<_>>()
.join("; ");
(!joined.is_empty()).then_some(joined)
}
Cookies::Empty => None,
_ => None,
}
let parsed = url.parse::<Url>().ok()?;
let joined = self.cookie_jar.cookies(&parsed)
.into_iter()
.filter_map(|c| c.to_str().ok().map(ToOwned::to_owned))
.collect::<Vec<_>>()
.join("; ");
(!joined.is_empty()).then_some(joined)
}
pub async fn get_raw(&mut self, url: &str) -> Result<Response, wreq::Error> {