

def _receive_push_promise_frame(self, frame):
    '\n        Receive a push-promise frame on the connection.\n        '
    if (not self.local_settings.enable_push):
        raise ProtocolError('Received pushed stream')
    pushed_headers = self.decoder.decode(frame.data, raw=True)
    events = self.state_machine.process_input(ConnectionInputs.RECV_PUSH_PROMISE)
    try:
        stream = self._get_stream_by_id(frame.stream_id)
    except NoSuchStreamError:
        if (frame.stream_id in self._reset_streams):
            f = RstStreamFrame(frame.promised_stream_id)
            f.error_code = REFUSED_STREAM
            return ([f], events)
        raise ProtocolError('Attempted to push on closed stream.')
    if ((frame.stream_id % 2) == 0):
        raise ProtocolError('Cannot recursively push streams.')
    (frames, stream_events) = stream.receive_push_promise_in_band(frame.promised_stream_id, pushed_headers, self.header_encoding)
    new_stream = self._begin_new_stream(frame.promised_stream_id, AllowedStreamIDs.EVEN)
    self.streams[frame.promised_stream_id] = new_stream
    new_stream.remotely_pushed(pushed_headers)
    return (frames, (events + stream_events))

dataset/ETHPy150Open python-hyper/hyper-h2/h2/connection.py H2Connection._receive_push_promise_frame/original