diff options
Diffstat (limited to 'netlib')
-rw-r--r-- | netlib/exceptions.py | 59 | ||||
-rw-r--r-- | netlib/http/http1/assemble.py | 2 | ||||
-rw-r--r-- | netlib/http/http1/read.py | 2 | ||||
-rw-r--r-- | netlib/http/http2/framereader.py | 4 | ||||
-rw-r--r-- | netlib/tcp.py | 2 |
5 files changed, 5 insertions, 64 deletions
diff --git a/netlib/exceptions.py b/netlib/exceptions.py deleted file mode 100644 index d0b15d27..00000000 --- a/netlib/exceptions.py +++ /dev/null @@ -1,59 +0,0 @@ -""" -We try to be very hygienic regarding the exceptions we throw: -Every Exception netlib raises shall be a subclass of NetlibException. - - -See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/ -""" - - -class NetlibException(Exception): - """ - Base class for all exceptions thrown by netlib. - """ - def __init__(self, message=None): - super().__init__(message) - - -class Disconnect: - """Immediate EOF""" - - -class HttpException(NetlibException): - pass - - -class HttpReadDisconnect(HttpException, Disconnect): - pass - - -class HttpSyntaxException(HttpException): - pass - - -class TcpException(NetlibException): - pass - - -class TcpDisconnect(TcpException, Disconnect): - pass - - -class TcpReadIncomplete(TcpException): - pass - - -class TcpTimeout(TcpException): - pass - - -class TlsException(NetlibException): - pass - - -class InvalidCertificateException(TlsException): - pass - - -class Timeout(TcpException): - pass diff --git a/netlib/http/http1/assemble.py b/netlib/http/http1/assemble.py index 3d65da34..e0a91ad8 100644 --- a/netlib/http/http1/assemble.py +++ b/netlib/http/http1/assemble.py @@ -1,5 +1,5 @@ import netlib.http.url -from netlib import exceptions +from mitmproxy import exceptions def assemble_request(request): diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py index 89b73c5a..e6b22863 100644 --- a/netlib/http/http1/read.py +++ b/netlib/http/http1/read.py @@ -7,7 +7,7 @@ from netlib.http import response from netlib.http import headers from netlib.http import url from netlib import check -from netlib import exceptions +from mitmproxy import exceptions def get_header_tokens(headers, key): diff --git a/netlib/http/http2/framereader.py b/netlib/http/http2/framereader.py index 8b7cfffb..6a164919 100644 --- a/netlib/http/http2/framereader.py +++ b/netlib/http/http2/framereader.py @@ -1,7 +1,7 @@ import codecs import hyperframe -from ...exceptions import HttpException +from mitmproxy import exceptions def read_raw_frame(rfile): @@ -9,7 +9,7 @@ def read_raw_frame(rfile): length = int(codecs.encode(header[:3], 'hex_codec'), 16) if length == 4740180: - raise HttpException("Length field looks more like HTTP/1.1:\n{}".format(rfile.read(-1))) + raise exceptions.HttpException("Length field looks more like HTTP/1.1:\n{}".format(rfile.read(-1))) body = rfile.safe_read(length) return [header, body] diff --git a/netlib/tcp.py b/netlib/tcp.py index 6e323957..ac368a9c 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -20,7 +20,7 @@ from OpenSSL import SSL from mitmproxy import certs from mitmproxy.utils import version_check from mitmproxy.types import serializable -from netlib import exceptions +from mitmproxy import exceptions from mitmproxy.types import basethread # This is a rather hackish way to make sure that |