fix lint error

This commit is contained in:
sanlengjingvv 2021-03-14 18:42:29 +08:00
parent 76d7ee3a2f
commit a3fd70f240
4 changed files with 6 additions and 4 deletions

View File

@ -302,6 +302,7 @@ class HttpStream(layer.Layer):
if isinstance(event, ResponseData):
self.response_body_buf += event.data
elif isinstance(event, ResponseTrailers):
assert self.flow.response
self.flow.response.trailers = event.trailers
yield HttpResponseTrailersHook(self.flow)
elif isinstance(event, ResponseEndOfMessage):

View File

@ -44,6 +44,7 @@ class HttpResponseHook(commands.StartHook):
name = "response"
flow: http.HTTPFlow
@dataclass
class HttpResponseTrailersHook(commands.StartHook):
"""
@ -52,6 +53,7 @@ class HttpResponseTrailersHook(commands.StartHook):
name = "responsetrailers"
flow: http.HTTPFlow
@dataclass
class HttpErrorHook(commands.StartHook):
"""

View File

@ -99,10 +99,7 @@ class Http2Connection(HttpConnection):
self.h2_conn.send_data(event.stream_id, event.data)
elif isinstance(event, ResponseTrailers):
if self.is_open_for_us(event.stream_id):
trailers = [
*event.trailers.fields
]
r = event.trailers.fields
trailers = [*event.trailers.fields]
self.h2_conn.send_headers(event.stream_id, trailers, event.end_stream)
elif isinstance(event, self.SendEndOfMessage):
if self.is_open_for_us(event.stream_id):
@ -458,6 +455,7 @@ class Http2Client(Http2Connection):
elif isinstance(event, h2.events.TrailersReceived):
pseudo_trailers, trailers = split_pseudo_headers(event.headers)
yield ReceiveHttp(ResponseTrailers(event.stream_id, trailers, bool(event.stream_ended)))
return False
elif isinstance(event, h2.events.RequestReceived):
yield from self.protocol_error(f"HTTP/2 protocol error: received request from server")
return True

View File

@ -35,6 +35,7 @@ example_response_trailers = (
(b'my-trailer-b', b'0')
)
def decode_frames(data: bytes) -> List[hyperframe.frame.Frame]:
# swallow preamble
if data.startswith(b"PRI * HTTP/2.0"):