Fix slowdown when sending large data over HTTP/2 (#6873) (#6875)

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

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Orhan Kavrakoğlu 2024-05-25 16:13:17 +02:00 committed by GitHub
parent 552c320fad
commit 8cf0cca702
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -68,12 +68,12 @@ class BufferedH2Connection(h2.connection.H2Connection):
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.