aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/flow.py8
-rw-r--r--libmproxy/tnetstring.py (renamed from libmproxy/netstring.py)37
-rw-r--r--test/.pry1
3 files changed, 26 insertions, 20 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index 8ec1a6a3..c0130ec3 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -2,9 +2,9 @@
This module provides more sophisticated flow tracking. These match requests
with their responses, and provide filtering and interception facilities.
"""
-import json, hashlib, Cookie, cookielib, base64, copy, re
+import hashlib, Cookie, cookielib, copy, re
import time
-import netstring, filt, script, utils, encoding, proxy
+import tnetstring, filt, script, utils, encoding, proxy
from email.utils import parsedate_tz, formatdate, mktime_tz
import controller, version
@@ -1319,7 +1319,7 @@ class FlowWriter:
def add(self, flow):
d = flow._get_state()
- netstring.dump(d, self.fo)
+ tnetstring.dump(d, self.fo)
class FlowReadError(Exception):
@@ -1339,7 +1339,7 @@ class FlowReader:
off = 0
try:
while 1:
- data = netstring.load(self.fo)
+ data = tnetstring.load(self.fo)
off = self.fo.tell()
yield Flow._from_state(data)
except ValueError, v:
diff --git a/libmproxy/netstring.py b/libmproxy/tnetstring.py
index 03e38c6a..76b15a02 100644
--- a/libmproxy/netstring.py
+++ b/libmproxy/tnetstring.py
@@ -1,5 +1,25 @@
+# imported from the tnetstring project: https://github.com/rfk/tnetstring
+#
+# Copyright (c) 2011 Ryan Kelly
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
"""
-
tnetstring: data serialization using typed netstrings
======================================================
@@ -376,18 +396,3 @@ def pop(string,encoding=None):
d[key] = val
return (d,remain)
raise ValueError("unknown type tag")
-
-
-
-# Use the c-extension version if available
-try:
- import _tnetstring
-except ImportError:
- pass
-else:
- dumps = _tnetstring.dumps
- load = _tnetstring.load
- loads = _tnetstring.loads
- pop = _tnetstring.pop
-
-
diff --git a/test/.pry b/test/.pry
index 63b74633..f6f18e7b 100644
--- a/test/.pry
+++ b/test/.pry
@@ -2,4 +2,5 @@ base = ..
coverage = ../libmproxy
exclude = .
../libmproxy/contrib
+ ../libmproxy/tnetstring.py