Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
added cli option to proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-schneider-vtex committed Jul 3, 2023
1 parent e204bc4 commit c2c1b55
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pub struct CliArgs {
/// Status codes to be ignored
#[arg(long = "fstatus", default_value = "404")]
filter_status: String,

/// proxy
#[arg(short = 'x')]
proxy: Option<String>,
}

impl CliArgs {
Expand Down Expand Up @@ -94,6 +98,7 @@ struct RequestParam {
url: String,
// refactor this to &[u8]
body: String,
proxy: Option<String>,
}

//TODO: Run any script from bash here
Expand All @@ -114,9 +119,15 @@ fn request(
http_verb,
url,
body,
proxy,
}: RequestParam,
) -> Result<reqwest::blocking::Response> {
let client = ClientBuilder::new()
let client = match proxy {
Some(url) => ClientBuilder::new().proxy(reqwest::Proxy::all(url)?),
None => ClientBuilder::new(),
};

let client = client
.danger_accept_invalid_hostnames(true)
.danger_accept_invalid_certs(true)
.timeout(Duration::from_secs(30))
Expand Down Expand Up @@ -169,6 +180,7 @@ fn execute_requests(args: &CliArgs) -> Result<()> {
http_verb: args.verb,
url: url,
body: args.data.clone().unwrap_or("".into()),
proxy: args.proxy.clone(),
})
.collect_vec();

Expand Down

0 comments on commit c2c1b55

Please sign in to comment.