aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2018-02-24 15:49:38 +1300
committerAldo Cortesi <aldo@nullcube.com>2018-02-24 15:49:38 +1300
commit2aa7ac584b7884b8fd7622aec86b47d1e33a4a11 (patch)
tree380a5f8a603ed1571f7ca554b93931775d47b0a4 /mitmproxy
parent704c1db1b7aa25c4ee6371bec811e92409b92398 (diff)
downloadmitmproxy-2aa7ac584b7884b8fd7622aec86b47d1e33a4a11.tar.gz
mitmproxy-2aa7ac584b7884b8fd7622aec86b47d1e33a4a11.tar.bz2
mitmproxy-2aa7ac584b7884b8fd7622aec86b47d1e33a4a11.zip
addon options: stickycookie, streambodies
Diffstat (limited to 'mitmproxy')
-rw-r--r--mitmproxy/addons/stickycookie.py6
-rw-r--r--mitmproxy/addons/streambodies.py19
-rw-r--r--mitmproxy/options.py23
3 files changed, 25 insertions, 23 deletions
diff --git a/mitmproxy/addons/stickycookie.py b/mitmproxy/addons/stickycookie.py
index e58e0a58..e5f85fa1 100644
--- a/mitmproxy/addons/stickycookie.py
+++ b/mitmproxy/addons/stickycookie.py
@@ -34,6 +34,12 @@ class StickyCookie:
self.jar = collections.defaultdict(dict) # type: Dict[TOrigin, Dict[str, str]]
self.flt = None # type: Optional[flowfilter.TFilter]
+ def load(self, loader):
+ loader.add_option(
+ "stickycookie", Optional[str], None,
+ "Set sticky cookie filter. Matched against requests."
+ )
+
def configure(self, updated):
if "stickycookie" in updated:
if ctx.options.stickycookie:
diff --git a/mitmproxy/addons/streambodies.py b/mitmproxy/addons/streambodies.py
index c841075f..6ca9918f 100644
--- a/mitmproxy/addons/streambodies.py
+++ b/mitmproxy/addons/streambodies.py
@@ -1,3 +1,5 @@
+import typing
+
from mitmproxy.net.http import http1
from mitmproxy import exceptions
from mitmproxy import ctx
@@ -8,6 +10,23 @@ class StreamBodies:
def __init__(self):
self.max_size = None
+ def load(self, loader):
+ loader.add_option(
+ "stream_large_bodies", typing.Optional[str], None,
+ """
+ Stream data to the client if response body exceeds the given
+ threshold. If streamed, the body will not be stored in any way.
+ Understands k/m/g suffixes, i.e. 3m for 3 megabytes.
+ """
+ )
+ loader.add_option(
+ "stream_websockets", bool, False,
+ """
+ Stream WebSocket messages between client and server.
+ Messages are captured and cannot be modified.
+ """
+ )
+
def configure(self, updated):
if "stream_large_bodies" in updated and ctx.options.stream_large_bodies:
try:
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index bf2012d7..ed17489a 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -67,10 +67,6 @@ class Options(optmanager.OptManager):
view_filter = None # type: Optional[str]
# FIXME: Options that should be uncomplicated to migrate to addons
- stickyauth = None # type: Optional[str]
- stickycookie = None # type: Optional[str]
- stream_large_bodies = None # type: Optional[str]
- stream_websockets = None # type: bool
upstream_auth = None # type: Optional[str]
view_order = None # type: str
view_order_reversed = None # type: bool
@@ -90,25 +86,6 @@ class Options(optmanager.OptManager):
"Use the Host header to construct URLs for display."
)
self.add_option(
- "stickycookie", Optional[str], None,
- "Set sticky cookie filter. Matched against requests."
- )
- self.add_option(
- "stream_large_bodies", Optional[str], None,
- """
- Stream data to the client if response body exceeds the given
- threshold. If streamed, the body will not be stored in any way.
- Understands k/m/g suffixes, i.e. 3m for 3 megabytes.
- """
- )
- self.add_option(
- "stream_websockets", bool, False,
- """
- Stream WebSocket messages between client and server.
- Messages are captured and cannot be modified.
- """
- )
- self.add_option(
"verbosity", str, 'info',
"Log verbosity.",
choices=log_verbosity