aboutsummaryrefslogtreecommitdiffstats
path: root/pathod/pathoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'pathod/pathoc.py')
-rw-r--r--pathod/pathoc.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/pathod/pathoc.py b/pathod/pathoc.py
index a49ed351..5cfb4591 100644
--- a/pathod/pathoc.py
+++ b/pathod/pathoc.py
@@ -13,21 +13,24 @@ import threading
import OpenSSL.crypto
import six
-from netlib import tcp, http, certutils, websockets, socks
+from netlib import tcp, certutils, websockets, socks
from netlib.exceptions import HttpException, TcpDisconnect, TcpTimeout, TlsException, TcpException, \
NetlibException
from netlib.http import http1, http2
-import language.http
-import language.websockets
-from . import utils, log
+from . import log, language
import logging
from netlib.tutils import treq
+from netlib import strutils
logging.getLogger("hpack").setLevel(logging.WARNING)
+def xrepr(s):
+ return repr(s)[1:-1]
+
+
class PathocError(Exception):
pass
@@ -43,7 +46,7 @@ class SSLInfo(object):
"Cipher: %s, %s bit, %s" % self.cipher,
"SSL certificate chain:"
]
- for n,i in enumerate(self.certchain):
+ for n, i in enumerate(self.certchain):
parts.append(" Certificate [%s]" % n)
parts.append("\tSubject: ")
for cn in i.get_subject().get_components():
@@ -74,7 +77,6 @@ class SSLInfo(object):
return "\n".join(parts)
-
class WebsocketFrameReader(threading.Thread):
def __init__(
@@ -284,7 +286,7 @@ class Pathoc(tcp.TCPClient):
if self.use_http2 and not self.ssl:
raise NotImplementedError("HTTP2 without SSL is not supported.")
- tcp.TCPClient.connect(self)
+ ret = tcp.TCPClient.connect(self)
if connect_to:
self.http_connect(connect_to)
@@ -322,6 +324,7 @@ class Pathoc(tcp.TCPClient):
if self.timeout:
self.settimeout(self.timeout)
+ return ret
def stop(self):
if self.ws_framereader:
@@ -426,7 +429,7 @@ class Pathoc(tcp.TCPClient):
finally:
if resp:
lg("<< %s %s: %s bytes" % (
- resp.status_code, utils.xrepr(resp.reason), len(resp.content)
+ resp.status_code, strutils.bytes_to_escaped_str(resp.reason), len(resp.content)
))
if resp.status_code in self.ignorecodes:
lg.suppress()