web: fix header update

This commit is contained in:
Maximilian Hils 2016-11-09 10:04:51 +01:00
parent c2a130dced
commit d9597add76
1 changed files with 28 additions and 27 deletions

View File

@ -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
from mitmproxy import flow
from mitmproxy import http
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 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 = {}