This commit is contained in:
Thomas Kriechbaumer 2017-03-24 19:24:28 +01:00
parent 335861f490
commit ef9f0e22ea
3 changed files with 16 additions and 8 deletions

View File

@ -188,7 +188,7 @@ class Http2Layer(base.Layer):
self.streams[eid].kill()
self.connections[source_conn].safe_reset_stream(
event.stream_id,
h2.errors.REFUSED_STREAM
h2.errors.ErrorCodes.REFUSED_STREAM
)
self.log("HTTP body too large. Limit is {}.".format(bsl), "info")
else:
@ -207,7 +207,7 @@ class Http2Layer(base.Layer):
def _handle_stream_reset(self, eid, event, is_server, other_conn):
self.streams[eid].kill()
if eid in self.streams and event.error_code == h2.errors.CANCEL:
if eid in self.streams and event.error_code == h2.errors.ErrorCodes.CANCEL:
if is_server:
other_stream_id = self.streams[eid].client_stream_id
else:
@ -228,7 +228,7 @@ class Http2Layer(base.Layer):
event.last_stream_id,
event.additional_data), "info")
if event.error_code != h2.errors.NO_ERROR:
if event.error_code != h2.errors.ErrorCodes.NO_ERROR:
# Something terrible has happened - kill everything!
self.connections[self.client_conn].close_connection(
error_code=event.error_code,

View File

@ -66,9 +66,9 @@ setup(
"construct>=2.8, <2.9",
"cryptography>=1.3, <1.9",
"cssutils>=1.0.1, <1.1",
"h2>=2.6.1, <3",
"h2>=3.0, <4",
"html2text>=2016.1.8, <=2016.9.19",
"hyperframe>=4.0.2, <6",
"hyperframe>=5.0, <6",
"jsbeautifier>=1.6.3, <1.7",
"kaitaistruct>=0.6, <0.7",
"passlib>=1.6.5, <1.8",

View File

@ -36,7 +36,11 @@ class _Http2ServerBase(net_tservers.ServerTestBase):
class handler(mitmproxy.net.tcp.BaseHandler):
def handle(self):
h2_conn = h2.connection.H2Connection(client_side=False, header_encoding=False)
config = h2.config.H2Configuration(
client_side=False,
validate_outbound_headers=False,
validate_inbound_headers=False)
h2_conn = h2.connection.H2Connection(config)
preamble = self.rfile.read(24)
h2_conn.initiate_connection()
@ -138,7 +142,11 @@ class _Http2TestBase:
client.convert_to_ssl(alpn_protos=[b'h2'])
h2_conn = h2.connection.H2Connection(client_side=True, header_encoding=False)
config = h2.config.H2Configuration(
client_side=True,
validate_outbound_headers=False,
validate_inbound_headers=False)
h2_conn = h2.connection.H2Connection(config)
h2_conn.initiate_connection()
client.wfile.write(h2_conn.data_to_send())
client.wfile.flush()
@ -756,7 +764,7 @@ class TestMaxConcurrentStreams(_Http2Test):
@classmethod
def setup_class(cls):
_Http2TestBase.setup_class()
_Http2ServerBase.setup_class(h2_server_settings={h2.settings.MAX_CONCURRENT_STREAMS: 2})
_Http2ServerBase.setup_class(h2_server_settings={h2.settings.SettingCodes.MAX_CONCURRENT_STREAMS: 2})
@classmethod
def handle_server_event(cls, event, h2_conn, rfile, wfile):