From 8430f857b504a3e7406dc36e54dc32783569d0dd Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 20 Oct 2016 11:56:38 +1300 Subject: [PATCH] The final piece: netlib -> mitproxy.net --- .appveyor.yml | 2 +- .travis.yml | 2 +- MANIFEST.in | 3 +- README.rst | 7 ++-- docs/conf.py | 5 +-- docs/dev/testing.rst | 2 +- docs/modd.conf | 2 +- examples/har_dump.py | 2 +- mitmproxy/addons/stickycookie.py | 2 +- mitmproxy/addons/streambodies.py | 2 +- mitmproxy/addons/wsgiapp.py | 2 +- mitmproxy/certs.py | 2 +- mitmproxy/connections.py | 2 +- mitmproxy/contentviews.py | 4 +- mitmproxy/exceptions.py | 2 +- mitmproxy/export.py | 6 +-- mitmproxy/http.py | 12 +++--- mitmproxy/master.py | 4 +- {netlib => mitmproxy/net}/__init__.py | 0 {netlib => mitmproxy/net}/check.py | 0 mitmproxy/net/http/__init__.py | 15 ++++++++ .../net}/http/authentication.py | 0 {netlib => mitmproxy/net}/http/cookies.py | 0 {netlib => mitmproxy/net}/http/encoding.py | 0 {netlib => mitmproxy/net}/http/headers.py | 0 .../net}/http/http1/__init__.py | 0 .../net}/http/http1/assemble.py | 8 ++-- {netlib => mitmproxy/net}/http/http1/read.py | 10 ++--- mitmproxy/net/http/http2/__init__.py | 8 ++++ .../net}/http/http2/framereader.py | 0 {netlib => mitmproxy/net}/http/http2/utils.py | 2 +- {netlib => mitmproxy/net}/http/message.py | 6 +-- {netlib => mitmproxy/net}/http/multipart.py | 2 +- {netlib => mitmproxy/net}/http/request.py | 36 +++++++++--------- {netlib => mitmproxy/net}/http/response.py | 10 ++--- .../net}/http/status_codes.py | 0 {netlib => mitmproxy/net}/http/url.py | 2 +- {netlib => mitmproxy/net}/http/user_agents.py | 0 {netlib => mitmproxy/net}/socks.py | 4 +- {netlib => mitmproxy/net}/tcp.py | 0 .../net}/websockets/__init__.py | 0 {netlib => mitmproxy/net}/websockets/frame.py | 2 +- .../net}/websockets/masker.py | 0 {netlib => mitmproxy/net}/websockets/utils.py | 2 +- {netlib => mitmproxy/net}/wsgi.py | 4 +- mitmproxy/proxy/config.py | 6 +-- mitmproxy/proxy/modes/socks_proxy.py | 2 +- mitmproxy/proxy/protocol/http.py | 10 ++--- mitmproxy/proxy/protocol/http1.py | 2 +- mitmproxy/proxy/protocol/http2.py | 12 +++--- mitmproxy/proxy/protocol/http_replay.py | 2 +- mitmproxy/proxy/protocol/rawtcp.py | 4 +- mitmproxy/proxy/protocol/tls.py | 2 +- mitmproxy/proxy/protocol/websockets.py | 4 +- mitmproxy/proxy/server.py | 4 +- mitmproxy/test/tutils.py | 10 ++--- mitmproxy/tools/cmdline.py | 2 +- mitmproxy/tools/console/common.py | 6 +-- mitmproxy/tools/console/flowlist.py | 4 +- mitmproxy/tools/console/flowview.py | 4 +- .../tools/console/grideditor/col_subgrid.py | 2 +- mitmproxy/tools/console/grideditor/editors.py | 2 +- mitmproxy/tools/console/master.py | 2 +- mitmproxy/tools/console/statusbar.py | 4 +- mitmproxy/tools/dump.py | 2 +- mitmproxy/tools/web/master.py | 2 +- mitmproxy/utils/debug.py | 2 +- mitmproxy/utils/version_check.py | 5 +-- netlib/http/__init__.py | 15 -------- netlib/http/http2/__init__.py | 8 ---- pathod/language/http.py | 12 +++--- pathod/language/http2.py | 4 +- pathod/language/websockets.py | 18 ++++----- pathod/pathoc.py | 8 ++-- pathod/pathoc_cmdline.py | 4 +- pathod/pathod.py | 4 +- pathod/pathod_cmdline.py | 2 +- pathod/protocols/http.py | 2 +- pathod/protocols/http2.py | 22 +++++------ pathod/protocols/websockets.py | 2 +- release/README.mkd | 2 +- release/rtool.py | 2 +- setup.py | 1 - test/{netlib => mitmproxy/net}/__init__.py | 0 .../net}/data/clientcert/.gitignore | 0 .../net}/data/clientcert/client.cnf | 0 .../net}/data/clientcert/client.pem | 0 .../net}/data/clientcert/make | 0 test/{netlib => mitmproxy/net}/data/dercert | Bin .../net}/data/dhparam.pem | 0 test/{netlib => mitmproxy/net}/data/htpasswd | 0 .../{netlib => mitmproxy/net}/data/server.crt | 0 .../{netlib => mitmproxy/net}/data/server.key | 0 test/{netlib => mitmproxy/net}/data/text_cert | 0 .../net}/data/text_cert_2 | 0 .../net}/data/text_cert_weird1 | 0 .../net}/data/verificationcerts/9da13359.0 | 0 .../net}/data/verificationcerts/generate.py | 0 .../data/verificationcerts/self-signed.crt | 0 .../data/verificationcerts/self-signed.key | 0 .../data/verificationcerts/trusted-leaf.crt | 0 .../data/verificationcerts/trusted-leaf.key | 0 .../data/verificationcerts/trusted-root.crt | 0 .../data/verificationcerts/trusted-root.key | 0 .../data/verificationcerts/trusted-root.srl | 0 .../net}/http/__init__.py | 0 .../net}/http/http1/__init__.py | 0 .../net}/http/http1/test_assemble.py | 4 +- .../net}/http/http1/test_read.py | 4 +- .../net}/http/http2/__init__.py | 0 .../net}/http/http2/test_framereader.py | 0 .../net}/http/test_authentication.py | 2 +- .../net}/http/test_cookies.py | 2 +- .../net}/http/test_encoding.py | 2 +- .../net}/http/test_headers.py | 2 +- .../net}/http/test_message.py | 2 +- .../net}/http/test_multipart.py | 4 +- .../net}/http/test_request.py | 2 +- .../net}/http/test_response.py | 6 +-- .../net}/http/test_status_codes.py | 2 +- .../net}/http/test_url.py | 2 +- .../net}/http/test_user_agents.py | 2 +- test/{netlib => mitmproxy/net}/test_check.py | 2 +- .../{netlib => mitmproxy/net}/test_imports.py | 0 test/{netlib => mitmproxy/net}/test_socks.py | 4 +- test/{netlib => mitmproxy/net}/test_tcp.py | 2 +- test/{netlib => mitmproxy/net}/test_wsgi.py | 4 +- .../net}/tools/getcertnames | 2 +- test/{netlib => mitmproxy/net}/tservers.py | 2 +- .../net}/websockets/__init__.py | 0 .../net}/websockets/test_frame.py | 2 +- .../net}/websockets/test_masker.py | 2 +- .../net}/websockets/test_utils.py | 4 +- test/mitmproxy/protocol/test_http1.py | 4 +- test/mitmproxy/protocol/test_http2.py | 16 ++++---- test/mitmproxy/protocol/test_websockets.py | 14 +++---- test/mitmproxy/test_contentview.py | 4 +- test/mitmproxy/test_custom_contentview.py | 2 +- test/mitmproxy/test_examples.py | 4 +- test/mitmproxy/test_flow.py | 2 +- test/mitmproxy/test_flow_export.py | 2 +- test/mitmproxy/test_proxy.py | 2 +- test/mitmproxy/test_server.py | 18 ++++----- test/pathod/test_language_http2.py | 4 +- test/pathod/test_language_websocket.py | 12 +++--- test/pathod/test_pathoc.py | 6 +-- test/pathod/test_pathod.py | 2 +- test/pathod/test_protocols_http2.py | 26 ++++++------- test/pathod/tutils.py | 2 +- tox.ini | 2 +- 150 files changed, 275 insertions(+), 282 deletions(-) rename {netlib => mitmproxy/net}/__init__.py (100%) rename {netlib => mitmproxy/net}/check.py (100%) create mode 100644 mitmproxy/net/http/__init__.py rename {netlib => mitmproxy/net}/http/authentication.py (100%) rename {netlib => mitmproxy/net}/http/cookies.py (100%) rename {netlib => mitmproxy/net}/http/encoding.py (100%) rename {netlib => mitmproxy/net}/http/headers.py (100%) rename {netlib => mitmproxy/net}/http/http1/__init__.py (100%) rename {netlib => mitmproxy/net}/http/http1/assemble.py (92%) rename {netlib => mitmproxy/net}/http/http1/read.py (98%) create mode 100644 mitmproxy/net/http/http2/__init__.py rename {netlib => mitmproxy/net}/http/http2/framereader.py (100%) rename {netlib => mitmproxy/net}/http/http2/utils.py (96%) rename {netlib => mitmproxy/net}/http/message.py (98%) rename {netlib => mitmproxy/net}/http/multipart.py (95%) rename {netlib => mitmproxy/net}/http/request.py (90%) rename {netlib => mitmproxy/net}/http/response.py (95%) rename {netlib => mitmproxy/net}/http/status_codes.py (100%) rename {netlib => mitmproxy/net}/http/url.py (99%) rename {netlib => mitmproxy/net}/http/user_agents.py (100%) rename {netlib => mitmproxy/net}/socks.py (99%) rename {netlib => mitmproxy/net}/tcp.py (100%) rename {netlib => mitmproxy/net}/websockets/__init__.py (100%) rename {netlib => mitmproxy/net}/websockets/frame.py (99%) rename {netlib => mitmproxy/net}/websockets/masker.py (100%) rename {netlib => mitmproxy/net}/websockets/utils.py (98%) rename {netlib => mitmproxy/net}/wsgi.py (98%) delete mode 100644 netlib/http/__init__.py delete mode 100644 netlib/http/http2/__init__.py rename test/{netlib => mitmproxy/net}/__init__.py (100%) rename test/{netlib => mitmproxy/net}/data/clientcert/.gitignore (100%) rename test/{netlib => mitmproxy/net}/data/clientcert/client.cnf (100%) rename test/{netlib => mitmproxy/net}/data/clientcert/client.pem (100%) rename test/{netlib => mitmproxy/net}/data/clientcert/make (100%) rename test/{netlib => mitmproxy/net}/data/dercert (100%) rename test/{netlib => mitmproxy/net}/data/dhparam.pem (100%) rename test/{netlib => mitmproxy/net}/data/htpasswd (100%) rename test/{netlib => mitmproxy/net}/data/server.crt (100%) rename test/{netlib => mitmproxy/net}/data/server.key (100%) rename test/{netlib => mitmproxy/net}/data/text_cert (100%) rename test/{netlib => mitmproxy/net}/data/text_cert_2 (100%) rename test/{netlib => mitmproxy/net}/data/text_cert_weird1 (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/9da13359.0 (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/generate.py (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/self-signed.crt (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/self-signed.key (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/trusted-leaf.crt (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/trusted-leaf.key (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/trusted-root.crt (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/trusted-root.key (100%) rename test/{netlib => mitmproxy/net}/data/verificationcerts/trusted-root.srl (100%) rename test/{netlib => mitmproxy/net}/http/__init__.py (100%) rename test/{netlib => mitmproxy/net}/http/http1/__init__.py (100%) rename test/{netlib => mitmproxy/net}/http/http1/test_assemble.py (97%) rename test/{netlib => mitmproxy/net}/http/http1/test_read.py (99%) rename test/{netlib => mitmproxy/net}/http/http2/__init__.py (100%) rename test/{netlib => mitmproxy/net}/http/http2/test_framereader.py (100%) rename test/{netlib => mitmproxy/net}/http/test_authentication.py (98%) rename test/{netlib => mitmproxy/net}/http/test_cookies.py (99%) rename test/{netlib => mitmproxy/net}/http/test_encoding.py (98%) rename test/{netlib => mitmproxy/net}/http/test_headers.py (97%) rename test/{netlib => mitmproxy/net}/http/test_message.py (99%) rename test/{netlib => mitmproxy/net}/http/test_multipart.py (87%) rename test/{netlib => mitmproxy/net}/http/test_request.py (99%) rename test/{netlib => mitmproxy/net}/http/test_response.py (97%) rename test/{netlib => mitmproxy/net}/http/test_status_codes.py (73%) rename test/{netlib => mitmproxy/net}/http/test_url.py (98%) rename test/{netlib => mitmproxy/net}/http/test_user_agents.py (75%) rename test/{netlib => mitmproxy/net}/test_check.py (87%) rename test/{netlib => mitmproxy/net}/test_imports.py (100%) rename test/{netlib => mitmproxy/net}/test_socks.py (98%) rename test/{netlib => mitmproxy/net}/test_tcp.py (99%) rename test/{netlib => mitmproxy/net}/test_wsgi.py (97%) rename test/{netlib => mitmproxy/net}/tools/getcertnames (94%) rename test/{netlib => mitmproxy/net}/tservers.py (99%) rename test/{netlib => mitmproxy/net}/websockets/__init__.py (100%) rename test/{netlib => mitmproxy/net}/websockets/test_frame.py (99%) rename test/{netlib => mitmproxy/net}/websockets/test_masker.py (95%) rename test/{netlib => mitmproxy/net}/websockets/test_utils.py (98%) diff --git a/.appveyor.yml b/.appveyor.yml index 388686289..746e0fd14 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -23,7 +23,7 @@ install: - "pip install -U tox" test_script: - - ps: "tox -- --cov netlib --cov mitmproxy --cov pathod -v" + - ps: "tox -- --cov mitmproxy --cov pathod -v" deploy_script: ps: | diff --git a/.travis.yml b/.travis.yml index d160a96ee..d7cb7027d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,7 @@ install: fi - pip install tox -script: tox -- --cov netlib --cov mitmproxy --cov pathod -v +script: tox -- --cov mitmproxy --cov pathod -v after_success: - | diff --git a/MANIFEST.in b/MANIFEST.in index 440a14ed7..404936e84 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ graft mitmproxy graft pathod -graft netlib -recursive-exclude * *.pyc *.pyo *.swo *.swp *.map \ No newline at end of file +recursive-exclude * *.pyc *.pyo *.swo *.swp *.map diff --git a/README.rst b/README.rst index 146a2c439..cdeada2d8 100644 --- a/README.rst +++ b/README.rst @@ -3,8 +3,7 @@ mitmproxy |travis| |appveyor| |coverage| |latest_release| |python_versions| -This repository contains the **mitmproxy** and **pathod** projects, as well as -their shared networking library, **netlib**. +This repository contains the **mitmproxy** and **pathod** projects. ``mitmproxy`` is an interactive, SSL-capable intercepting proxy with a console interface. @@ -64,7 +63,7 @@ virtualenv_ installed (you can find installation instructions for virtualenv The *dev* script will create a virtualenv environment in a directory called "venv", and install all mandatory and optional dependencies into it. The -primary mitmproxy components - mitmproxy, netlib and pathod - are installed as +primary mitmproxy components - mitmproxy and pathod - are installed as "editable", so any changes to the source in the repository will be reflected live in the virtualenv. @@ -144,7 +143,7 @@ PR checks will fail and block merging. We are using this command to check for st .. code-block:: text - flake8 --jobs 8 --count mitmproxy netlib pathod examples test + flake8 --jobs 8 --count mitmproxy pathod examples test .. |mitmproxy_site| image:: https://shields.mitmproxy.org/api/https%3A%2F%2F-mitmproxy.org-blue.svg diff --git a/docs/conf.py b/docs/conf.py index ce942aa94..d7793b79c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -231,10 +231,7 @@ def linkcode_resolve(domain, info): _, line = inspect.getsourcelines(obj) except (TypeError, IOError): return None - if spath.rfind("netlib") > -1: - off = spath.rfind("netlib") - mpath = spath[off:] - elif spath.rfind("mitmproxy") > -1: + if spath.rfind("mitmproxy") > -1: off = spath.rfind("mitmproxy") mpath = spath[off:] else: diff --git a/docs/dev/testing.rst b/docs/dev/testing.rst index 315b9bc90..b86efce16 100644 --- a/docs/dev/testing.rst +++ b/docs/dev/testing.rst @@ -10,7 +10,7 @@ suitable extension to the test suite. Our tests are written for the `py.test`_ or nose_ test frameworks. At the point where you send your pull request, a command like this: ->>> py.test --cov mitmproxy --cov netlib +>>> py.test --cov mitmproxy Should give output something like this: diff --git a/docs/modd.conf b/docs/modd.conf index bc91238c0..0e8f0dced 100644 --- a/docs/modd.conf +++ b/docs/modd.conf @@ -1,6 +1,6 @@ @build = ./_build -** !_build/** ../netlib/**/*.py ../mitmproxy/**/*.py { +** !_build/** ../mitmproxy/**/*.py { prep: sphinx-build -W -d @build/doctrees -b html . @build/html daemon: devd -m @build/html } diff --git a/examples/har_dump.py b/examples/har_dump.py index d01e6cddc..560b9adca 100644 --- a/examples/har_dump.py +++ b/examples/har_dump.py @@ -16,7 +16,7 @@ import mitmproxy from mitmproxy import version from mitmproxy.utils import strutils -from netlib.http import cookies +from mitmproxy.net.http import cookies HAR = {} diff --git a/mitmproxy/addons/stickycookie.py b/mitmproxy/addons/stickycookie.py index d89bd92d1..27d78646b 100644 --- a/mitmproxy/addons/stickycookie.py +++ b/mitmproxy/addons/stickycookie.py @@ -1,7 +1,7 @@ import collections from http import cookiejar -from netlib.http import cookies +from mitmproxy.net.http import cookies from mitmproxy import exceptions from mitmproxy import flowfilter diff --git a/mitmproxy/addons/streambodies.py b/mitmproxy/addons/streambodies.py index bd8958b04..88cb74f33 100644 --- a/mitmproxy/addons/streambodies.py +++ b/mitmproxy/addons/streambodies.py @@ -1,4 +1,4 @@ -from netlib.http import http1 +from mitmproxy.net.http import http1 from mitmproxy import exceptions from mitmproxy import ctx diff --git a/mitmproxy/addons/wsgiapp.py b/mitmproxy/addons/wsgiapp.py index 0879a87be..85d09a0ae 100644 --- a/mitmproxy/addons/wsgiapp.py +++ b/mitmproxy/addons/wsgiapp.py @@ -1,7 +1,7 @@ from mitmproxy import ctx from mitmproxy import exceptions -from netlib import wsgi +from mitmproxy.net import wsgi from mitmproxy import version diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index 9cb8a40ed..83db4e6e3 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -193,7 +193,7 @@ class CertStore: @staticmethod def load_dhparam(path): - # netlib<=0.10 doesn't generate a dhparam file. + # mitmproxy<=0.10 doesn't generate a dhparam file. # Create it now if neccessary. if not os.path.exists(path): with open(path, "wb") as f: diff --git a/mitmproxy/connections.py b/mitmproxy/connections.py index 6b39ac207..015d06894 100644 --- a/mitmproxy/connections.py +++ b/mitmproxy/connections.py @@ -5,7 +5,7 @@ import os from mitmproxy import stateobject from mitmproxy import certs -from netlib import tcp +from mitmproxy.net import tcp class ClientConnection(tcp.BaseHandler, stateobject.StateObject): diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index a171f36bf..b7f15d8d7 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -33,10 +33,10 @@ from PIL import ExifTags from PIL import Image from mitmproxy import exceptions from mitmproxy.contrib.wbxml import ASCommandResponse -from netlib import http +from mitmproxy.net import http from mitmproxy.types import multidict from mitmproxy.utils import strutils -from netlib.http import url +from mitmproxy.net.http import url try: import pyamf diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py index a7ecf17f1..309b81892 100644 --- a/mitmproxy/exceptions.py +++ b/mitmproxy/exceptions.py @@ -112,7 +112,7 @@ class AddonHalt(MitmproxyException): class NetlibException(MitmproxyException): """ - Base class for all exceptions thrown by netlib. + Base class for all exceptions thrown by mitmproxy.net. """ def __init__(self, message=None): super().__init__(message) diff --git a/mitmproxy/export.py b/mitmproxy/export.py index e5f4d34a5..d9a88849d 100644 --- a/mitmproxy/export.py +++ b/mitmproxy/export.py @@ -3,7 +3,7 @@ import re import textwrap import urllib -import netlib.http +import mitmproxy.net.http def _native(s): @@ -89,9 +89,9 @@ def python_code(flow): return code -def is_json(headers: netlib.http.Headers, content: bytes) -> bool: +def is_json(headers: mitmproxy.net.http.Headers, content: bytes) -> bool: if headers: - ct = netlib.http.parse_content_type(headers.get("content-type", "")) + ct = mitmproxy.net.http.parse_content_type(headers.get("content-type", "")) if ct and "%s/%s" % (ct[0], ct[1]) == "application/json": try: return json.loads(content.decode("utf8", "surrogateescape")) diff --git a/mitmproxy/http.py b/mitmproxy/http.py index 4474ca3be..99e126feb 100644 --- a/mitmproxy/http.py +++ b/mitmproxy/http.py @@ -1,9 +1,9 @@ import cgi from mitmproxy import flow -from netlib import http +from mitmproxy.net import http from mitmproxy import version -from netlib import tcp +from mitmproxy.net import tcp class HTTPRequest(http.Request): @@ -12,7 +12,7 @@ class HTTPRequest(http.Request): A mitmproxy HTTP request. """ - # This is a very thin wrapper on top of :py:class:`netlib.http.Request` and + # This is a very thin wrapper on top of :py:class:`mitmproxy.net.http.Request` and # may be removed in the future. def __init__( @@ -73,7 +73,7 @@ class HTTPRequest(http.Request): @classmethod def wrap(self, request): """ - Wraps an existing :py:class:`netlib.http.Request`. + Wraps an existing :py:class:`mitmproxy.net.http.Request`. """ req = HTTPRequest( first_line_format=request.data.first_line_format, @@ -99,7 +99,7 @@ class HTTPResponse(http.Response): """ A mitmproxy HTTP response. """ - # This is a very thin wrapper on top of :py:class:`netlib.http.Response` and + # This is a very thin wrapper on top of :py:class:`mitmproxy.net.http.Response` and # may be removed in the future. def __init__( @@ -131,7 +131,7 @@ class HTTPResponse(http.Response): @classmethod def wrap(self, response): """ - Wraps an existing :py:class:`netlib.http.Response`. + Wraps an existing :py:class:`mitmproxy.net.http.Response`. """ resp = HTTPResponse( http_version=response.data.http_version, diff --git a/mitmproxy/master.py b/mitmproxy/master.py index 2e57e57d3..31ce17a3a 100644 --- a/mitmproxy/master.py +++ b/mitmproxy/master.py @@ -15,7 +15,7 @@ from mitmproxy import log from mitmproxy import io from mitmproxy.proxy.protocol import http_replay from mitmproxy.types import basethread -import netlib.http +import mitmproxy.net.http from . import ctx as mitmproxy_ctx @@ -122,7 +122,7 @@ class Master: s = connections.ServerConnection.make_dummy((host, port)) f = http.HTTPFlow(c, s) - headers = netlib.http.Headers() + headers = mitmproxy.net.http.Headers() req = http.HTTPRequest( "absolute", diff --git a/netlib/__init__.py b/mitmproxy/net/__init__.py similarity index 100% rename from netlib/__init__.py rename to mitmproxy/net/__init__.py diff --git a/netlib/check.py b/mitmproxy/net/check.py similarity index 100% rename from netlib/check.py rename to mitmproxy/net/check.py diff --git a/mitmproxy/net/http/__init__.py b/mitmproxy/net/http/__init__.py new file mode 100644 index 000000000..7e290bdc6 --- /dev/null +++ b/mitmproxy/net/http/__init__.py @@ -0,0 +1,15 @@ +from mitmproxy.net.http.request import Request +from mitmproxy.net.http.response import Response +from mitmproxy.net.http.message import Message +from mitmproxy.net.http.headers import Headers, parse_content_type +from mitmproxy.net.http.message import decoded +from mitmproxy.net.http import http1, http2, status_codes, multipart + +__all__ = [ + "Request", + "Response", + "Message", + "Headers", "parse_content_type", + "decoded", + "http1", "http2", "status_codes", "multipart", +] diff --git a/netlib/http/authentication.py b/mitmproxy/net/http/authentication.py similarity index 100% rename from netlib/http/authentication.py rename to mitmproxy/net/http/authentication.py diff --git a/netlib/http/cookies.py b/mitmproxy/net/http/cookies.py similarity index 100% rename from netlib/http/cookies.py rename to mitmproxy/net/http/cookies.py diff --git a/netlib/http/encoding.py b/mitmproxy/net/http/encoding.py similarity index 100% rename from netlib/http/encoding.py rename to mitmproxy/net/http/encoding.py diff --git a/netlib/http/headers.py b/mitmproxy/net/http/headers.py similarity index 100% rename from netlib/http/headers.py rename to mitmproxy/net/http/headers.py diff --git a/netlib/http/http1/__init__.py b/mitmproxy/net/http/http1/__init__.py similarity index 100% rename from netlib/http/http1/__init__.py rename to mitmproxy/net/http/http1/__init__.py diff --git a/netlib/http/http1/assemble.py b/mitmproxy/net/http/http1/assemble.py similarity index 92% rename from netlib/http/http1/assemble.py rename to mitmproxy/net/http/http1/assemble.py index e0a91ad80..d718589f4 100644 --- a/netlib/http/http1/assemble.py +++ b/mitmproxy/net/http/http1/assemble.py @@ -1,4 +1,4 @@ -import netlib.http.url +import mitmproxy.net.http.url from mitmproxy import exceptions @@ -44,7 +44,7 @@ def assemble_body(headers, body_chunks): def _assemble_request_line(request_data): """ Args: - request_data (netlib.http.request.RequestData) + request_data (mitmproxy.net.http.request.RequestData) """ form = request_data.first_line_format if form == "relative": @@ -76,11 +76,11 @@ def _assemble_request_line(request_data): def _assemble_request_headers(request_data): """ Args: - request_data (netlib.http.request.RequestData) + request_data (mitmproxy.net.http.request.RequestData) """ headers = request_data.headers.copy() if "host" not in headers and request_data.scheme and request_data.host and request_data.port: - headers["host"] = netlib.http.url.hostport( + headers["host"] = mitmproxy.net.http.url.hostport( request_data.scheme, request_data.host, request_data.port diff --git a/netlib/http/http1/read.py b/mitmproxy/net/http/http1/read.py similarity index 98% rename from netlib/http/http1/read.py rename to mitmproxy/net/http/http1/read.py index e6b22863e..6eb30709b 100644 --- a/netlib/http/http1/read.py +++ b/mitmproxy/net/http/http1/read.py @@ -2,11 +2,11 @@ import time import sys import re -from netlib.http import request -from netlib.http import response -from netlib.http import headers -from netlib.http import url -from netlib import check +from mitmproxy.net.http import request +from mitmproxy.net.http import response +from mitmproxy.net.http import headers +from mitmproxy.net.http import url +from mitmproxy.net import check from mitmproxy import exceptions diff --git a/mitmproxy/net/http/http2/__init__.py b/mitmproxy/net/http/http2/__init__.py new file mode 100644 index 000000000..7027006be --- /dev/null +++ b/mitmproxy/net/http/http2/__init__.py @@ -0,0 +1,8 @@ +from mitmproxy.net.http.http2.framereader import read_raw_frame, parse_frame +from mitmproxy.net.http.http2.utils import parse_headers + +__all__ = [ + "read_raw_frame", + "parse_frame", + "parse_headers", +] diff --git a/netlib/http/http2/framereader.py b/mitmproxy/net/http/http2/framereader.py similarity index 100% rename from netlib/http/http2/framereader.py rename to mitmproxy/net/http/http2/framereader.py diff --git a/netlib/http/http2/utils.py b/mitmproxy/net/http/http2/utils.py similarity index 96% rename from netlib/http/http2/utils.py rename to mitmproxy/net/http/http2/utils.py index 164bacc8a..62a59c727 100644 --- a/netlib/http/http2/utils.py +++ b/mitmproxy/net/http/http2/utils.py @@ -1,4 +1,4 @@ -from netlib.http import url +from mitmproxy.net.http import url def parse_headers(headers): diff --git a/netlib/http/message.py b/mitmproxy/net/http/message.py similarity index 98% rename from netlib/http/message.py rename to mitmproxy/net/http/message.py index 772a124e6..af1d16bea 100644 --- a/netlib/http/message.py +++ b/mitmproxy/net/http/message.py @@ -3,9 +3,9 @@ import warnings from typing import Optional from mitmproxy.utils import strutils -from netlib.http import encoding +from mitmproxy.net.http import encoding from mitmproxy.types import serializable -from netlib.http import headers +from mitmproxy.net.http import headers # While headers _should_ be ASCII, it's not uncommon for certain headers to be utf-8 encoded. @@ -69,7 +69,7 @@ class Message(serializable.Serializable): Message headers object Returns: - netlib.http.Headers + mitmproxy.net.http.Headers """ return self.data.headers diff --git a/netlib/http/multipart.py b/mitmproxy/net/http/multipart.py similarity index 95% rename from netlib/http/multipart.py rename to mitmproxy/net/http/multipart.py index 536b2809d..a854d47fd 100644 --- a/netlib/http/multipart.py +++ b/mitmproxy/net/http/multipart.py @@ -1,6 +1,6 @@ import re -from netlib.http import headers +from mitmproxy.net.http import headers def decode(hdrs, content): diff --git a/netlib/http/request.py b/mitmproxy/net/http/request.py similarity index 90% rename from netlib/http/request.py rename to mitmproxy/net/http/request.py index 16b0c986b..c3d853635 100644 --- a/netlib/http/request.py +++ b/mitmproxy/net/http/request.py @@ -3,11 +3,11 @@ import urllib from mitmproxy.types import multidict from mitmproxy.utils import strutils -from netlib.http import multipart -from netlib.http import cookies -from netlib.http import headers as nheaders -from netlib.http import message -import netlib.http.url +from mitmproxy.net.http import multipart +from mitmproxy.net.http import cookies +from mitmproxy.net.http import headers as nheaders +from mitmproxy.net.http import message +import mitmproxy.net.http.url # This regex extracts & splits the host header into host and port. # Handles the edge case of IPv6 addresses containing colons. @@ -203,11 +203,11 @@ class Request(message.Message): """ if self.first_line_format == "authority": return "%s:%d" % (self.host, self.port) - return netlib.http.url.unparse(self.scheme, self.host, self.port, self.path) + return mitmproxy.net.http.url.unparse(self.scheme, self.host, self.port, self.path) @url.setter def url(self, url): - self.scheme, self.host, self.port, self.path = netlib.http.url.parse(url) + self.scheme, self.host, self.port, self.path = mitmproxy.net.http.url.parse(url) def _parse_host_header(self): """Extract the host and port from Host header""" @@ -243,12 +243,12 @@ class Request(message.Message): """ if self.first_line_format == "authority": return "%s:%d" % (self.pretty_host, self.port) - return netlib.http.url.unparse(self.scheme, self.pretty_host, self.port, self.path) + return mitmproxy.net.http.url.unparse(self.scheme, self.pretty_host, self.port, self.path) @property def query(self) -> multidict.MultiDictView: """ - The request query string as an :py:class:`~netlib.multidict.MultiDictView` object. + The request query string as an :py:class:`~mitmproxy.net.multidict.MultiDictView` object. """ return multidict.MultiDictView( self._get_query, @@ -257,10 +257,10 @@ class Request(message.Message): def _get_query(self): query = urllib.parse.urlparse(self.url).query - return tuple(netlib.http.url.decode(query)) + return tuple(mitmproxy.net.http.url.decode(query)) def _set_query(self, query_data): - query = netlib.http.url.encode(query_data) + query = mitmproxy.net.http.url.encode(query_data) _, _, path, params, _, fragment = urllib.parse.urlparse(self.url) self.path = urllib.parse.urlunparse(["", "", path, params, query, fragment]) @@ -273,7 +273,7 @@ class Request(message.Message): """ The request cookies. - An empty :py:class:`~netlib.multidict.MultiDictView` object if the cookie monster ate them all. + An empty :py:class:`~mitmproxy.net.multidict.MultiDictView` object if the cookie monster ate them all. """ return multidict.MultiDictView( self._get_cookies, @@ -301,11 +301,11 @@ class Request(message.Message): # This needs to be a tuple so that it's immutable. # Otherwise, this would fail silently: # request.path_components.append("foo") - return tuple(netlib.http.url.unquote(i) for i in path.split("/") if i) + return tuple(mitmproxy.net.http.url.unquote(i) for i in path.split("/") if i) @path_components.setter def path_components(self, components): - components = map(lambda x: netlib.http.url.quote(x, safe=""), components) + components = map(lambda x: mitmproxy.net.http.url.quote(x, safe=""), components) path = "/" + "/".join(components) _, _, _, params, query, fragment = urllib.parse.urlparse(self.url) self.path = urllib.parse.urlunparse(["", "", path, params, query, fragment]) @@ -347,7 +347,7 @@ class Request(message.Message): @property def urlencoded_form(self): """ - The URL-encoded form data as an :py:class:`~netlib.multidict.MultiDictView` object. + The URL-encoded form data as an :py:class:`~mitmproxy.net.multidict.MultiDictView` object. An empty multidict.MultiDictView if the content-type indicates non-form data or the content could not be parsed. """ @@ -360,7 +360,7 @@ class Request(message.Message): is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get("content-type", "").lower() if is_valid_content_type: try: - return tuple(netlib.http.url.decode(self.content)) + return tuple(mitmproxy.net.http.url.decode(self.content)) except ValueError: pass return () @@ -371,7 +371,7 @@ class Request(message.Message): This will overwrite the existing content if there is one. """ self.headers["content-type"] = "application/x-www-form-urlencoded" - self.content = netlib.http.url.encode(form_data).encode() + self.content = mitmproxy.net.http.url.encode(form_data).encode() @urlencoded_form.setter def urlencoded_form(self, value): @@ -380,7 +380,7 @@ class Request(message.Message): @property def multipart_form(self): """ - The multipart form data as an :py:class:`~netlib.multidict.MultiDictView` object. + The multipart form data as an :py:class:`~mitmproxy.net.multidict.MultiDictView` object. None if the content-type indicates non-form data. """ return multidict.MultiDictView( diff --git a/netlib/http/response.py b/mitmproxy/net/http/response.py similarity index 95% rename from netlib/http/response.py rename to mitmproxy/net/http/response.py index 4d1d5d24b..b458a3d8a 100644 --- a/netlib/http/response.py +++ b/mitmproxy/net/http/response.py @@ -2,10 +2,10 @@ import time from email.utils import parsedate_tz, formatdate, mktime_tz from mitmproxy.utils import human from mitmproxy.types import multidict -from netlib.http import cookies -from netlib.http import headers as nheaders -from netlib.http import message -from netlib.http import status_codes +from mitmproxy.net.http import cookies +from mitmproxy.net.http import headers as nheaders +from mitmproxy.net.http import message +from mitmproxy.net.http import status_codes from typing import AnyStr from typing import Dict from typing import Iterable @@ -131,7 +131,7 @@ class Response(message.Message): def cookies(self) -> multidict.MultiDictView: """ The response cookies. A possibly empty - :py:class:`~netlib.multidict.MultiDictView`, where the keys are cookie + :py:class:`~mitmproxy.net.multidict.MultiDictView`, where the keys are cookie name strings, and values are (value, attr) tuples. Value is a string, and attr is an MultiDictView containing cookie attributes. Within attrs, unary attributes (e.g. HTTPOnly) are indicated by a Null value. diff --git a/netlib/http/status_codes.py b/mitmproxy/net/http/status_codes.py similarity index 100% rename from netlib/http/status_codes.py rename to mitmproxy/net/http/status_codes.py diff --git a/netlib/http/url.py b/mitmproxy/net/http/url.py similarity index 99% rename from netlib/http/url.py rename to mitmproxy/net/http/url.py index 3ca581202..ff3d52641 100644 --- a/netlib/http/url.py +++ b/mitmproxy/net/http/url.py @@ -2,7 +2,7 @@ import urllib from typing import Sequence from typing import Tuple -from netlib import check +from mitmproxy.net import check # PY2 workaround diff --git a/netlib/http/user_agents.py b/mitmproxy/net/http/user_agents.py similarity index 100% rename from netlib/http/user_agents.py rename to mitmproxy/net/http/user_agents.py diff --git a/netlib/socks.py b/mitmproxy/net/socks.py similarity index 99% rename from netlib/socks.py rename to mitmproxy/net/socks.py index 377308a81..115949f5d 100644 --- a/netlib/socks.py +++ b/mitmproxy/net/socks.py @@ -2,8 +2,8 @@ import struct import array import ipaddress -from netlib import tcp -from netlib import check +from mitmproxy.net import tcp +from mitmproxy.net import check from mitmproxy.types import bidi diff --git a/netlib/tcp.py b/mitmproxy/net/tcp.py similarity index 100% rename from netlib/tcp.py rename to mitmproxy/net/tcp.py diff --git a/netlib/websockets/__init__.py b/mitmproxy/net/websockets/__init__.py similarity index 100% rename from netlib/websockets/__init__.py rename to mitmproxy/net/websockets/__init__.py diff --git a/netlib/websockets/frame.py b/mitmproxy/net/websockets/frame.py similarity index 99% rename from netlib/websockets/frame.py rename to mitmproxy/net/websockets/frame.py index bc4ae43a1..bd5f67ddc 100644 --- a/netlib/websockets/frame.py +++ b/mitmproxy/net/websockets/frame.py @@ -2,7 +2,7 @@ import os import struct import io -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy.utils import strutils from mitmproxy.utils import bits from mitmproxy.utils import human diff --git a/netlib/websockets/masker.py b/mitmproxy/net/websockets/masker.py similarity index 100% rename from netlib/websockets/masker.py rename to mitmproxy/net/websockets/masker.py diff --git a/netlib/websockets/utils.py b/mitmproxy/net/websockets/utils.py similarity index 98% rename from netlib/websockets/utils.py rename to mitmproxy/net/websockets/utils.py index 980436622..d0b168ce7 100644 --- a/netlib/websockets/utils.py +++ b/mitmproxy/net/websockets/utils.py @@ -8,7 +8,7 @@ import base64 import hashlib import os -from netlib import http +from mitmproxy.net import http from mitmproxy.utils import strutils MAGIC = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11' diff --git a/netlib/wsgi.py b/mitmproxy/net/wsgi.py similarity index 98% rename from netlib/wsgi.py rename to mitmproxy/net/wsgi.py index 5a54cd706..b2705ea1d 100644 --- a/netlib/wsgi.py +++ b/mitmproxy/net/wsgi.py @@ -3,8 +3,8 @@ import traceback import urllib import io -from netlib import http -from netlib import tcp +from mitmproxy.net import http +from mitmproxy.net import tcp from mitmproxy.utils import strutils diff --git a/mitmproxy/proxy/config.py b/mitmproxy/proxy/config.py index 86b68ee57..7df9e6929 100644 --- a/mitmproxy/proxy/config.py +++ b/mitmproxy/proxy/config.py @@ -11,9 +11,9 @@ from OpenSSL import SSL, crypto from mitmproxy import exceptions from mitmproxy import options as moptions from mitmproxy import certs -from netlib import tcp -from netlib.http import authentication -from netlib.http import url +from mitmproxy.net import tcp +from mitmproxy.net.http import authentication +from mitmproxy.net.http import url CONF_BASENAME = "mitmproxy" diff --git a/mitmproxy/proxy/modes/socks_proxy.py b/mitmproxy/proxy/modes/socks_proxy.py index 175453b04..adcd8fc1d 100644 --- a/mitmproxy/proxy/modes/socks_proxy.py +++ b/mitmproxy/proxy/modes/socks_proxy.py @@ -1,6 +1,6 @@ from mitmproxy import exceptions from mitmproxy.proxy import protocol -from netlib import socks +from mitmproxy.net import socks class Socks5Proxy(protocol.Layer, protocol.ServerConnectionMixin): diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py index 6bc06502c..a47fb4554 100644 --- a/mitmproxy/proxy/protocol/http.py +++ b/mitmproxy/proxy/protocol/http.py @@ -6,9 +6,9 @@ from mitmproxy import http from mitmproxy import flow from mitmproxy.proxy.protocol import base from mitmproxy.proxy.protocol import websockets as pwebsockets -import netlib.http -from netlib import tcp -from netlib import websockets +import mitmproxy.net.http +from mitmproxy.net import tcp +from mitmproxy.net import websockets class _HttpTransmissionLayer(base.Layer): @@ -422,13 +422,13 @@ class HttpLayer(base.Layer): self.send_response(http.make_error_response( 401, "Authentication Required", - netlib.http.Headers(**self.config.authenticator.auth_challenge_headers()) + mitmproxy.net.http.Headers(**self.config.authenticator.auth_challenge_headers()) )) else: self.send_response(http.make_error_response( 407, "Proxy Authentication Required", - netlib.http.Headers(**self.config.authenticator.auth_challenge_headers()) + mitmproxy.net.http.Headers(**self.config.authenticator.auth_challenge_headers()) )) return False return True diff --git a/mitmproxy/proxy/protocol/http1.py b/mitmproxy/proxy/protocol/http1.py index 968d32498..713c48a76 100644 --- a/mitmproxy/proxy/protocol/http1.py +++ b/mitmproxy/proxy/protocol/http1.py @@ -1,6 +1,6 @@ from mitmproxy import http from mitmproxy.proxy.protocol import http as httpbase -from netlib.http import http1 +from mitmproxy.net.http import http1 class Http1Layer(httpbase._HttpTransmissionLayer): diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py index d0b0720d8..f635e7108 100644 --- a/mitmproxy/proxy/protocol/http2.py +++ b/mitmproxy/proxy/protocol/http2.py @@ -12,10 +12,10 @@ from mitmproxy import exceptions from mitmproxy import http from mitmproxy.proxy.protocol import base from mitmproxy.proxy.protocol import http as httpbase -import netlib.http -from netlib import tcp +import mitmproxy.net.http +from mitmproxy.net import tcp from mitmproxy.types import basethread -from netlib.http import http2 +from mitmproxy.net.http import http2 class SafeH2Connection(connection.H2Connection): @@ -148,7 +148,7 @@ class Http2Layer(base.Layer): return True def _handle_request_received(self, eid, event, h2_connection): - headers = netlib.http.Headers([[k, v] for k, v in event.headers]) + headers = mitmproxy.net.http.Headers([[k, v] for k, v in event.headers]) self.streams[eid] = Http2SingleStreamLayer(self, h2_connection, eid, headers) self.streams[eid].timestamp_start = time.time() self.streams[eid].no_body = (event.stream_ended is not None) @@ -162,7 +162,7 @@ class Http2Layer(base.Layer): return True def _handle_response_received(self, eid, event): - headers = netlib.http.Headers([[k, v] for k, v in event.headers]) + headers = mitmproxy.net.http.Headers([[k, v] for k, v in event.headers]) self.streams[eid].queued_data_length = 0 self.streams[eid].timestamp_start = time.time() self.streams[eid].response_headers = headers @@ -239,7 +239,7 @@ class Http2Layer(base.Layer): self.client_conn.h2.push_stream(parent_eid, event.pushed_stream_id, event.headers) self.client_conn.send(self.client_conn.h2.data_to_send()) - headers = netlib.http.Headers([[k, v] for k, v in event.headers]) + headers = mitmproxy.net.http.Headers([[k, v] for k, v in event.headers]) self.streams[event.pushed_stream_id] = Http2SingleStreamLayer(self, h2_connection, event.pushed_stream_id, headers) self.streams[event.pushed_stream_id].timestamp_start = time.time() self.streams[event.pushed_stream_id].pushed = True diff --git a/mitmproxy/proxy/protocol/http_replay.py b/mitmproxy/proxy/protocol/http_replay.py index 7efb0782a..c37badd3f 100644 --- a/mitmproxy/proxy/protocol/http_replay.py +++ b/mitmproxy/proxy/protocol/http_replay.py @@ -6,7 +6,7 @@ from mitmproxy import exceptions from mitmproxy import http from mitmproxy import flow from mitmproxy import connections -from netlib.http import http1 +from mitmproxy.net.http import http1 from mitmproxy.types import basethread diff --git a/mitmproxy/proxy/protocol/rawtcp.py b/mitmproxy/proxy/protocol/rawtcp.py index 8230c50b9..0ec505945 100644 --- a/mitmproxy/proxy/protocol/rawtcp.py +++ b/mitmproxy/proxy/protocol/rawtcp.py @@ -2,7 +2,7 @@ import socket from OpenSSL import SSL -import netlib.tcp +import mitmproxy.net.tcp from mitmproxy import tcp from mitmproxy import flow from mitmproxy import exceptions @@ -31,7 +31,7 @@ class RawTCPLayer(base.Layer): try: while not self.channel.should_exit.is_set(): - r = netlib.tcp.ssl_read_select(conns, 10) + r = mitmproxy.net.tcp.ssl_read_select(conns, 10) for conn in r: dst = server if conn == client else client diff --git a/mitmproxy/proxy/protocol/tls.py b/mitmproxy/proxy/protocol/tls.py index b106aa0c0..8a344faf5 100644 --- a/mitmproxy/proxy/protocol/tls.py +++ b/mitmproxy/proxy/protocol/tls.py @@ -6,7 +6,7 @@ import construct from mitmproxy import exceptions from mitmproxy.contrib.tls import _constructs from mitmproxy.proxy.protocol import base -from netlib import check +from mitmproxy.net import check # taken from https://testssl.sh/openssl-rfc.mappping.html diff --git a/mitmproxy/proxy/protocol/websockets.py b/mitmproxy/proxy/protocol/websockets.py index f84a1dc59..ca1d05cb6 100644 --- a/mitmproxy/proxy/protocol/websockets.py +++ b/mitmproxy/proxy/protocol/websockets.py @@ -4,8 +4,8 @@ from OpenSSL import SSL from mitmproxy import exceptions from mitmproxy.proxy.protocol import base from mitmproxy.utils import strutils -from netlib import tcp -from netlib import websockets +from mitmproxy.net import tcp +from mitmproxy.net import websockets class WebSocketsLayer(base.Layer): diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 8472660ac..232d70389 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -8,8 +8,8 @@ from mitmproxy import http from mitmproxy import log from mitmproxy.proxy import modes from mitmproxy.proxy import root_context -from netlib import tcp -from netlib.http import http1 +from mitmproxy.net import tcp +from mitmproxy.net.http import http1 class DummyServer: diff --git a/mitmproxy/test/tutils.py b/mitmproxy/test/tutils.py index fc7c0eb9d..e925b282d 100644 --- a/mitmproxy/test/tutils.py +++ b/mitmproxy/test/tutils.py @@ -7,8 +7,8 @@ from contextlib import contextmanager import sys from mitmproxy.utils import data -from netlib import tcp -from netlib import http +from mitmproxy.net import tcp +from mitmproxy.net import http def treader(bytes): @@ -89,13 +89,13 @@ class RaisesContext: return True -test_data = data.Data(__name__).push("../../test/netlib") +test_data = data.Data(__name__).push("../../test/mitmproxy/net") def treq(**kwargs): """ Returns: - netlib.http.Request + mitmproxy.net.http.Request """ default = dict( first_line_format="relative", @@ -115,7 +115,7 @@ def treq(**kwargs): def tresp(**kwargs): """ Returns: - netlib.http.Response + mitmproxy.net.http.Response """ default = dict( http_version=b"HTTP/1.1", diff --git a/mitmproxy/tools/cmdline.py b/mitmproxy/tools/cmdline.py index b83694efc..2f9ea15c6 100644 --- a/mitmproxy/tools/cmdline.py +++ b/mitmproxy/tools/cmdline.py @@ -6,7 +6,7 @@ from mitmproxy import flowfilter from mitmproxy import options from mitmproxy import platform from mitmproxy.utils import human -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy import version diff --git a/mitmproxy/tools/console/common.py b/mitmproxy/tools/console/common.py index 53411d17c..90dce5aea 100644 --- a/mitmproxy/tools/console/common.py +++ b/mitmproxy/tools/console/common.py @@ -6,7 +6,7 @@ import os import urwid import urwid.util -import netlib +import mitmproxy.net from mitmproxy.utils import lrucache from mitmproxy.tools.console import signals from mitmproxy import export @@ -226,7 +226,7 @@ def format_flow_data(key, scope, flow): if request.content is None: return None, "Request content is missing" if key == "h": - data += netlib.http.http1.assemble_request(request) + data += mitmproxy.net.http.http1.assemble_request(request) elif key == "c": data += request.get_content(strict=False) else: @@ -240,7 +240,7 @@ def format_flow_data(key, scope, flow): if response.content is None: return None, "Response content is missing" if key == "h": - data += netlib.http.http1.assemble_response(response) + data += mitmproxy.net.http.http1.assemble_response(response) elif key == "c": data += response.get_content(strict=False) else: diff --git a/mitmproxy/tools/console/flowlist.py b/mitmproxy/tools/console/flowlist.py index 31624229c..d33348a0f 100644 --- a/mitmproxy/tools/console/flowlist.py +++ b/mitmproxy/tools/console/flowlist.py @@ -1,6 +1,6 @@ import urwid -import netlib.http.url +import mitmproxy.net.http.url from mitmproxy import exceptions from mitmproxy.tools.console import common from mitmproxy.tools.console import signals @@ -325,7 +325,7 @@ class FlowListBox(urwid.ListBox): ) def new_request(self, url, method): - parts = netlib.http.url.parse(str(url)) + parts = mitmproxy.net.http.url.parse(str(url)) if not parts: signals.status_message.send(message="Invalid Url") return diff --git a/mitmproxy/tools/console/flowview.py b/mitmproxy/tools/console/flowview.py index afebf44e8..4e886ee47 100644 --- a/mitmproxy/tools/console/flowview.py +++ b/mitmproxy/tools/console/flowview.py @@ -16,8 +16,8 @@ from mitmproxy.tools.console import searchable from mitmproxy.tools.console import signals from mitmproxy.tools.console import tabs from mitmproxy import export -from netlib.http import Headers -from netlib.http import status_codes +from mitmproxy.net.http import Headers +from mitmproxy.net.http import status_codes class SearchError(Exception): diff --git a/mitmproxy/tools/console/grideditor/col_subgrid.py b/mitmproxy/tools/console/grideditor/col_subgrid.py index 3147e63d0..4db374620 100644 --- a/mitmproxy/tools/console/grideditor/col_subgrid.py +++ b/mitmproxy/tools/console/grideditor/col_subgrid.py @@ -1,7 +1,7 @@ import urwid from mitmproxy.tools.console.grideditor import base from mitmproxy.tools.console import signals -from netlib.http import cookies +from mitmproxy.net.http import cookies class Column(base.Column): diff --git a/mitmproxy/tools/console/grideditor/editors.py b/mitmproxy/tools/console/grideditor/editors.py index 64361af74..5e3f3d42d 100644 --- a/mitmproxy/tools/console/grideditor/editors.py +++ b/mitmproxy/tools/console/grideditor/editors.py @@ -9,7 +9,7 @@ from mitmproxy.tools.console.grideditor import col_bytes from mitmproxy.tools.console.grideditor import col_text from mitmproxy.tools.console.grideditor import col_subgrid from mitmproxy.tools.console import signals -from netlib.http import user_agents +from mitmproxy.net.http import user_agents class QueryEditor(base.GridEditor): diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py index 7ff0026eb..af43c53be 100644 --- a/mitmproxy/tools/console/master.py +++ b/mitmproxy/tools/console/master.py @@ -37,7 +37,7 @@ from mitmproxy.tools.console import window from mitmproxy.flowfilter import FMarked from mitmproxy.utils import strutils -from netlib import tcp +from mitmproxy.net import tcp EVENTLOG_SIZE = 500 diff --git a/mitmproxy/tools/console/statusbar.py b/mitmproxy/tools/console/statusbar.py index ac41b213d..74382677a 100644 --- a/mitmproxy/tools/console/statusbar.py +++ b/mitmproxy/tools/console/statusbar.py @@ -2,7 +2,7 @@ import os.path import urwid -import netlib.http.url +import mitmproxy.net.http.url from mitmproxy.tools.console import common from mitmproxy.tools.console import pathedit from mitmproxy.tools.console import signals @@ -208,7 +208,7 @@ class StatusBar(urwid.WidgetWrap): if self.master.options.mode in ["reverse", "upstream"]: dst = self.master.server.config.upstream_server - r.append("[dest:%s]" % netlib.http.url.unparse( + r.append("[dest:%s]" % mitmproxy.net.http.url.unparse( dst.scheme, dst.address.host, dst.address.port diff --git a/mitmproxy/tools/dump.py b/mitmproxy/tools/dump.py index 47f693039..e92482f39 100644 --- a/mitmproxy/tools/dump.py +++ b/mitmproxy/tools/dump.py @@ -8,7 +8,7 @@ from mitmproxy import io from mitmproxy import options from mitmproxy import master from mitmproxy.addons import dumper, termlog -from netlib import tcp +from mitmproxy.net import tcp class DumpError(Exception): diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py index 2bca45552..619582f34 100644 --- a/mitmproxy/tools/web/master.py +++ b/mitmproxy/tools/web/master.py @@ -13,7 +13,7 @@ from mitmproxy.addons import state from mitmproxy import options from mitmproxy import master from mitmproxy.tools.web import app -from netlib.http import authentication +from mitmproxy.net.http import authentication class Stop(Exception): diff --git a/mitmproxy/utils/debug.py b/mitmproxy/utils/debug.py index 147fe4b13..ac8fedd7b 100644 --- a/mitmproxy/utils/debug.py +++ b/mitmproxy/utils/debug.py @@ -84,7 +84,7 @@ def dump_info(signal=None, frame=None, file=sys.stdout, testing=False): # pragm d = {} for i in gc.get_objects(): t = str(type(i)) - if "mitmproxy" in t or "netlib" in t: + if "mitmproxy" in t: d[t] = d.setdefault(t, 0) + 1 itms = list(d.items()) itms.sort(key=lambda x: x[1]) diff --git a/mitmproxy/utils/version_check.py b/mitmproxy/utils/version_check.py index 547c031c8..4cf2b9e60 100644 --- a/mitmproxy/utils/version_check.py +++ b/mitmproxy/utils/version_check.py @@ -1,7 +1,6 @@ """ -Having installed a wrong version of pyOpenSSL or netlib is unfortunately a -very common source of error. Check before every start that both versions -are somewhat okay. +Having installed a wrong version of pyOpenSSL is unfortunately a very common +source of error. Check before every start that both versions are somewhat okay. """ import sys import inspect diff --git a/netlib/http/__init__.py b/netlib/http/__init__.py deleted file mode 100644 index 315f61ac9..000000000 --- a/netlib/http/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -from netlib.http.request import Request -from netlib.http.response import Response -from netlib.http.message import Message -from netlib.http.headers import Headers, parse_content_type -from netlib.http.message import decoded -from netlib.http import http1, http2, status_codes, multipart - -__all__ = [ - "Request", - "Response", - "Message", - "Headers", "parse_content_type", - "decoded", - "http1", "http2", "status_codes", "multipart", -] diff --git a/netlib/http/http2/__init__.py b/netlib/http/http2/__init__.py deleted file mode 100644 index 20cc63a02..000000000 --- a/netlib/http/http2/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from netlib.http.http2.framereader import read_raw_frame, parse_frame -from netlib.http.http2.utils import parse_headers - -__all__ = [ - "read_raw_frame", - "parse_frame", - "parse_headers", -] diff --git a/pathod/language/http.py b/pathod/language/http.py index 32f990bbf..8fcf9edc7 100644 --- a/pathod/language/http.py +++ b/pathod/language/http.py @@ -2,12 +2,12 @@ import abc import pyparsing as pp -from netlib.http import url -import netlib.websockets -from netlib.http import status_codes, user_agents +from mitmproxy.net.http import url +import mitmproxy.net.websockets +from mitmproxy.net.http import status_codes, user_agents from . import base, exceptions, actions, message -# TODO: use netlib.semantics.protocol assemble method, +# TODO: use mitmproxy.net.semantics.protocol assemble method, # instead of duplicating the HTTP on-the-wire representation here. # see http2 language for an example @@ -198,7 +198,7 @@ class Response(_HTTPMessage): 1, StatusCode(101) ) - headers = netlib.websockets.server_handshake_headers( + headers = mitmproxy.net.websockets.server_handshake_headers( settings.websocket_key ) for i in headers.fields: @@ -310,7 +310,7 @@ class Request(_HTTPMessage): 1, Method("get") ) - for i in netlib.websockets.client_handshake_headers().fields: + for i in mitmproxy.net.websockets.client_handshake_headers().fields: if not get_header(i[0], self.headers): tokens.append( Header( diff --git a/pathod/language/http2.py b/pathod/language/http2.py index 35fc5ba80..08c5f6d77 100644 --- a/pathod/language/http2.py +++ b/pathod/language/http2.py @@ -1,7 +1,7 @@ import pyparsing as pp -from netlib import http -from netlib.http import user_agents, Headers +from mitmproxy.net import http +from mitmproxy.net.http import user_agents, Headers from . import base, message """ diff --git a/pathod/language/websockets.py b/pathod/language/websockets.py index d2291f822..a237381cf 100644 --- a/pathod/language/websockets.py +++ b/pathod/language/websockets.py @@ -1,6 +1,6 @@ import random import string -import netlib.websockets +import mitmproxy.net.websockets from mitmproxy.utils import strutils import pyparsing as pp from . import base, generators, actions, message @@ -14,12 +14,12 @@ class WF(base.CaselessLiteral): class OpCode(base.IntField): names = { - "continue": netlib.websockets.OPCODE.CONTINUE, - "text": netlib.websockets.OPCODE.TEXT, - "binary": netlib.websockets.OPCODE.BINARY, - "close": netlib.websockets.OPCODE.CLOSE, - "ping": netlib.websockets.OPCODE.PING, - "pong": netlib.websockets.OPCODE.PONG, + "continue": mitmproxy.net.websockets.OPCODE.CONTINUE, + "text": mitmproxy.net.websockets.OPCODE.TEXT, + "binary": mitmproxy.net.websockets.OPCODE.BINARY, + "close": mitmproxy.net.websockets.OPCODE.CLOSE, + "ping": mitmproxy.net.websockets.OPCODE.PING, + "pong": mitmproxy.net.websockets.OPCODE.PONG, } max = 15 preamble = "c" @@ -215,11 +215,11 @@ class WebsocketFrame(message.Message): v = getattr(self, i, None) if v is not None: frameparts[i] = v.value - frame = netlib.websockets.FrameHeader(**frameparts) + frame = mitmproxy.net.websockets.FrameHeader(**frameparts) vals = [bytes(frame)] if bodygen: if frame.masking_key and not self.rawbody: - masker = netlib.websockets.Masker(frame.masking_key) + masker = mitmproxy.net.websockets.Masker(frame.masking_key) vals.append( generators.TransformGenerator( bodygen, diff --git a/pathod/pathoc.py b/pathod/pathoc.py index 0978277ad..066c330c0 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -13,12 +13,12 @@ import logging from mitmproxy.test.tutils import treq from mitmproxy.utils import strutils -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy import certs -from netlib import websockets -from netlib import socks +from mitmproxy.net import websockets +from mitmproxy.net import socks from mitmproxy import exceptions -from netlib.http import http1 +from mitmproxy.net.http import http1 from mitmproxy.types import basethread from pathod import log diff --git a/pathod/pathoc_cmdline.py b/pathod/pathoc_cmdline.py index 2b4b9f9ce..3b738d47a 100644 --- a/pathod/pathoc_cmdline.py +++ b/pathod/pathoc_cmdline.py @@ -3,9 +3,9 @@ import argparse import os import os.path -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy import version -from netlib.http import user_agents +from mitmproxy.net.http import user_agents from . import pathoc, language diff --git a/pathod/pathod.py b/pathod/pathod.py index 746998c55..a8658361d 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -4,9 +4,9 @@ import os import sys import threading -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy import certs as mcerts -from netlib import websockets +from mitmproxy.net import websockets from mitmproxy import version import urllib diff --git a/pathod/pathod_cmdline.py b/pathod/pathod_cmdline.py index 8d6ee2b6e..ef1e983ff 100644 --- a/pathod/pathod_cmdline.py +++ b/pathod/pathod_cmdline.py @@ -4,7 +4,7 @@ import os import os.path import re -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy.utils import human from mitmproxy import version from . import pathod diff --git a/pathod/protocols/http.py b/pathod/protocols/http.py index a20a58a1d..4387b4fb1 100644 --- a/pathod/protocols/http.py +++ b/pathod/protocols/http.py @@ -1,6 +1,6 @@ from mitmproxy import version from mitmproxy import exceptions -from netlib.http import http1 +from mitmproxy.net.http import http1 from .. import language diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index 838469d6f..118163d28 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -4,10 +4,10 @@ import time import hyperframe.frame from hpack.hpack import Encoder, Decoder -from netlib.http import http2 -import netlib.http.headers -import netlib.http.response -import netlib.http.request +from mitmproxy.net.http import http2 +import mitmproxy.net.http.headers +import mitmproxy.net.http.response +import mitmproxy.net.http.request from mitmproxy.types import bidi from .. import language @@ -100,7 +100,7 @@ class HTTP2StateProtocol: first_line_format, method, scheme, host, port, path = http2.parse_headers(headers) - request = netlib.http.request.Request( + request = mitmproxy.net.http.request.Request( first_line_format, method, scheme, @@ -148,7 +148,7 @@ class HTTP2StateProtocol: else: timestamp_end = None - response = netlib.http.response.Response( + response = mitmproxy.net.http.response.Response( b"HTTP/2.0", int(headers.get(':status', 502)), b'', @@ -162,15 +162,15 @@ class HTTP2StateProtocol: return response def assemble(self, message): - if isinstance(message, netlib.http.request.Request): + if isinstance(message, mitmproxy.net.http.request.Request): return self.assemble_request(message) - elif isinstance(message, netlib.http.response.Response): + elif isinstance(message, mitmproxy.net.http.response.Response): return self.assemble_response(message) else: raise ValueError("HTTP message not supported.") def assemble_request(self, request): - assert isinstance(request, netlib.http.request.Request) + assert isinstance(request, mitmproxy.net.http.request.Request) authority = self.tcp_handler.sni if self.tcp_handler.sni else self.tcp_handler.address.host if self.tcp_handler.address.port != 443: @@ -194,7 +194,7 @@ class HTTP2StateProtocol: self._create_body(request.body, stream_id))) def assemble_response(self, response): - assert isinstance(response, netlib.http.response.Response) + assert isinstance(response, mitmproxy.net.http.response.Response) headers = response.headers.copy() @@ -394,7 +394,7 @@ class HTTP2StateProtocol: else: self._handle_unexpected_frame(frm) - headers = netlib.http.headers.Headers( + headers = mitmproxy.net.http.headers.Headers( [[k, v] for k, v in self.decoder.decode(header_blocks, raw=True)] ) diff --git a/pathod/protocols/websockets.py b/pathod/protocols/websockets.py index 585a48e3b..00ae5aa88 100644 --- a/pathod/protocols/websockets.py +++ b/pathod/protocols/websockets.py @@ -1,6 +1,6 @@ import time -from netlib import websockets +from mitmproxy.net import websockets from pathod import language from mitmproxy import exceptions diff --git a/release/README.mkd b/release/README.mkd index db2ef970c..c55054316 100644 --- a/release/README.mkd +++ b/release/README.mkd @@ -7,7 +7,7 @@ - Only if an emergency bugfix is needed, we push a new `0.x.y` bugfix release for a single project. This matches with what we do in `setup.py`: - "netlib>=%s, <%s" % (version.MINORVERSION, version.NEXT_MINORVERSION) + "mitmproxy>=%s, <%s" % (version.MINORVERSION, version.NEXT_MINORVERSION) # Release Checklist diff --git a/release/rtool.py b/release/rtool.py index 3ed9157e0..fbca40e23 100755 --- a/release/rtool.py +++ b/release/rtool.py @@ -48,7 +48,7 @@ VENV_PIP = join(VENV_DIR, VENV_BIN, "pip") VENV_PYINSTALLER = join(VENV_DIR, VENV_BIN, "pyinstaller") # Project Configuration -VERSION_FILE = join(ROOT_DIR, "netlib", "version.py") +VERSION_FILE = join(ROOT_DIR, "mitmproxy", "version.py") PROJECT_NAME = "mitmproxy" PYTHON_VERSION = "py2.py3" BDISTS = { diff --git a/setup.py b/setup.py index 9981ea6cf..1351ba73a 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ setup( packages=find_packages(include=[ "mitmproxy", "mitmproxy.*", "pathod", "pathod.*", - "netlib", "netlib.*" ]), include_package_data=True, entry_points={ diff --git a/test/netlib/__init__.py b/test/mitmproxy/net/__init__.py similarity index 100% rename from test/netlib/__init__.py rename to test/mitmproxy/net/__init__.py diff --git a/test/netlib/data/clientcert/.gitignore b/test/mitmproxy/net/data/clientcert/.gitignore similarity index 100% rename from test/netlib/data/clientcert/.gitignore rename to test/mitmproxy/net/data/clientcert/.gitignore diff --git a/test/netlib/data/clientcert/client.cnf b/test/mitmproxy/net/data/clientcert/client.cnf similarity index 100% rename from test/netlib/data/clientcert/client.cnf rename to test/mitmproxy/net/data/clientcert/client.cnf diff --git a/test/netlib/data/clientcert/client.pem b/test/mitmproxy/net/data/clientcert/client.pem similarity index 100% rename from test/netlib/data/clientcert/client.pem rename to test/mitmproxy/net/data/clientcert/client.pem diff --git a/test/netlib/data/clientcert/make b/test/mitmproxy/net/data/clientcert/make similarity index 100% rename from test/netlib/data/clientcert/make rename to test/mitmproxy/net/data/clientcert/make diff --git a/test/netlib/data/dercert b/test/mitmproxy/net/data/dercert similarity index 100% rename from test/netlib/data/dercert rename to test/mitmproxy/net/data/dercert diff --git a/test/netlib/data/dhparam.pem b/test/mitmproxy/net/data/dhparam.pem similarity index 100% rename from test/netlib/data/dhparam.pem rename to test/mitmproxy/net/data/dhparam.pem diff --git a/test/netlib/data/htpasswd b/test/mitmproxy/net/data/htpasswd similarity index 100% rename from test/netlib/data/htpasswd rename to test/mitmproxy/net/data/htpasswd diff --git a/test/netlib/data/server.crt b/test/mitmproxy/net/data/server.crt similarity index 100% rename from test/netlib/data/server.crt rename to test/mitmproxy/net/data/server.crt diff --git a/test/netlib/data/server.key b/test/mitmproxy/net/data/server.key similarity index 100% rename from test/netlib/data/server.key rename to test/mitmproxy/net/data/server.key diff --git a/test/netlib/data/text_cert b/test/mitmproxy/net/data/text_cert similarity index 100% rename from test/netlib/data/text_cert rename to test/mitmproxy/net/data/text_cert diff --git a/test/netlib/data/text_cert_2 b/test/mitmproxy/net/data/text_cert_2 similarity index 100% rename from test/netlib/data/text_cert_2 rename to test/mitmproxy/net/data/text_cert_2 diff --git a/test/netlib/data/text_cert_weird1 b/test/mitmproxy/net/data/text_cert_weird1 similarity index 100% rename from test/netlib/data/text_cert_weird1 rename to test/mitmproxy/net/data/text_cert_weird1 diff --git a/test/netlib/data/verificationcerts/9da13359.0 b/test/mitmproxy/net/data/verificationcerts/9da13359.0 similarity index 100% rename from test/netlib/data/verificationcerts/9da13359.0 rename to test/mitmproxy/net/data/verificationcerts/9da13359.0 diff --git a/test/netlib/data/verificationcerts/generate.py b/test/mitmproxy/net/data/verificationcerts/generate.py similarity index 100% rename from test/netlib/data/verificationcerts/generate.py rename to test/mitmproxy/net/data/verificationcerts/generate.py diff --git a/test/netlib/data/verificationcerts/self-signed.crt b/test/mitmproxy/net/data/verificationcerts/self-signed.crt similarity index 100% rename from test/netlib/data/verificationcerts/self-signed.crt rename to test/mitmproxy/net/data/verificationcerts/self-signed.crt diff --git a/test/netlib/data/verificationcerts/self-signed.key b/test/mitmproxy/net/data/verificationcerts/self-signed.key similarity index 100% rename from test/netlib/data/verificationcerts/self-signed.key rename to test/mitmproxy/net/data/verificationcerts/self-signed.key diff --git a/test/netlib/data/verificationcerts/trusted-leaf.crt b/test/mitmproxy/net/data/verificationcerts/trusted-leaf.crt similarity index 100% rename from test/netlib/data/verificationcerts/trusted-leaf.crt rename to test/mitmproxy/net/data/verificationcerts/trusted-leaf.crt diff --git a/test/netlib/data/verificationcerts/trusted-leaf.key b/test/mitmproxy/net/data/verificationcerts/trusted-leaf.key similarity index 100% rename from test/netlib/data/verificationcerts/trusted-leaf.key rename to test/mitmproxy/net/data/verificationcerts/trusted-leaf.key diff --git a/test/netlib/data/verificationcerts/trusted-root.crt b/test/mitmproxy/net/data/verificationcerts/trusted-root.crt similarity index 100% rename from test/netlib/data/verificationcerts/trusted-root.crt rename to test/mitmproxy/net/data/verificationcerts/trusted-root.crt diff --git a/test/netlib/data/verificationcerts/trusted-root.key b/test/mitmproxy/net/data/verificationcerts/trusted-root.key similarity index 100% rename from test/netlib/data/verificationcerts/trusted-root.key rename to test/mitmproxy/net/data/verificationcerts/trusted-root.key diff --git a/test/netlib/data/verificationcerts/trusted-root.srl b/test/mitmproxy/net/data/verificationcerts/trusted-root.srl similarity index 100% rename from test/netlib/data/verificationcerts/trusted-root.srl rename to test/mitmproxy/net/data/verificationcerts/trusted-root.srl diff --git a/test/netlib/http/__init__.py b/test/mitmproxy/net/http/__init__.py similarity index 100% rename from test/netlib/http/__init__.py rename to test/mitmproxy/net/http/__init__.py diff --git a/test/netlib/http/http1/__init__.py b/test/mitmproxy/net/http/http1/__init__.py similarity index 100% rename from test/netlib/http/http1/__init__.py rename to test/mitmproxy/net/http/http1/__init__.py diff --git a/test/netlib/http/http1/test_assemble.py b/test/mitmproxy/net/http/http1/test_assemble.py similarity index 97% rename from test/netlib/http/http1/test_assemble.py rename to test/mitmproxy/net/http/http1/test_assemble.py index dac5fdada..e80376e81 100644 --- a/test/netlib/http/http1/test_assemble.py +++ b/test/mitmproxy/net/http/http1/test_assemble.py @@ -1,6 +1,6 @@ from mitmproxy import exceptions -from netlib.http import Headers -from netlib.http.http1.assemble import ( +from mitmproxy.net.http import Headers +from mitmproxy.net.http.http1.assemble import ( assemble_request, assemble_request_head, assemble_response, assemble_response_head, _assemble_request_line, _assemble_request_headers, _assemble_response_headers, diff --git a/test/netlib/http/http1/test_read.py b/test/mitmproxy/net/http/http1/test_read.py similarity index 99% rename from test/netlib/http/http1/test_read.py rename to test/mitmproxy/net/http/http1/test_read.py index eb96968ce..20997259f 100644 --- a/test/netlib/http/http1/test_read.py +++ b/test/mitmproxy/net/http/http1/test_read.py @@ -3,8 +3,8 @@ from mock import Mock import pytest from mitmproxy import exceptions -from netlib.http import Headers -from netlib.http.http1.read import ( +from mitmproxy.net.http import Headers +from mitmproxy.net.http.http1.read import ( read_request, read_response, read_request_head, read_response_head, read_body, connection_close, expected_http_body_size, _get_first_line, _read_request_line, _parse_authority_form, _read_response_line, _check_http_version, diff --git a/test/netlib/http/http2/__init__.py b/test/mitmproxy/net/http/http2/__init__.py similarity index 100% rename from test/netlib/http/http2/__init__.py rename to test/mitmproxy/net/http/http2/__init__.py diff --git a/test/netlib/http/http2/test_framereader.py b/test/mitmproxy/net/http/http2/test_framereader.py similarity index 100% rename from test/netlib/http/http2/test_framereader.py rename to test/mitmproxy/net/http/http2/test_framereader.py diff --git a/test/netlib/http/test_authentication.py b/test/mitmproxy/net/http/test_authentication.py similarity index 98% rename from test/netlib/http/test_authentication.py rename to test/mitmproxy/net/http/test_authentication.py index 5e04bbc5c..11b6e2e0e 100644 --- a/test/netlib/http/test_authentication.py +++ b/test/mitmproxy/net/http/test_authentication.py @@ -1,7 +1,7 @@ import binascii from mitmproxy.test import tutils -from netlib.http import authentication, Headers +from mitmproxy.net.http import authentication, Headers def test_parse_http_basic_auth(): diff --git a/test/netlib/http/test_cookies.py b/test/mitmproxy/net/http/test_cookies.py similarity index 99% rename from test/netlib/http/test_cookies.py rename to test/mitmproxy/net/http/test_cookies.py index ca10a69c3..8c9c0c325 100644 --- a/test/netlib/http/test_cookies.py +++ b/test/mitmproxy/net/http/test_cookies.py @@ -1,6 +1,6 @@ import time -from netlib.http import cookies +from mitmproxy.net.http import cookies from mitmproxy.test.tutils import raises import mock diff --git a/test/netlib/http/test_encoding.py b/test/mitmproxy/net/http/test_encoding.py similarity index 98% rename from test/netlib/http/test_encoding.py rename to test/mitmproxy/net/http/test_encoding.py index 896007096..d8fa5e768 100644 --- a/test/netlib/http/test_encoding.py +++ b/test/mitmproxy/net/http/test_encoding.py @@ -1,7 +1,7 @@ import mock import pytest -from netlib.http import encoding +from mitmproxy.net.http import encoding from mitmproxy.test import tutils diff --git a/test/netlib/http/test_headers.py b/test/mitmproxy/net/http/test_headers.py similarity index 97% rename from test/netlib/http/test_headers.py rename to test/mitmproxy/net/http/test_headers.py index cac77d573..8e0f770d7 100644 --- a/test/netlib/http/test_headers.py +++ b/test/mitmproxy/net/http/test_headers.py @@ -1,6 +1,6 @@ import collections -from netlib.http.headers import Headers, parse_content_type, assemble_content_type +from mitmproxy.net.http.headers import Headers, parse_content_type, assemble_content_type from mitmproxy.test.tutils import raises diff --git a/test/netlib/http/test_message.py b/test/mitmproxy/net/http/test_message.py similarity index 99% rename from test/netlib/http/test_message.py rename to test/mitmproxy/net/http/test_message.py index 2bc8824fc..69d029d9c 100644 --- a/test/netlib/http/test_message.py +++ b/test/mitmproxy/net/http/test_message.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from mitmproxy.test import tutils -from netlib import http +from mitmproxy.net import http def _test_passthrough_attr(message, attr): diff --git a/test/netlib/http/test_multipart.py b/test/mitmproxy/net/http/test_multipart.py similarity index 87% rename from test/netlib/http/test_multipart.py rename to test/mitmproxy/net/http/test_multipart.py index 1d7e00620..68ae6bbdf 100644 --- a/test/netlib/http/test_multipart.py +++ b/test/mitmproxy/net/http/test_multipart.py @@ -1,5 +1,5 @@ -from netlib.http import Headers -from netlib.http import multipart +from mitmproxy.net.http import Headers +from mitmproxy.net.http import multipart def test_decode(): diff --git a/test/netlib/http/test_request.py b/test/mitmproxy/net/http/test_request.py similarity index 99% rename from test/netlib/http/test_request.py rename to test/mitmproxy/net/http/test_request.py index ecfc1ba6c..9c0ec333c 100644 --- a/test/netlib/http/test_request.py +++ b/test/mitmproxy/net/http/test_request.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from netlib.http import Headers +from mitmproxy.net.http import Headers from mitmproxy.test.tutils import treq, raises from .test_message import _test_decoded_attr, _test_passthrough_attr diff --git a/test/netlib/http/test_response.py b/test/mitmproxy/net/http/test_response.py similarity index 97% rename from test/netlib/http/test_response.py rename to test/mitmproxy/net/http/test_response.py index 4a6fac62d..239fb6ef7 100644 --- a/test/netlib/http/test_response.py +++ b/test/mitmproxy/net/http/test_response.py @@ -2,9 +2,9 @@ import email import time -from netlib.http import Headers -from netlib.http import Response -from netlib.http.cookies import CookieAttrs +from mitmproxy.net.http import Headers +from mitmproxy.net.http import Response +from mitmproxy.net.http.cookies import CookieAttrs from mitmproxy.test.tutils import raises, tresp from .test_message import _test_passthrough_attr, _test_decoded_attr diff --git a/test/netlib/http/test_status_codes.py b/test/mitmproxy/net/http/test_status_codes.py similarity index 73% rename from test/netlib/http/test_status_codes.py rename to test/mitmproxy/net/http/test_status_codes.py index 9fea6b707..098f8eef9 100644 --- a/test/netlib/http/test_status_codes.py +++ b/test/mitmproxy/net/http/test_status_codes.py @@ -1,4 +1,4 @@ -from netlib.http import status_codes +from mitmproxy.net.http import status_codes def test_simple(): diff --git a/test/netlib/http/test_url.py b/test/mitmproxy/net/http/test_url.py similarity index 98% rename from test/netlib/http/test_url.py rename to test/mitmproxy/net/http/test_url.py index 7cea6c580..94b2eaccc 100644 --- a/test/netlib/http/test_url.py +++ b/test/mitmproxy/net/http/test_url.py @@ -1,5 +1,5 @@ from mitmproxy.test import tutils -from netlib.http import url +from mitmproxy.net.http import url def test_parse(): diff --git a/test/netlib/http/test_user_agents.py b/test/mitmproxy/net/http/test_user_agents.py similarity index 75% rename from test/netlib/http/test_user_agents.py rename to test/mitmproxy/net/http/test_user_agents.py index 0bf1bba7f..9e3914470 100644 --- a/test/netlib/http/test_user_agents.py +++ b/test/mitmproxy/net/http/test_user_agents.py @@ -1,4 +1,4 @@ -from netlib.http import user_agents +from mitmproxy.net.http import user_agents def test_get_shortcut(): diff --git a/test/netlib/test_check.py b/test/mitmproxy/net/test_check.py similarity index 87% rename from test/netlib/test_check.py rename to test/mitmproxy/net/test_check.py index 6a1388f4d..18a50157f 100644 --- a/test/netlib/test_check.py +++ b/test/mitmproxy/net/test_check.py @@ -1,6 +1,6 @@ # coding=utf-8 -from netlib import check +from mitmproxy.net import check def test_is_valid_host(): diff --git a/test/netlib/test_imports.py b/test/mitmproxy/net/test_imports.py similarity index 100% rename from test/netlib/test_imports.py rename to test/mitmproxy/net/test_imports.py diff --git a/test/netlib/test_socks.py b/test/mitmproxy/net/test_socks.py similarity index 98% rename from test/netlib/test_socks.py rename to test/mitmproxy/net/test_socks.py index 0603f34b3..b6551faa3 100644 --- a/test/netlib/test_socks.py +++ b/test/mitmproxy/net/test_socks.py @@ -1,7 +1,7 @@ import ipaddress from io import BytesIO -from netlib import socks -from netlib import tcp +from mitmproxy.net import socks +from mitmproxy.net import tcp from mitmproxy.test import tutils diff --git a/test/netlib/test_tcp.py b/test/mitmproxy/net/test_tcp.py similarity index 99% rename from test/netlib/test_tcp.py rename to test/mitmproxy/net/test_tcp.py index 594ee21c2..8a7c692a3 100644 --- a/test/netlib/test_tcp.py +++ b/test/mitmproxy/net/test_tcp.py @@ -10,7 +10,7 @@ import mock from OpenSSL import SSL from mitmproxy import certs -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy.test import tutils from mitmproxy import exceptions diff --git a/test/netlib/test_wsgi.py b/test/mitmproxy/net/test_wsgi.py similarity index 97% rename from test/netlib/test_wsgi.py rename to test/mitmproxy/net/test_wsgi.py index 5c61f81c8..b4d6b53f2 100644 --- a/test/netlib/test_wsgi.py +++ b/test/mitmproxy/net/test_wsgi.py @@ -1,7 +1,7 @@ from io import BytesIO import sys -from netlib import wsgi -from netlib.http import Headers +from mitmproxy.net import wsgi +from mitmproxy.net.http import Headers def tflow(): diff --git a/test/netlib/tools/getcertnames b/test/mitmproxy/net/tools/getcertnames similarity index 94% rename from test/netlib/tools/getcertnames rename to test/mitmproxy/net/tools/getcertnames index 0882fccd1..d64e5ff55 100644 --- a/test/netlib/tools/getcertnames +++ b/test/mitmproxy/net/tools/getcertnames @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys sys.path.insert(0, "../../") -from netlib import tcp +from mitmproxy.net import tcp def get_remote_cert(host, port, sni): diff --git a/test/netlib/tservers.py b/test/mitmproxy/net/tservers.py similarity index 99% rename from test/netlib/tservers.py rename to test/mitmproxy/net/tservers.py index 2fae8ba62..ba10ef5ed 100644 --- a/test/netlib/tservers.py +++ b/test/mitmproxy/net/tservers.py @@ -3,7 +3,7 @@ import queue import io import OpenSSL -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy.test import tutils diff --git a/test/netlib/websockets/__init__.py b/test/mitmproxy/net/websockets/__init__.py similarity index 100% rename from test/netlib/websockets/__init__.py rename to test/mitmproxy/net/websockets/__init__.py diff --git a/test/netlib/websockets/test_frame.py b/test/mitmproxy/net/websockets/test_frame.py similarity index 99% rename from test/netlib/websockets/test_frame.py rename to test/mitmproxy/net/websockets/test_frame.py index 3b7c9ed4a..198be3d57 100644 --- a/test/netlib/websockets/test_frame.py +++ b/test/mitmproxy/net/websockets/test_frame.py @@ -2,7 +2,7 @@ import os import codecs import pytest -from netlib import websockets +from mitmproxy.net import websockets from mitmproxy.test import tutils diff --git a/test/netlib/websockets/test_masker.py b/test/mitmproxy/net/websockets/test_masker.py similarity index 95% rename from test/netlib/websockets/test_masker.py rename to test/mitmproxy/net/websockets/test_masker.py index 23a9b8763..88360c3b4 100644 --- a/test/netlib/websockets/test_masker.py +++ b/test/mitmproxy/net/websockets/test_masker.py @@ -1,7 +1,7 @@ import codecs import pytest -from netlib import websockets +from mitmproxy.net import websockets class TestMasker: diff --git a/test/netlib/websockets/test_utils.py b/test/mitmproxy/net/websockets/test_utils.py similarity index 98% rename from test/netlib/websockets/test_utils.py rename to test/mitmproxy/net/websockets/test_utils.py index f6f1e40a7..6704d39d9 100644 --- a/test/netlib/websockets/test_utils.py +++ b/test/mitmproxy/net/websockets/test_utils.py @@ -1,7 +1,7 @@ import pytest -from netlib import http -from netlib import websockets +from mitmproxy.net import http +from mitmproxy.net import websockets class TestUtils: diff --git a/test/mitmproxy/protocol/test_http1.py b/test/mitmproxy/protocol/test_http1.py index d18ff4117..43c903f37 100644 --- a/test/mitmproxy/protocol/test_http1.py +++ b/test/mitmproxy/protocol/test_http1.py @@ -1,5 +1,5 @@ -from netlib.http import http1 -from netlib.tcp import TCPClient +from mitmproxy.net.http import http1 +from mitmproxy.net.tcp import TCPClient from mitmproxy.test.tutils import treq from .. import tutils, tservers diff --git a/test/mitmproxy/protocol/test_http2.py b/test/mitmproxy/protocol/test_http2.py index b624489fe..4629d1099 100644 --- a/test/mitmproxy/protocol/test_http2.py +++ b/test/mitmproxy/protocol/test_http2.py @@ -11,10 +11,10 @@ import h2 from mitmproxy import options from mitmproxy.proxy.config import ProxyConfig -import netlib -from ...netlib import tservers as netlib_tservers +import mitmproxy.net +from ...mitmproxy.net import tservers as net_tservers from mitmproxy import exceptions -from netlib.http import http1, http2 +from mitmproxy.net.http import http1, http2 from .. import tservers @@ -28,7 +28,7 @@ logging.getLogger("PIL.PngImagePlugin").setLevel(logging.WARNING) requires_alpn = pytest.mark.skipif( - not netlib.tcp.HAS_ALPN, + not mitmproxy.net.tcp.HAS_ALPN, reason='requires OpenSSL with ALPN support') @@ -37,10 +37,10 @@ requires_alpn = pytest.mark.skipif( # print(msg) -class _Http2ServerBase(netlib_tservers.ServerTestBase): +class _Http2ServerBase(net_tservers.ServerTestBase): ssl = dict(alpn_select=b'h2') - class handler(netlib.tcp.BaseHandler): + class handler(mitmproxy.net.tcp.BaseHandler): def handle(self): h2_conn = h2.connection.H2Connection(client_side=False, header_encoding=False) @@ -122,11 +122,11 @@ class _Http2TestBase: self.server.server.handle_server_event = self.handle_server_event def _setup_connection(self): - client = netlib.tcp.TCPClient(("127.0.0.1", self.proxy.port)) + client = mitmproxy.net.tcp.TCPClient(("127.0.0.1", self.proxy.port)) client.connect() # send CONNECT request - client.wfile.write(http1.assemble_request(netlib.http.Request( + client.wfile.write(http1.assemble_request(mitmproxy.net.http.Request( 'authority', b'CONNECT', b'', diff --git a/test/mitmproxy/protocol/test_websockets.py b/test/mitmproxy/protocol/test_websockets.py index f22e95d55..71cbb5f49 100644 --- a/test/mitmproxy/protocol/test_websockets.py +++ b/test/mitmproxy/protocol/test_websockets.py @@ -7,17 +7,17 @@ from mitmproxy import options from mitmproxy import exceptions from mitmproxy.proxy.config import ProxyConfig -import netlib -from netlib import http -from ...netlib import tservers as netlib_tservers +import mitmproxy.net +from mitmproxy.net import http +from ...mitmproxy.net import tservers as net_tservers from .. import tservers -from netlib import websockets +from mitmproxy.net import websockets -class _WebSocketsServerBase(netlib_tservers.ServerTestBase): +class _WebSocketsServerBase(net_tservers.ServerTestBase): - class handler(netlib.tcp.BaseHandler): + class handler(mitmproxy.net.tcp.BaseHandler): def handle(self): try: @@ -78,7 +78,7 @@ class _WebSocketsTestBase: self.server.server.handle_websockets = self.handle_websockets def _setup_connection(self): - client = netlib.tcp.TCPClient(("127.0.0.1", self.proxy.port)) + client = mitmproxy.net.tcp.TCPClient(("127.0.0.1", self.proxy.port)) client.connect() request = http.Request( diff --git a/test/mitmproxy/test_contentview.py b/test/mitmproxy/test_contentview.py index 2c5e1c853..b0e77ce13 100644 --- a/test/mitmproxy/test_contentview.py +++ b/test/mitmproxy/test_contentview.py @@ -1,7 +1,7 @@ import mock from mitmproxy.exceptions import ContentViewException -from netlib.http import Headers -from netlib.http import url +from mitmproxy.net.http import Headers +from mitmproxy.net.http import url from mitmproxy.types import multidict import mitmproxy.contentviews as cv diff --git a/test/mitmproxy/test_custom_contentview.py b/test/mitmproxy/test_custom_contentview.py index 889fb8b32..28f7fb333 100644 --- a/test/mitmproxy/test_custom_contentview.py +++ b/test/mitmproxy/test_custom_contentview.py @@ -1,5 +1,5 @@ import mitmproxy.contentviews as cv -from netlib.http import Headers +from mitmproxy.net.http import Headers def test_custom_views(): diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index 48193fe7d..6972da0c7 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -10,8 +10,8 @@ from mitmproxy.utils import data from mitmproxy import master from mitmproxy.test import tutils as netutils -from netlib.http import Headers -from netlib.http import cookies +from mitmproxy.net.http import Headers +from mitmproxy.net.http import cookies from . import tutils, mastertest diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 14899be1a..5b9f38355 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -2,7 +2,7 @@ import mock import io import mitmproxy.test.tutils -from netlib.http import Headers +from mitmproxy.net.http import Headers import mitmproxy.io from mitmproxy import flowfilter, options from mitmproxy.addons import state diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py index 8ef2b7ee4..df0ccb77f 100644 --- a/test/mitmproxy/test_flow_export.py +++ b/test/mitmproxy/test_flow_export.py @@ -1,7 +1,7 @@ import re import mitmproxy.test.tutils -from netlib.http import Headers +from mitmproxy.net.http import Headers from mitmproxy import export # heh from . import tutils diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py index c0d978d2d..a9d9bb878 100644 --- a/test/mitmproxy/test_proxy.py +++ b/test/mitmproxy/test_proxy.py @@ -10,7 +10,7 @@ from mitmproxy.proxy.server import DummyServer, ProxyServer, ConnectionHandler from mitmproxy.proxy import config from mitmproxy import exceptions from pathod import test -from netlib.http import http1 +from mitmproxy.net.http import http1 from . import tutils diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py index f7f134437..7dd738f44 100644 --- a/test/mitmproxy/test_server.py +++ b/test/mitmproxy/test_server.py @@ -8,14 +8,14 @@ from mitmproxy import options from mitmproxy.addons import script from mitmproxy import http from mitmproxy.proxy.config import HostMatcher, parse_server_spec -import netlib.http -from netlib import tcp -from netlib import socks +import mitmproxy.net.http +from mitmproxy.net import tcp +from mitmproxy.net import socks from mitmproxy import certs from mitmproxy import exceptions -from netlib.http import authentication -from netlib.http import http1 -from netlib.tcp import Address +from mitmproxy.net.http import authentication +from mitmproxy.net.http import http1 +from mitmproxy.net.tcp import Address from mitmproxy.test.tutils import raises from pathod import pathoc from pathod import pathod @@ -297,7 +297,7 @@ class TestHTTPAuth(tservers.HTTPProxyTest): h'%s'='%s' """ % ( self.server.port, - netlib.http.authentication.BasicProxyAuth.AUTH_HEADER, + mitmproxy.net.http.authentication.BasicProxyAuth.AUTH_HEADER, authentication.assemble_http_basic_auth("basic", "test", "test") )) assert ret.status_code == 202 @@ -314,7 +314,7 @@ class TestHTTPReverseAuth(tservers.ReverseProxyTest): '/p/202' h'%s'='%s' """ % ( - netlib.http.authentication.BasicWebsiteAuth.AUTH_HEADER, + mitmproxy.net.http.authentication.BasicWebsiteAuth.AUTH_HEADER, authentication.assemble_http_basic_auth("basic", "test", "test") )) assert ret.status_code == 202 @@ -438,7 +438,7 @@ class TestHTTPSUpstreamServerVerificationWBadCert(tservers.HTTPProxyTest): def test_verification_w_bad_cert(self): # We only test for a single invalid cert here. # Actual testing of different root-causes (invalid hostname, expired, ...) - # is done in netlib. + # is done in mitmproxy.net. self.config.options.ssl_insecure = False r = self._request() assert r.status_code == 502 diff --git a/test/pathod/test_language_http2.py b/test/pathod/test_language_http2.py index 11e100ac8..7d3a8e60b 100644 --- a/test/pathod/test_language_http2.py +++ b/test/pathod/test_language_http2.py @@ -1,7 +1,7 @@ import io -from netlib import tcp -from netlib.http import user_agents +from mitmproxy.net import tcp +from mitmproxy.net.http import user_agents from pathod import language from pathod.language import http2 diff --git a/test/pathod/test_language_websocket.py b/test/pathod/test_language_websocket.py index 9d533d980..49fbd4e6d 100644 --- a/test/pathod/test_language_websocket.py +++ b/test/pathod/test_language_websocket.py @@ -1,6 +1,6 @@ from pathod import language from pathod.language import websockets -import netlib.websockets +import mitmproxy.net.websockets from . import tutils @@ -62,7 +62,7 @@ class TestWebsocketFrame: def test_flags(self): wf = parse_request("wf:fin:mask:rsv1:rsv2:rsv3") - frm = netlib.websockets.Frame.from_bytes(tutils.render(wf)) + frm = mitmproxy.net.websockets.Frame.from_bytes(tutils.render(wf)) assert frm.header.fin assert frm.header.mask assert frm.header.rsv1 @@ -70,7 +70,7 @@ class TestWebsocketFrame: assert frm.header.rsv3 wf = parse_request("wf:-fin:-mask:-rsv1:-rsv2:-rsv3") - frm = netlib.websockets.Frame.from_bytes(tutils.render(wf)) + frm = mitmproxy.net.websockets.Frame.from_bytes(tutils.render(wf)) assert not frm.header.fin assert not frm.header.mask assert not frm.header.rsv1 @@ -80,15 +80,15 @@ class TestWebsocketFrame: def fr(self, spec, **kwargs): settings = language.base.Settings(**kwargs) wf = parse_request(spec) - return netlib.websockets.Frame.from_bytes(tutils.render(wf, settings)) + return mitmproxy.net.websockets.Frame.from_bytes(tutils.render(wf, settings)) def test_construction(self): assert self.fr("wf:c1").header.opcode == 1 assert self.fr("wf:c0").header.opcode == 0 assert self.fr("wf:cbinary").header.opcode ==\ - netlib.websockets.OPCODE.BINARY + mitmproxy.net.websockets.OPCODE.BINARY assert self.fr("wf:ctext").header.opcode ==\ - netlib.websockets.OPCODE.TEXT + mitmproxy.net.websockets.OPCODE.TEXT def test_rawbody(self): frm = self.fr("wf:mask:r'foo'") diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py index 98dc9825e..90177ff65 100644 --- a/test/pathod/test_pathoc.py +++ b/test/pathod/test_pathoc.py @@ -1,9 +1,9 @@ import io from mock import Mock -from netlib import http -from netlib import tcp -from netlib.http import http1 +from mitmproxy.net import http +from mitmproxy.net import tcp +from mitmproxy.net.http import http1 from mitmproxy.test.tutils import raises from mitmproxy import exceptions diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 402cd638a..8ee7a2fd9 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -1,7 +1,7 @@ import io from pathod import pathod -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy import exceptions from . import tutils diff --git a/test/pathod/test_protocols_http2.py b/test/pathod/test_protocols_http2.py index a7303115c..d77702a3a 100644 --- a/test/pathod/test_protocols_http2.py +++ b/test/pathod/test_protocols_http2.py @@ -2,12 +2,12 @@ import mock import codecs import hyperframe -from netlib import tcp, http +from mitmproxy.net import tcp, http from mitmproxy.test.tutils import raises -from netlib.http import http2 +from mitmproxy.net.http import http2 from mitmproxy import exceptions -from ..netlib import tservers as netlib_tservers +from ..mitmproxy.net import tservers as net_tservers from pathod.protocols.http2 import HTTP2StateProtocol, TCPHandler @@ -66,7 +66,7 @@ class TestProtocol: assert mock_server_method.called -class TestCheckALPNMatch(netlib_tservers.ServerTestBase): +class TestCheckALPNMatch(net_tservers.ServerTestBase): handler = EchoHandler ssl = dict( alpn_select=b'h2', @@ -82,7 +82,7 @@ class TestCheckALPNMatch(netlib_tservers.ServerTestBase): assert protocol.check_alpn() -class TestCheckALPNMismatch(netlib_tservers.ServerTestBase): +class TestCheckALPNMismatch(net_tservers.ServerTestBase): handler = EchoHandler ssl = dict( alpn_select=None, @@ -99,7 +99,7 @@ class TestCheckALPNMismatch(netlib_tservers.ServerTestBase): protocol.check_alpn() -class TestPerformServerConnectionPreface(netlib_tservers.ServerTestBase): +class TestPerformServerConnectionPreface(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): @@ -136,7 +136,7 @@ class TestPerformServerConnectionPreface(netlib_tservers.ServerTestBase): protocol.perform_server_connection_preface(force=True) -class TestPerformClientConnectionPreface(netlib_tservers.ServerTestBase): +class TestPerformClientConnectionPreface(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): @@ -197,7 +197,7 @@ class TestserverstreamIds: assert self.protocol.current_stream_id == 6 -class TestApplySettings(netlib_tservers.ServerTestBase): +class TestApplySettings(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): # check settings acknowledgement @@ -290,7 +290,7 @@ class TestCreateBody: assert bytes[2] == codecs.decode('0000020001000000013432', 'hex_codec') -class TestReadRequest(netlib_tservers.ServerTestBase): +class TestReadRequest(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): @@ -320,7 +320,7 @@ class TestReadRequest(netlib_tservers.ServerTestBase): assert req.content == b'foobar' -class TestReadRequestRelative(netlib_tservers.ServerTestBase): +class TestReadRequestRelative(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): self.wfile.write( @@ -343,7 +343,7 @@ class TestReadRequestRelative(netlib_tservers.ServerTestBase): assert req.path == "*" -class TestReadRequestAbsolute(netlib_tservers.ServerTestBase): +class TestReadRequestAbsolute(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): self.wfile.write( @@ -367,7 +367,7 @@ class TestReadRequestAbsolute(netlib_tservers.ServerTestBase): assert req.port == 22 -class TestReadResponse(netlib_tservers.ServerTestBase): +class TestReadResponse(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): self.wfile.write( @@ -396,7 +396,7 @@ class TestReadResponse(netlib_tservers.ServerTestBase): assert resp.timestamp_end -class TestReadEmptyResponse(netlib_tservers.ServerTestBase): +class TestReadEmptyResponse(net_tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): self.wfile.write( diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index 16dec187f..ccc3df438 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -7,7 +7,7 @@ import urllib from mitmproxy.utils import data -from netlib import tcp +from mitmproxy.net import tcp from mitmproxy.test import tutils from pathod import language diff --git a/tox.ini b/tox.ini index 8747d2f0c..ff1484d0e 100644 --- a/tox.ini +++ b/tox.ini @@ -19,4 +19,4 @@ commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html [testenv:lint] deps = flake8>=2.6.2, <3.1 -commands = flake8 --jobs 8 --count mitmproxy netlib pathod examples test +commands = flake8 --jobs 8 --count mitmproxy pathod examples test