aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-02-08 19:41:11 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-02-08 19:41:11 +0100
commitbee12019183c461497e8e8f05ccfd9460353a0cb (patch)
tree59f56cc6851d8cb2099caf30b3d4e8d159947f75 /libmproxy/protocol
parentec087a1960bdcfff5d8207a8090f35223b02fd49 (diff)
downloadmitmproxy-bee12019183c461497e8e8f05ccfd9460353a0cb.tar.gz
mitmproxy-bee12019183c461497e8e8f05ccfd9460353a0cb.tar.bz2
mitmproxy-bee12019183c461497e8e8f05ccfd9460353a0cb.zip
fix #920
This might be implemented by hyper-h2 in the future.
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r--libmproxy/protocol/http2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/libmproxy/protocol/http2.py b/libmproxy/protocol/http2.py
index 8ccc209a..7bf06d31 100644
--- a/libmproxy/protocol/http2.py
+++ b/libmproxy/protocol/http2.py
@@ -9,6 +9,7 @@ from netlib.exceptions import HttpException
from netlib.http import Headers
from netlib.utils import http2_read_raw_frame
+import hyperframe
import h2
from h2.connection import H2Connection
from h2.events import *
@@ -97,6 +98,8 @@ class Http2Layer(Layer):
super(Http2Layer, self).__init__(ctx)
self.mode = mode
self.streams = dict()
+ self.client_reset_streams = []
+ self.server_reset_streams = []
self.server_to_client_stream_ids = dict([(0, 0)])
self.client_conn.h2 = SafeH2Connection(self.client_conn, client_side=False)
@@ -156,6 +159,8 @@ class Http2Layer(Layer):
self.streams[eid].data_finished.set()
elif isinstance(event, StreamReset):
self.streams[eid].zombie = time.time()
+ self.client_reset_streams.append(self.streams[eid].client_stream_id)
+ self.server_reset_streams.append(self.streams[eid].server_stream_id) if self.streams[eid].server_stream_id
if eid in self.streams and event.error_code == 0x8:
if is_server:
other_stream_id = self.streams[eid].client_stream_id
@@ -222,6 +227,20 @@ class Http2Layer(Layer):
stream.zombie = time.time()
return
+
+ frame, _ = hyperframe.frame.Frame.parse_frame_header(raw_frame[:9])
+
+ if is_server:
+ list = self.server_reset_streams
+ else:
+ list = self.client_reset_streams
+ if frame.stream_id in list:
+ # this frame belongs to a reset stream - just ignore it
+ if isinstance(frame, hyperframe.frame.HeadersFrame) or isinstance(frame, hyperframe.frame.ContinuationFrame):
+ # we need to keep the hpack-decoder happy too
+ source_conn.h2.decoder.decode(raw_frame[9:])
+ continue
+
events = source_conn.h2.receive_data(raw_frame)
source_conn.send(source_conn.h2.data_to_send())