mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Refactor copy_as_curl_command
This commit is contained in:
parent
9facd190c6
commit
0bb13c61d6
@ -281,24 +281,22 @@ def export_prompt(k, flow):
|
||||
copy_as_curl_command(flow)
|
||||
|
||||
def copy_as_curl_command(flow):
|
||||
|
||||
if flow.request.content is None or flow.request.content == CONTENT_MISSING:
|
||||
return None, "Request content is missing"
|
||||
|
||||
headerString = ""
|
||||
for k,v in flow.request.headers.fields:
|
||||
headerString += " -H '" + k + ":" + v + "' "
|
||||
data = "curl "
|
||||
|
||||
data = "curl"
|
||||
for k, v in flow.request.headers.fields:
|
||||
data += "-H '%s:%s' " % (k, v)
|
||||
|
||||
if flow.request.method != "GET":
|
||||
data += " -X " + flow.request.method
|
||||
data += "-X %s " % flow.request.method
|
||||
|
||||
full_url = flow.request.scheme + "://" + flow.request.host + flow.request.path
|
||||
data += " " + headerString + "'" + full_url + "'"
|
||||
data += "'%s'" % full_url
|
||||
|
||||
if flow.request.content != None and flow.request.content != "":
|
||||
data += " --data-binary " + "'" + flow.request.content + "'"
|
||||
if flow.request.content:
|
||||
data += " --data-binary '%s'" % flow.request.content
|
||||
|
||||
copy_to_clipboard_or_prompt(data)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user