javtiful done
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use serde::Serialize;
|
||||
use wreq::multipart::Form;
|
||||
use std::env;
|
||||
use wreq::Client;
|
||||
use wreq::Proxy;
|
||||
@@ -119,14 +120,37 @@ impl Requester {
|
||||
where
|
||||
S: Serialize + ?Sized,
|
||||
{
|
||||
let client = Client::builder()
|
||||
.cert_verification(false)
|
||||
.emulation(Emulation::Firefox136)
|
||||
.cookie_store(true)
|
||||
.build()
|
||||
.expect("Failed to create HTTP client");
|
||||
let mut request = self.client.post(url).version(Version::HTTP_11).json(data);
|
||||
|
||||
let mut request = client.post(url).version(Version::HTTP_11).json(data);
|
||||
// Set custom headers
|
||||
for (key, value) in headers.iter() {
|
||||
request = request.header(key, value);
|
||||
}
|
||||
|
||||
if self.proxy {
|
||||
if let Ok(proxy_url) = env::var("BURP_URL") {
|
||||
let proxy = Proxy::all(&proxy_url).unwrap();
|
||||
request = request.proxy(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
request.send().await
|
||||
}
|
||||
|
||||
pub async fn post_multipart(
|
||||
&mut self,
|
||||
url: &str,
|
||||
form: Form,
|
||||
headers: Vec<(String, String)>,
|
||||
_http_version: Option<Version>,
|
||||
) -> Result<Response, wreq::Error>
|
||||
{
|
||||
let http_version = match _http_version {
|
||||
Some(v) => v,
|
||||
None => Version::HTTP_11,
|
||||
};
|
||||
|
||||
let mut request = self.client.post(url).multipart(form).version(http_version);
|
||||
|
||||
// Set custom headers
|
||||
for (key, value) in headers.iter() {
|
||||
|
||||
Reference in New Issue
Block a user