Skip to content

Commit

Permalink
collect several lines of body into one (raw request)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Jul 11, 2021
1 parent 5047b5c commit 62d299c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,12 @@ pub fn parse_request(insecure: bool, request: &str, config: Config) -> Option<Co
headers.insert(key.to_string(), value);
}

let body = lines.next().unwrap_or("");
let mut body = lines.next().unwrap_or("").to_string();
while let Some(part) = lines.next() {
if !part.is_empty() {
body.push_str(part);
}
}

//check whether the body type can be json
let body_type = if config.body_type.contains('-') && config.as_body
Expand All @@ -334,9 +339,9 @@ pub fn parse_request(insecure: bool, request: &str, config: Config) -> Option<Co

//if --as-body is specified and body is empty or lacks injection points - add an injection point
let body = if config.as_body && ((!body.is_empty() && !body.contains("%s")) || body.is_empty()) {
adjust_body(body, &body_type)
adjust_body(&body, &body_type)
} else {
body.to_string()
body
};

let mut url = [proto.to_string(), host.clone(), path.clone()].concat();
Expand Down

0 comments on commit 62d299c

Please sign in to comment.