mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 09:37:37 +00:00
upgrade h2 to >=2.5.0
This commit is contained in:
parent
33bc526b70
commit
44ac370f08
@ -25,16 +25,12 @@ class SafeH2Connection(connection.H2Connection):
|
||||
self.conn = conn
|
||||
self.lock = threading.RLock()
|
||||
|
||||
def safe_increment_flow_control(self, stream_id, length):
|
||||
if length == 0:
|
||||
def safe_acknowledge_received_data(self, acknowledged_size, stream_id):
|
||||
if acknowledged_size == 0:
|
||||
return
|
||||
|
||||
with self.lock:
|
||||
self.increment_flow_control_window(length)
|
||||
self.conn.send(self.data_to_send())
|
||||
with self.lock:
|
||||
if stream_id in self.streams and not self.streams[stream_id].closed:
|
||||
self.increment_flow_control_window(length, stream_id=stream_id)
|
||||
self.acknowledge_received_data(acknowledged_size, stream_id)
|
||||
self.conn.send(self.data_to_send())
|
||||
|
||||
def safe_reset_stream(self, stream_id, error_code):
|
||||
@ -90,11 +86,23 @@ class Http2Layer(base.Layer):
|
||||
self.mode = mode
|
||||
self.streams = dict()
|
||||
self.server_to_client_stream_ids = dict([(0, 0)])
|
||||
self.client_conn.h2 = SafeH2Connection(self.client_conn, client_side=False, header_encoding=False)
|
||||
config = h2.config.H2Configuration(
|
||||
client_side=False,
|
||||
header_encoding=False,
|
||||
validate_outbound_headers=False,
|
||||
normalize_outbound_headers=False,
|
||||
validate_inbound_headers=False)
|
||||
self.client_conn.h2 = SafeH2Connection(self.client_conn, config=config)
|
||||
|
||||
def _initiate_server_conn(self):
|
||||
if self.server_conn:
|
||||
self.server_conn.h2 = SafeH2Connection(self.server_conn, client_side=True, header_encoding=False)
|
||||
config = h2.config.H2Configuration(
|
||||
client_side=True,
|
||||
header_encoding=False,
|
||||
validate_outbound_headers=False,
|
||||
normalize_outbound_headers=False,
|
||||
validate_inbound_headers=False)
|
||||
self.server_conn.h2 = SafeH2Connection(self.server_conn, config=config)
|
||||
self.server_conn.h2.initiate_connection()
|
||||
self.server_conn.send(self.server_conn.h2.data_to_send())
|
||||
|
||||
@ -181,9 +189,9 @@ class Http2Layer(base.Layer):
|
||||
else:
|
||||
self.streams[eid].data_queue.put(event.data)
|
||||
self.streams[eid].queued_data_length += len(event.data)
|
||||
source_conn.h2.safe_increment_flow_control(
|
||||
event.stream_id,
|
||||
event.flow_controlled_length
|
||||
source_conn.h2.safe_acknowledge_received_data(
|
||||
event.flow_controlled_length,
|
||||
event.stream_id
|
||||
)
|
||||
return True
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -67,7 +67,7 @@ setup(
|
||||
"cryptography>=1.3, <1.6",
|
||||
"cssutils>=1.0.1, <1.1",
|
||||
"Flask>=0.10.1, <0.12",
|
||||
"h2>=2.4.1, <3",
|
||||
"h2>=2.5.0, <3",
|
||||
"html2text>=2016.1.8, <=2016.9.19",
|
||||
"hyperframe>=4.0.1, <5",
|
||||
"jsbeautifier>=1.6.3, <1.7",
|
||||
|
@ -298,9 +298,9 @@ class TestRequestWithPriority(_Http2Test):
|
||||
|
||||
headers = [(':status', '200')]
|
||||
if event.priority_updated:
|
||||
headers.append(('priority_exclusive', event.priority_updated.exclusive))
|
||||
headers.append(('priority_depends_on', event.priority_updated.depends_on))
|
||||
headers.append(('priority_weight', event.priority_updated.weight))
|
||||
headers.append(('priority_exclusive', str(event.priority_updated.exclusive).encode()))
|
||||
headers.append(('priority_depends_on', str(event.priority_updated.depends_on).encode()))
|
||||
headers.append(('priority_weight', str(event.priority_updated.weight).encode()))
|
||||
h2_conn.send_headers(event.stream_id, headers)
|
||||
h2_conn.end_stream(event.stream_id)
|
||||
wfile.write(h2_conn.data_to_send())
|
||||
|
Loading…
Reference in New Issue
Block a user