Skip to content

Commit

Permalink
Fix raw requests with http/2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Jul 10, 2021
1 parent 12c72c6 commit 4fa9ec3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "x8"
version = "2.3.1"
version = "2.3.2"
authors = ["Alexander Mironov <[email protected]>"]
edition = "2018"
license = "GPL-3.0-or-later"
Expand All @@ -14,7 +14,7 @@ readme = "README.md"
[dependencies]
tokio = { version = "1", features = ["full"] }
futures = "0.3.15"
reqwest = { version = "0.11", features = ["socks", "json", "cookies", "rustls-tls", "trust-dns"] }
reqwest = { version = "0.11.2", features = ["socks", "json", "cookies", "rustls-tls", "trust-dns"] }
regex = "1.3.7"
percent-encoding = "2.1.0"
lazy_static = "1.4.0"
Expand Down
13 changes: 11 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn parse_request(insecure: bool, request: &str, config: Config) -> Option<Co
let proto = if insecure { "http://" } else { "https://" };
let mut firstline = lines.next()?.split(' ');
let method = firstline.next()?.to_string();
let path = firstline.next()?.to_string();
let mut path = firstline.next()?.to_string();

let http2: bool = firstline.next()?.to_string().contains("HTTP/2");

Expand All @@ -315,7 +315,12 @@ pub fn parse_request(insecure: bool, request: &str, config: Config) -> Option<Co

match key.to_lowercase().as_str() {
"content-type" => content_type = value.clone(),
"host" => host = value.clone(),
"host" => {
host = value.clone();
if http2 {
continue
}
},
"content-length" => continue,
_ => ()
};
Expand All @@ -342,10 +347,13 @@ pub fn parse_request(insecure: bool, request: &str, config: Config) -> Option<Co
};

let mut url = [proto.to_string(), host.clone(), path.clone()].concat();
let initial_url = url.clone();
if !config.as_body && url.contains('?') && url.contains('=') && !url.contains("%s") {
url.push_str("&%s");
path.push_str("&%s");
} else if !config.as_body {
url.push_str("?%s");
path.push_str("?%s");
}

Some(Config {
Expand All @@ -358,6 +366,7 @@ pub fn parse_request(insecure: bool, request: &str, config: Config) -> Option<Co
body_type,
parameter_template,
http2,
initial_url,
..config
})
}
Expand Down

0 comments on commit 4fa9ec3

Please sign in to comment.