mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
minor type fixes
This commit is contained in:
parent
8158349db5
commit
bccee15dcb
@ -12,8 +12,8 @@ from mitmproxy.net.http.http1 import assemble
|
|||||||
from mitmproxy.utils import strutils
|
from mitmproxy.utils import strutils
|
||||||
|
|
||||||
|
|
||||||
def cleanup_request(f: flow.Flow):
|
def cleanup_request(f: flow.Flow) -> http.HTTPRequest:
|
||||||
if not hasattr(f, "request") or not f.request: # type: ignore
|
if not hasattr(f, "request") or not f.request:
|
||||||
raise exceptions.CommandError("Can't export flow with no request.")
|
raise exceptions.CommandError("Can't export flow with no request.")
|
||||||
assert isinstance(f, http.HTTPFlow)
|
assert isinstance(f, http.HTTPFlow)
|
||||||
request = f.request.copy()
|
request = f.request.copy()
|
||||||
@ -27,13 +27,15 @@ def cleanup_request(f: flow.Flow):
|
|||||||
return request
|
return request
|
||||||
|
|
||||||
|
|
||||||
def cleanup_response(f: flow.Flow):
|
def cleanup_response(f: flow.Flow)-> http.HTTPResponse:
|
||||||
if not hasattr(f, "response") or not f.response: # type: ignore
|
if not hasattr(f, "response") or not f.response:
|
||||||
raise exceptions.CommandError("Can't export flow with no response.")
|
raise exceptions.CommandError("Can't export flow with no response.")
|
||||||
|
assert isinstance(f, http.HTTPFlow)
|
||||||
response = f.response.copy() # type: ignore
|
response = f.response.copy() # type: ignore
|
||||||
response.decode(strict=False)
|
response.decode(strict=False)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def request_content_for_console(request: http.HTTPRequest) -> str:
|
def request_content_for_console(request: http.HTTPRequest) -> str:
|
||||||
try:
|
try:
|
||||||
text = request.get_text(strict=True)
|
text = request.get_text(strict=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user