aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-11-09 10:04:51 +0100
committerMaximilian Hils <git@maximilianhils.com>2016-11-09 10:04:51 +0100
commitd9597add768ac2e3463381183cdf53cffac904a0 (patch)
tree2f2ea0bbd497d6b31bd218cf8c4c672ac3528125
parentc2a130dcedcb69c35d8bb7432fa65e6542e6de19 (diff)
downloadmitmproxy-d9597add768ac2e3463381183cdf53cffac904a0.tar.gz
mitmproxy-d9597add768ac2e3463381183cdf53cffac904a0.tar.bz2
mitmproxy-d9597add768ac2e3463381183cdf53cffac904a0.zip
web: fix header update
-rw-r--r--mitmproxy/tools/web/app.py53
1 files changed, 27 insertions, 26 deletions
diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py
index e5f74af3..d04af430 100644
--- a/mitmproxy/tools/web/app.py
+++ b/mitmproxy/tools/web/app.py
@@ -1,19 +1,17 @@
import base64
+import hashlib
import json
import logging
import os.path
import re
-import hashlib
-
-
-import tornado.websocket
-import tornado.web
from io import BytesIO
-from mitmproxy import flowfilter
+import tornado.web
+import tornado.websocket
+from mitmproxy import contentviews
from mitmproxy import flow
+from mitmproxy import flowfilter
from mitmproxy import http
-from mitmproxy import contentviews
from mitmproxy import io
from mitmproxy import version
@@ -192,6 +190,7 @@ class Flows(RequestHandler):
def get(self):
self.write([convert_flow_to_json_dict(f) for f in self.view])
+
class DumpFlows(RequestHandler):
def get(self):
self.set_header("Content-Disposition", "attachment; filename=flows")
@@ -251,7 +250,9 @@ class FlowHandler(RequestHandler):
elif k == "port":
request.port = int(v)
elif k == "headers":
- request.headers.set_state((a.encode(), b.encode()) for a, b in v)
+ request.headers.clear()
+ for header in v:
+ request.headers.add(*header)
elif k == "content":
request.text = v
else:
@@ -267,7 +268,9 @@ class FlowHandler(RequestHandler):
elif k == "http_version":
response.http_version = str(v)
elif k == "headers":
- response.headers.set_state(v)
+ response.headers.clear()
+ for header in v:
+ response.headers.add(*header)
elif k == "content":
response.text = v
else:
@@ -358,29 +361,27 @@ class FlowContentView(RequestHandler):
class Events(RequestHandler):
def get(self):
- self.write([]) # FIXME
+ self.write([]) # FIXME
class Settings(RequestHandler):
def get(self):
-
self.write(dict(
- version=version.VERSION,
- mode=str(self.master.options.mode),
- intercept=self.master.options.intercept,
- showhost=self.master.options.showhost,
- no_upstream_cert=self.master.options.no_upstream_cert,
- rawtcp=self.master.options.rawtcp,
- http2=self.master.options.http2,
- anticache=self.master.options.anticache,
- anticomp=self.master.options.anticomp,
- stickyauth=self.master.options.stickyauth,
- stickycookie=self.master.options.stickycookie,
- stream=self.master.options.stream_large_bodies,
- contentViews=[v.name.replace(' ', '_') for v in contentviews.views]
- )
- )
+ version=version.VERSION,
+ mode=str(self.master.options.mode),
+ intercept=self.master.options.intercept,
+ showhost=self.master.options.showhost,
+ no_upstream_cert=self.master.options.no_upstream_cert,
+ rawtcp=self.master.options.rawtcp,
+ http2=self.master.options.http2,
+ anticache=self.master.options.anticache,
+ anticomp=self.master.options.anticomp,
+ stickyauth=self.master.options.stickyauth,
+ stickycookie=self.master.options.stickycookie,
+ stream=self.master.options.stream_large_bodies,
+ contentViews=[v.name.replace(' ', '_') for v in contentviews.views]
+ ))
def put(self):
update = {}