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.
This commit is contained in:
Aldo Cortesi 2012-06-09 16:17:51 +12:00
parent 22192d1a46
commit 05492baf8d
2 changed files with 13 additions and 9 deletions

View File

@ -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

View File

@ -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()