aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pathod/app.py5
-rw-r--r--pathod/pathoc.py5
-rw-r--r--pathod/utils.py14
-rw-r--r--test/pathod/test_utils.py11
4 files changed, 6 insertions, 29 deletions
diff --git a/pathod/app.py b/pathod/app.py
index 7e9860b9..e3216c58 100644
--- a/pathod/app.py
+++ b/pathod/app.py
@@ -3,8 +3,9 @@ import pprint
import io
import copy
from flask import Flask, jsonify, render_template, request, abort, make_response
-from . import version, language, utils
+from . import version, language
from netlib.http import user_agents
+from netlib import strutils
logging.basicConfig(level="DEBUG")
EXAMPLE_HOST = "example.com"
@@ -166,7 +167,7 @@ def make_app(noapi, debug):
settings.websocket_key = EXAMPLE_WEBSOCKET_KEY
language.serve(safe, s, settings)
- args["output"] = utils.escape_unprintables(s.getvalue())
+ args["output"] = strutils.bytes_to_escaped_str(s.getvalue())
return render(template, False, **args)
@app.route('/response_preview')
diff --git a/pathod/pathoc.py b/pathod/pathoc.py
index ebbd952a..2b7d053c 100644
--- a/pathod/pathoc.py
+++ b/pathod/pathoc.py
@@ -18,10 +18,11 @@ from netlib.exceptions import HttpException, TcpDisconnect, TcpTimeout, TlsExcep
NetlibException
from netlib.http import http1, http2
-from . import utils, log, language
+from . import log, language
import logging
from netlib.tutils import treq
+from netlib import strutils
logging.getLogger("hpack").setLevel(logging.WARNING)
@@ -427,7 +428,7 @@ class Pathoc(tcp.TCPClient):
finally:
if resp:
lg("<< %s %s: %s bytes" % (
- resp.status_code, 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()
diff --git a/pathod/utils.py b/pathod/utils.py
index 96b54ab8..3276198a 100644
--- a/pathod/utils.py
+++ b/pathod/utils.py
@@ -2,8 +2,6 @@ import os
import sys
import netlib.utils
-from netlib import strutils
-
class MemBool(object):
@@ -28,18 +26,6 @@ def parse_anchor_spec(s):
return tuple(s.split("=", 1))
-def escape_unprintables(s):
- """
- Like inner_repr, but preserves line breaks.
- """
- s = s.replace(b"\r\n", b"PATHOD_MARKER_RN")
- s = s.replace(b"\n", b"PATHOD_MARKER_N")
- s = strutils.bytes_to_escaped_str(s)
- s = s.replace("PATHOD_MARKER_RN", "\n")
- s = s.replace("PATHOD_MARKER_N", "\n")
- return s
-
-
data = netlib.utils.Data(__name__)
diff --git a/test/pathod/test_utils.py b/test/pathod/test_utils.py
index ab4abbae..a46a523a 100644
--- a/test/pathod/test_utils.py
+++ b/test/pathod/test_utils.py
@@ -1,8 +1,6 @@
from pathod import utils
import tutils
-import six
-
def test_membool():
m = utils.MemBool()
@@ -20,12 +18,3 @@ def test_parse_anchor_spec():
def test_data_path():
tutils.raises(ValueError, utils.data.path, "nonexistent")
-
-
-def test_escape_unprintables():
- s = bytes(range(256))
- if six.PY2:
- s = "".join([chr(i) for i in range(255)])
- e = utils.escape_unprintables(s)
- assert e.encode('ascii')
- assert "PATHOD_MARKER" not in e