mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
Merge pull request #3841 from mhils/sans-io-adjustments
Minor code style improvements, sync sans-io changes
This commit is contained in:
commit
6d3b8c9716
@ -1,13 +1,17 @@
|
|||||||
"""
|
"""
|
||||||
Parse scheme, host and port from a string.
|
Parse scheme, host and port from a string.
|
||||||
"""
|
"""
|
||||||
import collections
|
|
||||||
import re
|
import re
|
||||||
|
import typing
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from mitmproxy.net import check
|
from mitmproxy.net import check
|
||||||
|
|
||||||
ServerSpec = collections.namedtuple("ServerSpec", ["scheme", "address"])
|
|
||||||
|
class ServerSpec(typing.NamedTuple):
|
||||||
|
scheme: str
|
||||||
|
address: typing.Tuple[str, int]
|
||||||
|
|
||||||
|
|
||||||
server_spec_re = re.compile(
|
server_spec_re = re.compile(
|
||||||
r"""
|
r"""
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
import h2.exceptions
|
import h2.exceptions
|
||||||
import time
|
import time
|
||||||
import enum
|
import enum
|
||||||
@ -142,13 +144,13 @@ def validate_request_form(mode, request):
|
|||||||
allowed_request_forms = MODE_REQUEST_FORMS[mode]
|
allowed_request_forms = MODE_REQUEST_FORMS[mode]
|
||||||
if request.first_line_format not in allowed_request_forms:
|
if request.first_line_format not in allowed_request_forms:
|
||||||
if mode == HTTPMode.transparent:
|
if mode == HTTPMode.transparent:
|
||||||
err_message = (
|
err_message = textwrap.dedent((
|
||||||
"""
|
"""
|
||||||
Mitmproxy received an {} request even though it is not running
|
Mitmproxy received an {} request even though it is not running
|
||||||
in regular mode. This usually indicates a misconfiguration,
|
in regular mode. This usually indicates a misconfiguration,
|
||||||
please see the mitmproxy mode documentation for details.
|
please see the mitmproxy mode documentation for details.
|
||||||
"""
|
"""
|
||||||
).format("HTTP CONNECT" if request.first_line_format == "authority" else "absolute-form")
|
)).strip().format("HTTP CONNECT" if request.first_line_format == "authority" else "absolute-form")
|
||||||
else:
|
else:
|
||||||
err_message = "Invalid HTTP request form (expected: %s, got: %s)" % (
|
err_message = "Invalid HTTP request form (expected: %s, got: %s)" % (
|
||||||
" or ".join(allowed_request_forms), request.first_line_format
|
" or ".join(allowed_request_forms), request.first_line_format
|
||||||
|
Loading…
Reference in New Issue
Block a user