mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
Use textwrap.dedent in flow_export.python_code too
This commit is contained in:
parent
5f044d03b7
commit
33c514e2a7
@ -1,5 +1,6 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import netlib.http
|
import netlib.http
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
|
|
||||||
def curl_command(flow):
|
def curl_command(flow):
|
||||||
@ -21,7 +22,8 @@ def curl_command(flow):
|
|||||||
|
|
||||||
|
|
||||||
def python_code(flow):
|
def python_code(flow):
|
||||||
code = """import requests
|
code = dedent("""
|
||||||
|
import requests
|
||||||
|
|
||||||
url = '{url}'
|
url = '{url}'
|
||||||
{headers}{params}{data}
|
{headers}{params}{data}
|
||||||
@ -30,7 +32,8 @@ response = requests.request(
|
|||||||
url=url,{args}
|
url=url,{args}
|
||||||
)
|
)
|
||||||
|
|
||||||
print(response.text)"""
|
print(response.text)
|
||||||
|
""").strip()
|
||||||
|
|
||||||
components = map(lambda x: urllib.quote(x, safe=""), flow.request.path_components)
|
components = map(lambda x: urllib.quote(x, safe=""), flow.request.path_components)
|
||||||
url = flow.request.scheme + "://" + flow.request.host + "/" + "/".join(components)
|
url = flow.request.scheme + "://" + flow.request.host + "/" + "/".join(components)
|
||||||
|
Loading…
Reference in New Issue
Block a user