🐛 (parse.py): fix method assignment logic to avoid overwriting with default 'post' when data flags are used
This commit is contained in:
parent
86eea0a844
commit
3b61df1a8b
1 changed files with 4 additions and 3 deletions
|
|
@ -64,21 +64,20 @@ def parse_curl_command(curl_command):
|
||||||
"cookies": {},
|
"cookies": {},
|
||||||
}
|
}
|
||||||
args = args_template.copy()
|
args = args_template.copy()
|
||||||
|
method_on_curl = None
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(tokens):
|
while i < len(tokens):
|
||||||
token = tokens[i]
|
token = tokens[i]
|
||||||
if token == "-X":
|
if token == "-X":
|
||||||
i += 1
|
i += 1
|
||||||
args["method"] = tokens[i].lower()
|
args["method"] = tokens[i].lower()
|
||||||
|
method_on_curl = tokens[i].lower()
|
||||||
elif token in ("-d", "--data"):
|
elif token in ("-d", "--data"):
|
||||||
i += 1
|
i += 1
|
||||||
args["data"] = tokens[i]
|
args["data"] = tokens[i]
|
||||||
args["method"] = "post"
|
|
||||||
elif token in ("-b", "--data-binary", "--data-raw"):
|
elif token in ("-b", "--data-binary", "--data-raw"):
|
||||||
i += 1
|
i += 1
|
||||||
args["data_binary"] = tokens[i]
|
args["data_binary"] = tokens[i]
|
||||||
args["method"] = "post"
|
|
||||||
elif token in ("-H", "--header"):
|
elif token in ("-H", "--header"):
|
||||||
i += 1
|
i += 1
|
||||||
args["headers"].append(tokens[i])
|
args["headers"].append(tokens[i])
|
||||||
|
|
@ -106,6 +105,8 @@ def parse_curl_command(curl_command):
|
||||||
args["url"] = token
|
args["url"] = token
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
args["method"] = method_on_curl or args["method"]
|
||||||
|
|
||||||
return ParsedArgs(**args)
|
return ParsedArgs(**args)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue