diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2013-07-30 09:42:29 +1200 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2013-07-30 09:42:29 +1200 |
| commit | 439d9a294c7df4d45b133e42edb3521901628daa (patch) | |
| tree | 9aa33a65c93aefa8bdaa9e9d9636c56781af56af | |
| parent | 5f0b5532bc9681c0fac8cfe821f49bff904d47be (diff) | |
| download | mitmproxy-439d9a294c7df4d45b133e42edb3521901628daa.tar.gz mitmproxy-439d9a294c7df4d45b133e42edb3521901628daa.tar.bz2 mitmproxy-439d9a294c7df4d45b133e42edb3521901628daa.zip | |
Make use of a change to netlib.tcp that clarifies error conditions for flush and close.
Should fix #144.
| -rw-r--r-- | libmproxy/proxy.py | 7 | ||||
| -rw-r--r-- | test/test_proxy.py | 2 |
2 files changed, 3 insertions, 6 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index ae5cd7d3..b1a5f084 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -85,12 +85,9 @@ class ServerConnection(tcp.TCPClient): if self.connection: try: self.wfile.flush() - except IOError, tcp.NetLibDisconnect: # pragma: no cover - pass - try: - self.connection.close() - except IOError: + except tcp.NetLibDisconnect: # pragma: no cover pass + self.connection.close() diff --git a/test/test_proxy.py b/test/test_proxy.py index 5828d077..c5640d8a 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -56,7 +56,7 @@ class TestServerConnection: sc = proxy.ServerConnection(proxy.ProxyConfig(), "http", self.d.IFACE, self.d.port, "host.com") sc.connect() sc.connection = mock.Mock() - sc.connection.close = mock.Mock(side_effect=IOError) + sc.connection.flush = mock.Mock(side_effect=tcp.NetLibDisconnect) sc.terminate() |
