aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-01-14 19:05:37 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-02-04 09:52:01 +0100
commit9e619742887f686aec1059283316ed389443cdf3 (patch)
tree6739e8858afcd077cd43ebe942e57419a531dd1e /libmproxy
parentb44c3ac6e0f54413a067294bbcb0fe019fade3f3 (diff)
downloadmitmproxy-9e619742887f686aec1059283316ed389443cdf3.tar.gz
mitmproxy-9e619742887f686aec1059283316ed389443cdf3.tar.bz2
mitmproxy-9e619742887f686aec1059283316ed389443cdf3.zip
improve flow control
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/protocol/http.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 8315aed0..7ea5f57d 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -141,6 +141,9 @@ class SafeH2Connection(H2Connection):
self.conn.send(self.data_to_send())
def safe_increment_flow_control(self, stream_id, length):
+ if length == 0:
+ return
+
with self.lock:
self.increment_flow_control_window(length)
self.conn.send(self.data_to_send())
@@ -152,7 +155,7 @@ class SafeH2Connection(H2Connection):
def safe_reset_stream(self, stream_id, error_code):
with self.lock:
self.reset_stream(stream_id, error_code)
- self.conn.send(self.h2.data_to_send())
+ self.conn.send(self.data_to_send())
def safe_acknowledge_settings(self, event):
with self.conn.h2.lock:
@@ -174,9 +177,17 @@ class SafeH2Connection(H2Connection):
max_outbound_frame_size = self.max_outbound_frame_size
for i in xrange(0, len(chunk), max_outbound_frame_size):
frame_chunk = chunk[i:i+max_outbound_frame_size]
- with self.lock:
- self.send_data(stream_id, frame_chunk)
- self.conn.send(self.data_to_send())
+
+ self.lock.acquire()
+ while True:
+ if self.local_flow_control_window(stream_id) < len(frame_chunk):
+ self.lock.release()
+ time.sleep(0)
+ else:
+ break
+ self.send_data(stream_id, frame_chunk)
+ self.conn.send(self.data_to_send())
+ self.lock.release()
with self.lock:
self.end_stream(stream_id)
self.conn.send(self.data_to_send())