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:
parent
22192d1a46
commit
05492baf8d
|
@ -123,6 +123,7 @@ def read_http_body(rfile, connection, headers, all, limit):
|
||||||
content = rfile.read(limit if limit else None)
|
content = rfile.read(limit if limit else None)
|
||||||
connection.close = True
|
connection.close = True
|
||||||
else:
|
else:
|
||||||
|
connection.close = True
|
||||||
content = ""
|
content = ""
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import threading, Queue
|
import threading, Queue, time
|
||||||
import os, shutil,tempfile
|
import os, shutil,tempfile
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import libpry
|
import libpry
|
||||||
from libmproxy import proxy, flow, controller, utils
|
from libmproxy import proxy, flow, controller, utils
|
||||||
import requests
|
import human_curl as hurl
|
||||||
import libpathod.test
|
import libpathod.test
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ def tflow_err():
|
||||||
|
|
||||||
class TestMaster(controller.Master):
|
class TestMaster(controller.Master):
|
||||||
def __init__(self, port, testq):
|
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)
|
controller.Master.__init__(self, s)
|
||||||
self.testq = testq
|
self.testq = testq
|
||||||
self.log = []
|
self.log = []
|
||||||
|
@ -106,17 +106,21 @@ class ProxTest:
|
||||||
"""
|
"""
|
||||||
Constructs a pathod request, with the appropriate base and proxy.
|
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
|
@property
|
||||||
def proxies(self):
|
def proxies(self):
|
||||||
"""
|
"""
|
||||||
The URL base for the server instance.
|
The URL base for the server instance.
|
||||||
"""
|
"""
|
||||||
return {
|
return (
|
||||||
"http" : "http://127.0.0.1:%s"%self.proxy.port,
|
("https" if self.ssl else "http", ("127.0.0.1", self.proxy.port))
|
||||||
"https" : "http://127.0.0.1:%s"%self.proxy.port
|
)
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def urlbase(self):
|
def urlbase(self):
|
||||||
|
@ -130,7 +134,6 @@ class ProxTest:
|
||||||
return pthread.tmaster.log
|
return pthread.tmaster.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def tmpdir(*args, **kwargs):
|
def tmpdir(*args, **kwargs):
|
||||||
orig_workdir = os.getcwd()
|
orig_workdir = os.getcwd()
|
||||||
|
|
Loading…
Reference in New Issue