aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-04-14 11:58:10 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-04-14 11:58:10 +1200
commitbea0bd236a60e3e6c80027448e51b7802394304a (patch)
tree1cc160e19eb1834703798503f1818e4278bce1b2 /libmproxy
parentf37efecd0a22313eacad33251512ef371557fde7 (diff)
downloadmitmproxy-bea0bd236a60e3e6c80027448e51b7802394304a.tar.gz
mitmproxy-bea0bd236a60e3e6c80027448e51b7802394304a.tar.bz2
mitmproxy-bea0bd236a60e3e6c80027448e51b7802394304a.zip
Housekeeping and cleanups
- No output to stdout on load in examples - they muck up the test suite. - Use the odict module directly, rather than aliasing it. The small convenience this gives to scripters is not worth it. - Move the cookie tests from the flow test module to the protocol_http test module.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/console/contentview.py3
-rw-r--r--libmproxy/console/flowview.py9
-rw-r--r--libmproxy/flow.py3
-rw-r--r--libmproxy/protocol/http.py28
4 files changed, 21 insertions, 22 deletions
diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py
index 12ed5b64..454c992f 100644
--- a/libmproxy/console/contentview.py
+++ b/libmproxy/console/contentview.py
@@ -12,6 +12,7 @@ import traceback
import urwid
import netlib.utils
+from netlib import odict
from . import common
from .. import utils, encoding, flow
@@ -519,7 +520,7 @@ def get_content_view(viewmode, hdrItems, content, limit, logfunc, is_request):
return "No content", ""
msg = []
- hdrs = flow.ODictCaseless([list(i) for i in hdrItems])
+ hdrs = odict.ODictCaseless([list(i) for i in hdrItems])
enc = hdrs.get_first("content-encoding")
if enc and enc != "identity":
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index 9776f2b1..d7dc0d23 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import
import os, sys, copy
import urwid
+from netlib import odict
from . import common, grideditor, contentview, signals, searchable, tabs
from . import flowdetailview
from .. import utils, flow, controller
@@ -275,11 +276,11 @@ class FlowView(tabs.Tabs):
signals.flow_change.send(self, flow = self.flow)
def set_headers(self, lst, conn):
- conn.headers = flow.ODictCaseless(lst)
+ conn.headers = odict.ODictCaseless(lst)
signals.flow_change.send(self, flow = self.flow)
def set_query(self, lst, conn):
- conn.set_query(flow.ODict(lst))
+ conn.set_query(odict.ODict(lst))
signals.flow_change.send(self, flow = self.flow)
def set_path_components(self, lst, conn):
@@ -287,7 +288,7 @@ class FlowView(tabs.Tabs):
signals.flow_change.send(self, flow = self.flow)
def set_form(self, lst, conn):
- conn.set_form_urlencoded(flow.ODict(lst))
+ conn.set_form_urlencoded(odict.ODict(lst))
signals.flow_change.send(self, flow = self.flow)
def edit_form(self, conn):
@@ -311,7 +312,7 @@ class FlowView(tabs.Tabs):
if not self.flow.response:
self.flow.response = HTTPResponse(
self.flow.request.httpversion,
- 200, "OK", flow.ODictCaseless(), ""
+ 200, "OK", odict.ODictCaseless(), ""
)
self.flow.response.reply = controller.DummyReply()
message = self.flow.response
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index 49c72faf..a010bb39 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -17,9 +17,6 @@ from .proxy.config import HostMatcher
from .proxy.connection import ClientConnection, ServerConnection
import urlparse
-ODict = odict.ODict
-ODictCaseless = odict.ODictCaseless
-
class AppRegistry:
def __init__(self):
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index c763db4c..496b71cc 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -8,7 +8,7 @@ from email.utils import parsedate_tz, formatdate, mktime_tz
import threading
from netlib import http, tcp, http_status
import netlib.utils
-from netlib.odict import ODict, ODictCaseless
+from netlib import odict
from .tcp import TCPHandler
from .primitives import KILL, ProtocolHandler, Flow, Error
from ..proxy.connection import ServerConnection
@@ -45,7 +45,7 @@ def send_connect_request(conn, host, port, update_state=True):
port,
None,
(1, 1),
- ODictCaseless(),
+ odict.ODictCaseless(),
""
)
conn.send(upstream_request.assemble())
@@ -100,7 +100,7 @@ class HTTPMessage(stateobject.StateObject):
timestamp_end=None):
self.httpversion = httpversion
self.headers = headers
- """@type: ODictCaseless"""
+ """@type: odict.ODictCaseless"""
self.content = content
self.timestamp_start = timestamp_start
@@ -108,7 +108,7 @@ class HTTPMessage(stateobject.StateObject):
_stateobject_attributes = dict(
httpversion=tuple,
- headers=ODictCaseless,
+ headers=odict.ODictCaseless,
content=str,
timestamp_start=float,
timestamp_end=float
@@ -242,7 +242,7 @@ class HTTPRequest(HTTPMessage):
httpversion: HTTP version tuple, e.g. (1,1)
- headers: ODictCaseless object
+ headers: odict.ODictCaseless object
content: Content of the request, None, or CONTENT_MISSING if there
is content associated, but not present. CONTENT_MISSING evaluates
@@ -280,7 +280,7 @@ class HTTPRequest(HTTPMessage):
timestamp_end=None,
form_out=None
):
- assert isinstance(headers, ODictCaseless) or not headers
+ assert isinstance(headers, odict.ODictCaseless) or not headers
HTTPMessage.__init__(
self,
httpversion,
@@ -521,7 +521,7 @@ class HTTPRequest(HTTPMessage):
return self.get_form_urlencoded()
elif self.headers.in_any("content-type", HDR_FORM_MULTIPART, True):
return self.get_form_multipart()
- return ODict([])
+ return odict.ODict([])
def get_form_urlencoded(self):
"""
@@ -530,13 +530,13 @@ class HTTPRequest(HTTPMessage):
indicates non-form data.
"""
if self.content and self.headers.in_any("content-type", HDR_FORM_URLENCODED, True):
- return ODict(utils.urldecode(self.content))
- return ODict([])
+ return odict.ODict(utils.urldecode(self.content))
+ return odict.ODict([])
def get_form_multipart(self):
if self.content and self.headers.in_any("content-type", HDR_FORM_MULTIPART, True):
- return ODict(utils.multipartdecode(self.headers, self.content))
- return ODict([])
+ return odict.ODict(utils.multipartdecode(self.headers, self.content))
+ return odict.ODict([])
def set_form_urlencoded(self, odict):
"""
@@ -577,8 +577,8 @@ class HTTPRequest(HTTPMessage):
"""
_, _, _, _, query, _ = urlparse.urlparse(self.url)
if query:
- return ODict(utils.urldecode(query))
- return ODict([])
+ return odict.ODict(utils.urldecode(query))
+ return odict.ODict([])
def set_query(self, odict):
"""
@@ -697,7 +697,7 @@ class HTTPResponse(HTTPMessage):
def __init__(self, httpversion, code, msg, headers, content, timestamp_start=None,
timestamp_end=None):
- assert isinstance(headers, ODictCaseless) or headers is None
+ assert isinstance(headers, odict.ODictCaseless) or headers is None
HTTPMessage.__init__(
self,
httpversion,