aboutsummaryrefslogtreecommitdiffstats
path: root/pathod/pathod.py
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-06-08 21:34:56 +0530
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-06-15 09:49:38 +0200
commitfa40531a80bbe5e0011383fe81f7e4785b2b0a7d (patch)
treedd0ad1fcdde3895ccc2bafa8666fc84ed0a82bd5 /pathod/pathod.py
parentd9b940c21e7729da1b6a63d8e82cd3ad4a82f775 (diff)
downloadmitmproxy-fa40531a80bbe5e0011383fe81f7e4785b2b0a7d.tar.gz
mitmproxy-fa40531a80bbe5e0011383fe81f7e4785b2b0a7d.tar.bz2
mitmproxy-fa40531a80bbe5e0011383fe81f7e4785b2b0a7d.zip
Py3: pathod
Diffstat (limited to 'pathod/pathod.py')
-rw-r--r--pathod/pathod.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/pathod/pathod.py b/pathod/pathod.py
index 315a04e0..3df86aae 100644
--- a/pathod/pathod.py
+++ b/pathod/pathod.py
@@ -4,19 +4,20 @@ import logging
import os
import sys
import threading
-import urllib
from netlib import tcp
from netlib import certutils
from netlib import websockets
from netlib import version
+
+from six.moves import urllib
from netlib.exceptions import HttpException, HttpReadDisconnect, TcpTimeout, TcpDisconnect, \
TlsException
from . import language, utils, log, protocols
-DEFAULT_CERT_DOMAIN = "pathod.net"
+DEFAULT_CERT_DOMAIN = b"pathod.net"
CONFDIR = "~/.mitmproxy"
CERTSTORE_BASENAME = "mitmproxy"
CA_CERT_NAME = "mitmproxy-ca.pem"
@@ -185,7 +186,7 @@ class PathodHandler(tcp.BaseHandler):
break
else:
if m(path.startswith(self.server.craftanchor)):
- spec = urllib.unquote(path)[len(self.server.craftanchor):]
+ spec = urllib.parse.unquote(path)[len(self.server.craftanchor):]
if spec:
try:
anchor_gen = language.parse_pathod(spec, self.use_http2)
@@ -211,7 +212,7 @@ class PathodHandler(tcp.BaseHandler):
"No valid craft request found"
)])
- spec = anchor_gen.next()
+ spec = next(anchor_gen)
if self.use_http2 and isinstance(spec, language.http2.Response):
spec.stream_id = req.stream_id
@@ -283,15 +284,10 @@ class PathodHandler(tcp.BaseHandler):
return
def addlog(self, log):
- # FIXME: The bytes in the log should not be escaped. We do this at the
- # moment because JSON encoding can't handle binary data, and I don't
- # want to base64 everything.
if self.server.logreq:
- encoded_bytes = self.rfile.get_log().encode("string_escape")
- log["request_bytes"] = encoded_bytes
+ log["request_bytes"] = self.rfile.get_log()
if self.server.logresp:
- encoded_bytes = self.wfile.get_log().encode("string_escape")
- log["response_bytes"] = encoded_bytes
+ log["response_bytes"] = self.wfile.get_log()
self.server.add_log(log)