diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-02-10 14:13:32 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-02-10 14:13:32 +0530 |
commit | 33c514e2a7d0c2458cf7cbd7bcf1ee6762bd24fa (patch) | |
tree | c0a45ad576b5a5610976ffe73557dd380c4b7c82 /libmproxy | |
parent | 5f044d03b7c9d95be910f2eb643b6c8a9036d8de (diff) | |
download | mitmproxy-33c514e2a7d0c2458cf7cbd7bcf1ee6762bd24fa.tar.gz mitmproxy-33c514e2a7d0c2458cf7cbd7bcf1ee6762bd24fa.tar.bz2 mitmproxy-33c514e2a7d0c2458cf7cbd7bcf1ee6762bd24fa.zip |
Use textwrap.dedent in flow_export.python_code too
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/flow_export.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libmproxy/flow_export.py b/libmproxy/flow_export.py index 584b3be4..52145516 100644 --- a/libmproxy/flow_export.py +++ b/libmproxy/flow_export.py @@ -1,5 +1,6 @@ import urllib import netlib.http +from textwrap import dedent def curl_command(flow): @@ -21,16 +22,18 @@ def curl_command(flow): def python_code(flow): - code = """import requests - -url = '{url}' -{headers}{params}{data} -response = requests.request( - method='{method}', - url=url,{args} -) - -print(response.text)""" + code = dedent(""" + import requests + + url = '{url}' + {headers}{params}{data} + response = requests.request( + method='{method}', + url=url,{args} + ) + + print(response.text) + """).strip() components = map(lambda x: urllib.quote(x, safe=""), flow.request.path_components) url = flow.request.scheme + "://" + flow.request.host + "/" + "/".join(components) |