implement transparent Priority updates

This commit is contained in:
Thomas Kriechbaumer 2016-05-21 20:17:59 +02:00
parent f7ce8e219e
commit 6965c93be6

View File

@ -9,6 +9,7 @@ import six
from h2.connection import H2Connection from h2.connection import H2Connection
from h2.exceptions import StreamClosedError from h2.exceptions import StreamClosedError
from h2 import events from h2 import events
from hyperframe.frame import PriorityFrame
from netlib.tcp import ssl_read_select from netlib.tcp import ssl_read_select
from netlib.exceptions import HttpException from netlib.exceptions import HttpException
@ -185,6 +186,17 @@ class Http2Layer(Layer):
self.streams[event.pushed_stream_id].timestamp_end = time.time() self.streams[event.pushed_stream_id].timestamp_end = time.time()
self.streams[event.pushed_stream_id].request_data_finished.set() self.streams[event.pushed_stream_id].request_data_finished.set()
self.streams[event.pushed_stream_id].start() self.streams[event.pushed_stream_id].start()
elif isinstance(event, events.PriorityUpdated):
stream_id = event.stream_id
if stream_id in self.streams.keys() and self.streams[stream_id].server_stream_id:
stream_id = self.streams[stream_id].server_stream_id
depends_on = event.depends_on
if depends_on in self.streams.keys() and self.streams[depends_on].server_stream_id:
depends_on = self.streams[depends_on].server_stream_id
frame = PriorityFrame(stream_id, depends_on, event.weight, event.exclusive)
self.server_conn.send(frame.serialize())
elif isinstance(event, events.TrailersReceived): elif isinstance(event, events.TrailersReceived):
raise NotImplementedError() raise NotImplementedError()