mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Merge pull request #1282 from dufferzafar/py3
Python 3 - mitmproxy.{protocol.http1, proxy, platform.pf}
This commit is contained in:
commit
b3502b92c8
@ -8,6 +8,7 @@ def lookup(address, port, s):
|
|||||||
|
|
||||||
Returns an (address, port) tuple, or None.
|
Returns an (address, port) tuple, or None.
|
||||||
"""
|
"""
|
||||||
|
s = s.decode()
|
||||||
spec = "%s:%s" % (address, port)
|
spec = "%s:%s" % (address, port)
|
||||||
for i in s.split("\n"):
|
for i in s.split("\n"):
|
||||||
if "ESTABLISHED:ESTABLISHED" in i and spec in i:
|
if "ESTABLISHED:ESTABLISHED" in i and spec in i:
|
||||||
|
@ -199,7 +199,7 @@ def process_proxy_options(parser, options):
|
|||||||
password_manager = authentication.PassManHtpasswd(
|
password_manager = authentication.PassManHtpasswd(
|
||||||
options.auth_htpasswd)
|
options.auth_htpasswd)
|
||||||
except ValueError as v:
|
except ValueError as v:
|
||||||
return parser.error(v.message)
|
return parser.error(v)
|
||||||
authenticator = authentication.BasicProxyAuth(password_manager, "mitmproxy")
|
authenticator = authentication.BasicProxyAuth(password_manager, "mitmproxy")
|
||||||
else:
|
else:
|
||||||
authenticator = authentication.NullProxyAuth(None)
|
authenticator = authentication.NullProxyAuth(None)
|
||||||
|
@ -18,14 +18,14 @@ class TestInvalidRequests(tservers.HTTPProxyTest):
|
|||||||
p = self.pathoc()
|
p = self.pathoc()
|
||||||
r = p.request("connect:'%s:%s'" % ("127.0.0.1", self.server2.port))
|
r = p.request("connect:'%s:%s'" % ("127.0.0.1", self.server2.port))
|
||||||
assert r.status_code == 400
|
assert r.status_code == 400
|
||||||
assert "Invalid HTTP request form" in r.content
|
assert b"Invalid HTTP request form" in r.content
|
||||||
|
|
||||||
def test_relative_request(self):
|
def test_relative_request(self):
|
||||||
p = self.pathoc_raw()
|
p = self.pathoc_raw()
|
||||||
p.connect()
|
p.connect()
|
||||||
r = p.request("get:/p/200")
|
r = p.request("get:/p/200")
|
||||||
assert r.status_code == 400
|
assert r.status_code == 400
|
||||||
assert "Invalid HTTP request form" in r.content
|
assert b"Invalid HTTP request form" in r.content
|
||||||
|
|
||||||
|
|
||||||
class TestExpectHeader(tservers.HTTPProxyTest):
|
class TestExpectHeader(tservers.HTTPProxyTest):
|
||||||
@ -43,8 +43,8 @@ class TestExpectHeader(tservers.HTTPProxyTest):
|
|||||||
)
|
)
|
||||||
client.wfile.flush()
|
client.wfile.flush()
|
||||||
|
|
||||||
assert client.rfile.readline() == "HTTP/1.1 100 Continue\r\n"
|
assert client.rfile.readline() == b"HTTP/1.1 100 Continue\r\n"
|
||||||
assert client.rfile.readline() == "\r\n"
|
assert client.rfile.readline() == b"\r\n"
|
||||||
|
|
||||||
client.wfile.write(b"0123456789abcdef\r\n")
|
client.wfile.write(b"0123456789abcdef\r\n")
|
||||||
client.wfile.flush()
|
client.wfile.flush()
|
||||||
|
2
tox.ini
2
tox.ini
@ -7,7 +7,7 @@ deps =
|
|||||||
codecov>=2.0.5
|
codecov>=2.0.5
|
||||||
passenv = CI TRAVIS_BUILD_ID TRAVIS TRAVIS_BRANCH TRAVIS_JOB_NUMBER TRAVIS_PULL_REQUEST TRAVIS_JOB_ID TRAVIS_REPO_SLUG TRAVIS_COMMIT
|
passenv = CI TRAVIS_BUILD_ID TRAVIS TRAVIS_BRANCH TRAVIS_JOB_NUMBER TRAVIS_PULL_REQUEST TRAVIS_JOB_ID TRAVIS_REPO_SLUG TRAVIS_COMMIT
|
||||||
setenv =
|
setenv =
|
||||||
PY3TESTS = test/netlib test/pathod/ test/mitmproxy/script test/mitmproxy/test_contentview.py test/mitmproxy/test_custom_contentview.py test/mitmproxy/test_app.py test/mitmproxy/test_controller.py test/mitmproxy/test_fuzzing.py test/mitmproxy/test_script.py test/mitmproxy/test_web_app.py test/mitmproxy/test_utils.py test/mitmproxy/test_stateobject.py test/mitmproxy/test_cmdline.py test/mitmproxy/test_contrib_tnetstring.py
|
PY3TESTS = test/netlib test/pathod/ test/mitmproxy/script test/mitmproxy/test_contentview.py test/mitmproxy/test_custom_contentview.py test/mitmproxy/test_app.py test/mitmproxy/test_controller.py test/mitmproxy/test_fuzzing.py test/mitmproxy/test_script.py test/mitmproxy/test_web_app.py test/mitmproxy/test_utils.py test/mitmproxy/test_stateobject.py test/mitmproxy/test_cmdline.py test/mitmproxy/test_contrib_tnetstring.py test/mitmproxy/test_proxy.py test/mitmproxy/test_protocol_http1.py test/mitmproxy/test_platform_pf.py
|
||||||
|
|
||||||
[testenv:py27]
|
[testenv:py27]
|
||||||
commands =
|
commands =
|
||||||
|
Loading…
Reference in New Issue
Block a user