Proxy mode: drop to SSL if we see an HTTP CONNECT request

This commit is contained in:
Aldo Cortesi 2013-01-05 17:06:41 +13:00
parent 1e932e7045
commit c744ef2dcb
2 changed files with 16 additions and 2 deletions

View File

@ -63,14 +63,24 @@ class PathodHandler(tcp.BaseHandler):
m = utils.MemBool()
if m(http.parse_init_connect(line)):
headers = http.read_headers(self.rfile)
self.wfile.write(
'HTTP/1.1 200 Connection established\r\n' +
('Proxy-agent: %s\r\n'%version.NAMEVERSION) +
'\r\n'
)
self.wfile.flush()
if m(http.parse_init_proxy(line)):
try:
self.convert_to_ssl(
self.server.ssloptions.certfile,
self.server.ssloptions.keyfile,
)
except tcp.NetLibError, v:
s = str(v)
self.info(s)
return False, dict(type = "error", msg = s)
return True, None
elif m(http.parse_init_proxy(line)):
method, _, _, _, path, httpversion = m.v
elif m(http.parse_init_http(line)):
method, path, httpversion = m.v

View File

@ -143,6 +143,10 @@ class CommonTests(tutils.DaemonTests):
assert rsp.status_code == 800
assert "File access denied" in rsp.content
def test_proxy(self):
v = self.pathoc(r"get:'http://foo.com/p/202':da")
assert v[1] == 202
class TestDaemon(CommonTests):
ssl = False