aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-01-13 16:17:01 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-01-13 16:17:01 +0530
commit0bb13c61d6ec7e0fae45a6aab0fe59ba1b6e6a48 (patch)
tree490029fa96db02740213847b733e67877b1d199f
parent9facd190c6937287eb93b430c24d13c13b5560b8 (diff)
downloadmitmproxy-0bb13c61d6ec7e0fae45a6aab0fe59ba1b6e6a48.tar.gz
mitmproxy-0bb13c61d6ec7e0fae45a6aab0fe59ba1b6e6a48.tar.bz2
mitmproxy-0bb13c61d6ec7e0fae45a6aab0fe59ba1b6e6a48.zip
Refactor copy_as_curl_command
-rw-r--r--libmproxy/console/common.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py
index 6a7064ff..29e86b79 100644
--- a/libmproxy/console/common.py
+++ b/libmproxy/console/common.py
@@ -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)