aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpathod/pathod.py19
-rw-r--r--test/test_pathod.py8
-rw-r--r--test/tutils.py5
3 files changed, 22 insertions, 10 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index fa5d519c..ce64acf9 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -70,15 +70,16 @@ class PathodHandler(tcp.BaseHandler):
'\r\n'
)
self.wfile.flush()
- 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)
+ if not self.server.ssloptions.not_after_connect:
+ 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
diff --git a/test/test_pathod.py b/test/test_pathod.py
index 0463fc55..665ef843 100644
--- a/test/test_pathod.py
+++ b/test/test_pathod.py
@@ -52,6 +52,14 @@ class TestNoApi(tutils.DaemonTests):
assert not "Log" in r.content
+class TestNotAfterConnect(tutils.DaemonTests):
+ ssl = False
+ not_after_connect = True
+ def test_connect(self):
+ v = self.pathoc(r"get:'http://foo.com/p/202':da", connect_to=("localhost", self.d.port))
+ assert v[1] == 202
+
+
class TestNohang(tutils.DaemonTests):
nohang = True
def test_nohang(self):
diff --git a/test/tutils.py b/test/tutils.py
index 580174d9..59649053 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -1,6 +1,6 @@
import tempfile, os, shutil
from contextlib import contextmanager
-from libpathod import utils, test, pathoc
+from libpathod import utils, test, pathoc, pathod
import requests
class DaemonTests:
@@ -10,12 +10,15 @@ class DaemonTests:
ssl = False
timeout = None
hexdump = False
+ not_after_connect = False
@classmethod
def setUpAll(self):
+ so = pathod.SSLOptions(not_after_connect = self.not_after_connect)
self.d = test.Daemon(
staticdir=test_data.path("data"),
anchors=[("/anchor/.*", "202:da")],
ssl = self.ssl,
+ ssloptions = so,
sizelimit=1*1024*1024,
noweb = self.noweb,
noapi = self.noapi,