Skip to content

Commit

Permalink
Use http2 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Apr 28, 2022
1 parent 3bdd81b commit aa2ae6c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 30 deletions.
7 changes: 0 additions & 7 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ pub fn get_config() -> (Config, usize) {
.help("The number of concurrent requests (default is 1)")
.takes_value(true)
)
.arg(
Arg::with_name("http2")
.long("http2")
.help("Prefer http/2 over http/1.1")
.conflicts_with("request")
)
.arg(
Arg::with_name("verify")
.long("verify")
Expand Down Expand Up @@ -567,7 +561,6 @@ pub fn get_config() -> (Config, usize) {
learn_requests_count,
max,
concurrency,
http2: args.is_present("http2"),
verify: args.is_present("verify"),
reflected_only: args.is_present("reflected_only")
};
Expand Down
12 changes: 4 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ async fn run() {
.danger_accept_invalid_certs(true)
.timeout(Duration::from_secs(60))
.http1_title_case_headers()
.cookie_store(true);
.cookie_store(true)
.use_rustls_tls();

if config.http2 {
client = client.use_rustls_tls();
}
if !config.proxy.is_empty() {
client = client.proxy(reqwest::Proxy::all(&config.proxy).unwrap());
}
Expand All @@ -104,11 +102,9 @@ async fn run() {
.danger_accept_invalid_certs(true)
.timeout(Duration::from_secs(60))
.http1_title_case_headers()
.cookie_store(true);
.cookie_store(true)
.use_rustls_tls();

if config.http2 {
replay_client = replay_client.use_rustls_tls();
}
if !config.replay_proxy.is_empty() {
replay_client = replay_client.proxy(reqwest::Proxy::all(&config.replay_proxy).unwrap());
}
Expand Down
8 changes: 0 additions & 8 deletions src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
use colored::*;
use reqwest::Client;
use std::{
error::Error,
time::Duration,
collections::{BTreeMap, HashMap},
io::{self, Write},
Expand Down Expand Up @@ -243,13 +242,6 @@ pub async fn request(
},
Err(err) => {
writeln!(io::stderr(), "[!] {} {:?}", url, err).ok();
match err.source() {
Some(val) => if val.to_string() == "invalid HTTP version parsed" && !config.http2 {
writeln!(io::stdout(), "[!] {}", "Try to use --http2 option".bright_red()).ok();
std::process::exit(1);
},
None => ()
};
writeln!(io::stderr(), "[~] error at the {} observed. Wait 50 sec and repeat.", config.url).ok();
std::thread::sleep(Duration::from_secs(50));
match create_request(config, random_query, &hashmap_query, client).send().await {
Expand Down
1 change: 0 additions & 1 deletion src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ pub struct Config {
pub learn_requests_count: usize,
pub max: usize,
pub concurrency: usize,
pub http2: bool,
pub verify: bool,
pub reflected_only: bool
}
Expand Down
8 changes: 2 additions & 6 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,8 @@ pub fn generate_request(config: &Config, initial_query: &HashMap<String, String>
req.push(' ');
req.push_str(&config.path.replace("%s", &query));

if config.http2 {
req.push_str(" HTTP/2\n");
} else {
req.push_str(" HTTP/1.1\n");
}

req.push_str(" HTTP/1.1\n");

if !config.headers.keys().any(|i| i.contains("Host")) {
req.push_str(&("Host: ".to_owned() + &config.host));
Expand Down Expand Up @@ -405,7 +402,6 @@ pub fn parse_request(config: Config, proto: &str, request: &str, custom_paramete
body,
body_type,
parameter_template,
http2,
initial_url,
..config
})
Expand Down

0 comments on commit aa2ae6c

Please sign in to comment.