aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/proxy/protocol
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2017-03-06 08:59:35 +1300
committerAldo Cortesi <aldo@nullcube.com>2017-03-06 09:07:16 +1300
commit201c65960eb19b97e6c499f22082aa176bdaa6b1 (patch)
tree362c899cf3f38cf991a542be6aad1380caf2be45 /mitmproxy/proxy/protocol
parent45d18ac8cba462eb4f4f73e3e63ea539b44c6f83 (diff)
downloadmitmproxy-201c65960eb19b97e6c499f22082aa176bdaa6b1.tar.gz
mitmproxy-201c65960eb19b97e6c499f22082aa176bdaa6b1.tar.bz2
mitmproxy-201c65960eb19b97e6c499f22082aa176bdaa6b1.zip
Options unification: sizes
Start dealing with corner cases: - Sizes are always stored in options as strings - Add a new core addon that's responsible for verifying settings that don't belong to an addon - Add a _processed scratch space on the Options object for processed core values to be stored in. This is pretty dirty, but less dirty than re-parsing values every time. We'll come up with something better down the track.
Diffstat (limited to 'mitmproxy/proxy/protocol')
-rw-r--r--mitmproxy/proxy/protocol/http1.py4
-rw-r--r--mitmproxy/proxy/protocol/http2.py2
-rw-r--r--mitmproxy/proxy/protocol/http_replay.py5
3 files changed, 6 insertions, 5 deletions
diff --git a/mitmproxy/proxy/protocol/http1.py b/mitmproxy/proxy/protocol/http1.py
index b1fd0ecd..cafc2682 100644
--- a/mitmproxy/proxy/protocol/http1.py
+++ b/mitmproxy/proxy/protocol/http1.py
@@ -19,7 +19,7 @@ class Http1Layer(httpbase._HttpTransmissionLayer):
return http1.read_body(
self.client_conn.rfile,
expected_size,
- self.config.options.body_size_limit
+ self.config.options._processed.get("body_size_limit")
)
def send_request(self, request):
@@ -35,7 +35,7 @@ class Http1Layer(httpbase._HttpTransmissionLayer):
return http1.read_body(
self.server_conn.rfile,
expected_size,
- self.config.options.body_size_limit
+ self.config.options._processed.get("body_size_limit")
)
def send_response_headers(self, response):
diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py
index 01406798..a6e8a4dd 100644
--- a/mitmproxy/proxy/protocol/http2.py
+++ b/mitmproxy/proxy/protocol/http2.py
@@ -183,7 +183,7 @@ class Http2Layer(base.Layer):
return True
def _handle_data_received(self, eid, event, source_conn):
- bsl = self.config.options.body_size_limit
+ bsl = self.config.options._processed.get("body_size_limit")
if bsl and self.streams[eid].queued_data_length > bsl:
self.streams[eid].kill()
self.connections[source_conn].safe_reset_stream(
diff --git a/mitmproxy/proxy/protocol/http_replay.py b/mitmproxy/proxy/protocol/http_replay.py
index 38f511c4..c47f2e8f 100644
--- a/mitmproxy/proxy/protocol/http_replay.py
+++ b/mitmproxy/proxy/protocol/http_replay.py
@@ -31,6 +31,7 @@ class RequestReplayThread(basethread.BaseThread):
def run(self):
r = self.f.request
+ bsl = self.config.options._processed.get("body_size_limit")
first_line_format_backup = r.first_line_format
server = None
try:
@@ -55,7 +56,7 @@ class RequestReplayThread(basethread.BaseThread):
resp = http1.read_response(
server.rfile,
connect_request,
- body_size_limit=self.config.options.body_size_limit
+ body_size_limit=bsl
)
if resp.status_code != 200:
raise exceptions.ReplayException("Upstream server refuses CONNECT request")
@@ -87,7 +88,7 @@ class RequestReplayThread(basethread.BaseThread):
http1.read_response(
server.rfile,
r,
- body_size_limit=self.config.options.body_size_limit
+ body_size_limit=bsl
)
)
if self.channel: