Skip to content

Commit

Permalink
Guess body type from headers as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Jul 20, 2021
1 parent bba392c commit 8880d5f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,15 @@ pub fn get_config() -> (Config, usize) {

//check whether it is possible to automatically fix body type
//- at the end means "specified automatically"
let body_type = if args.value_of("body-type").is_none() && !body.is_empty() && body.starts_with('{') {
let body_type = if args.value_of("body-type").is_none()
&& (
(
!body.is_empty() && body.starts_with('{')
)
|| (
headers.contains_key("Content-Type") && headers["Content-Type"].contains("json")
)
) {
String::from("json-")
} else {
args.value_of("body-type").unwrap_or("urlencode-").to_string()
Expand Down

0 comments on commit 8880d5f

Please sign in to comment.