mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
reuse frame reading snippet
This commit is contained in:
parent
4de9cbb61e
commit
a99ef584ad
@ -206,12 +206,8 @@ class Http2Layer(Layer):
|
||||
other_conn = self.server_conn if conn == self.client_conn.connection else self.client_conn
|
||||
is_server = (conn == self.server_conn.connection)
|
||||
|
||||
field = source_conn.rfile.peek(3)
|
||||
length = int(field.encode('hex'), 16)
|
||||
raw_frame = source_conn.rfile.safe_read(9 + length)
|
||||
|
||||
with source_conn.h2.lock:
|
||||
events = source_conn.h2.receive_data(raw_frame)
|
||||
events = source_conn.h2.receive_data(utils.http2_read_frame(source_conn.rfile))
|
||||
source_conn.send(source_conn.h2.data_to_send())
|
||||
|
||||
for event in events:
|
||||
|
@ -173,3 +173,9 @@ def safe_subn(pattern, repl, target, *args, **kwargs):
|
||||
need a better solution that is aware of the actual content ecoding.
|
||||
"""
|
||||
return re.subn(str(pattern), str(repl), target, *args, **kwargs)
|
||||
|
||||
def http2_read_frame(rfile):
|
||||
field = rfile.peek(3)
|
||||
length = int(field.encode('hex'), 16)
|
||||
raw_frame = rfile.safe_read(9 + length)
|
||||
return raw_frame
|
||||
|
Loading…
Reference in New Issue
Block a user