mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
parent
648a799525
commit
703fdea1a5
@ -76,11 +76,11 @@ def make_scope(flow: http.HTTPFlow) -> dict:
|
||||
},
|
||||
"http_version": HTTP_VERSION_MAP.get(flow.request.http_version, "1.1"),
|
||||
"method": flow.request.method,
|
||||
"scheme": flow.request.scheme,
|
||||
"scheme": flow.request.scheme.upper(),
|
||||
"path": path,
|
||||
"raw_path": flow.request.path,
|
||||
"query_string": query_string,
|
||||
"headers": list(list(x) for x in flow.request.headers.fields),
|
||||
"headers": [(name.lower(), value) for (name, value) in flow.request.headers.fields],
|
||||
"client": flow.client_conn.peername,
|
||||
"extensions": {
|
||||
"mitmproxy.master": ctx.master,
|
||||
|
@ -27,6 +27,11 @@ def request_check():
|
||||
return json.dumps(args)
|
||||
|
||||
|
||||
@tapp.route("/requestbody", methods=["POST"])
|
||||
def request_body():
|
||||
return json.dumps({"body": request.data.decode()})
|
||||
|
||||
|
||||
@tapp.route("/error")
|
||||
def error():
|
||||
raise ValueError("An exception...")
|
||||
@ -71,6 +76,14 @@ async def test_asgi_full():
|
||||
body = await reader.readuntil(b"}")
|
||||
assert body == b'{"param1": "1", "param2": "2"}'
|
||||
|
||||
reader, writer = await asyncio.open_connection(*proxy_addr)
|
||||
req = f"POST http://testapp:80/requestbody HTTP/1.1\r\nContent-Length: 6\r\n\r\nHello!"
|
||||
writer.write(req.encode())
|
||||
header = await reader.readuntil(b"\r\n\r\n")
|
||||
assert header.startswith(b"HTTP/1.1 200 OK")
|
||||
body = await reader.readuntil(b"}")
|
||||
assert body == b'{"body": "Hello!"}'
|
||||
|
||||
reader, writer = await asyncio.open_connection(*proxy_addr)
|
||||
req = f"GET http://errapp:80/?foo=bar HTTP/1.1\r\n\r\n"
|
||||
writer.write(req.encode())
|
||||
|
Loading…
Reference in New Issue
Block a user