Skip to content

Commit

Permalink
Fix slowdown when sending large data over HTTP/2 (mitmproxy#6873) (mi…
Browse files Browse the repository at this point in the history
…tmproxy#6875)

* Do not mutate data when splitting into chunks (mitmproxy#6873)

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
aib and autofix-ci[bot] authored May 25, 2024
1 parent 552c320 commit 8cf0cca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
([#6821](https://github.com/mitmproxy/mitmproxy/pull/6821), @Prinzhorn)
* Fix a bug where client replay would not work with proxyauth.
([#6866](https://github.com/mitmproxy/mitmproxy/pull/6866), @mhils)
* Fix slowdown when sending large data over HTTP/2
([#6875](https://github.com/mitmproxy/mitmproxy/pull/6875), @aib)


## 17 April 2024: mitmproxy 10.3.0
Expand Down
10 changes: 5 additions & 5 deletions mitmproxy/proxy/layers/http/_http_h2.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def send_data(
frame_size = len(data)
assert pad_length is None

while frame_size > self.max_outbound_frame_size:
chunk_data = data[: self.max_outbound_frame_size]
self.send_data(stream_id, chunk_data, end_stream=False)
if frame_size > self.max_outbound_frame_size:
for start in range(0, frame_size, self.max_outbound_frame_size):
chunk = data[start : start + self.max_outbound_frame_size]
self.send_data(stream_id, chunk, end_stream=False)

data = data[self.max_outbound_frame_size :]
frame_size -= len(chunk_data)
return

if self.stream_buffers.get(stream_id, None):
# We already have some data buffered, let's append.
Expand Down

0 comments on commit 8cf0cca

Please sign in to comment.