mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
http2: use callback for handle unexpected frames
This commit is contained in:
parent
721bd1c136
commit
4339b8e7fa
@ -68,8 +68,8 @@ class Http2Layer(Layer):
|
||||
def __init__(self, ctx, mode):
|
||||
super(Http2Layer, self).__init__(ctx)
|
||||
self.mode = mode
|
||||
self.client_protocol = HTTP2Protocol(self.client_conn, is_server=True)
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False)
|
||||
self.client_protocol = HTTP2Protocol(self.client_conn, is_server=True, unhandled_frame_cb=self.handle_unexpected_frame)
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False, unhandled_frame_cb=self.handle_unexpected_frame)
|
||||
|
||||
def read_from_client(self):
|
||||
return HTTPRequest.from_protocol(
|
||||
@ -95,17 +95,17 @@ class Http2Layer(Layer):
|
||||
|
||||
def connect(self):
|
||||
self.ctx.connect()
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False)
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False, unhandled_frame_cb=self.handle_unexpected_frame)
|
||||
self.server_protocol.perform_connection_preface()
|
||||
|
||||
def reconnect(self):
|
||||
self.ctx.reconnect()
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False)
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False, unhandled_frame_cb=self.handle_unexpected_frame)
|
||||
self.server_protocol.perform_connection_preface()
|
||||
|
||||
def set_server(self, *args, **kwargs):
|
||||
self.ctx.set_server(*args, **kwargs)
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False)
|
||||
self.server_protocol = HTTP2Protocol(self.server_conn, is_server=False, unhandled_frame_cb=self.handle_unexpected_frame)
|
||||
self.server_protocol.perform_connection_preface()
|
||||
|
||||
def __call__(self):
|
||||
@ -113,6 +113,9 @@ class Http2Layer(Layer):
|
||||
layer = HttpLayer(self, self.mode)
|
||||
layer()
|
||||
|
||||
def handle_unexpected_frame(self, frm):
|
||||
print(frm.human_readable())
|
||||
|
||||
|
||||
def make_error_response(status_code, message, headers=None):
|
||||
response = status_codes.RESPONSES.get(status_code, "Unknown")
|
||||
|
Loading…
Reference in New Issue
Block a user