diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-09 16:17:51 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-09 16:17:51 +1200 |
commit | 05492baf8d2c970c5e5c3d207549893490ead751 (patch) | |
tree | 936d486399857b88c97d7767c3eed7dbecefb8b5 | |
parent | 22192d1a46a45b3824290ff4095539fa8b6be1fa (diff) | |
download | mitmproxy-05492baf8d2c970c5e5c3d207549893490ead751.tar.gz mitmproxy-05492baf8d2c970c5e5c3d207549893490ead751.tar.bz2 mitmproxy-05492baf8d2c970c5e5c3d207549893490ead751.zip |
Move from requests to human_curl.
It turns out that _none_ of the Python stdlib or anything that relies on it
supports CONNECT through a proxy. Beggars belief, but there you go.
-rw-r--r-- | libmproxy/proxy.py | 1 | ||||
-rw-r--r-- | test/tutils.py | 21 |
2 files changed, 13 insertions, 9 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 9249de86..2d4ee988 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -123,6 +123,7 @@ def read_http_body(rfile, connection, headers, all, limit): content = rfile.read(limit if limit else None) connection.close = True else: + connection.close = True content = "" return content diff --git a/test/tutils.py b/test/tutils.py index 19dbb139..e1bb49a5 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -1,9 +1,9 @@ -import threading, Queue +import threading, Queue, time import os, shutil,tempfile from contextlib import contextmanager import libpry from libmproxy import proxy, flow, controller, utils -import requests +import human_curl as hurl import libpathod.test import random @@ -44,7 +44,7 @@ def tflow_err(): class TestMaster(controller.Master): def __init__(self, port, testq): - s = proxy.ProxyServer(proxy.ProxyConfig("data/testkey.pem"), port) + s = proxy.ProxyServer(proxy.ProxyConfig(test_data.path("data/testkey.pem")), port) controller.Master.__init__(self, s) self.testq = testq self.log = [] @@ -106,17 +106,21 @@ class ProxTest: """ Constructs a pathod request, with the appropriate base and proxy. """ - return requests.get(self.urlbase + "/p/" + spec, proxies=self.proxies, verify=False) + return hurl.get( + self.urlbase + "/p/" + spec, + proxy=self.proxies, + validate_cert=False, + #debug=hurl.utils.stdout_debug + ) @property def proxies(self): """ The URL base for the server instance. """ - return { - "http" : "http://127.0.0.1:%s"%self.proxy.port, - "https" : "http://127.0.0.1:%s"%self.proxy.port - } + return ( + ("https" if self.ssl else "http", ("127.0.0.1", self.proxy.port)) + ) @property def urlbase(self): @@ -130,7 +134,6 @@ class ProxTest: return pthread.tmaster.log - @contextmanager def tmpdir(*args, **kwargs): orig_workdir = os.getcwd() |