private void HandlePriority(PriorityFrame priorityFrame, out Http2Stream stream)
        {
            //09 -> 6.3.  PRIORITY
            //The PRIORITY frame is associated with an existing stream.  If a
            //PRIORITY frame is received with a stream identifier of 0x0, the
            //recipient MUST respond with a connection error (Section 5.4.1) of
            //type PROTOCOL_ERROR [PROTOCOL_ERROR].
            if (priorityFrame.StreamId == 0)
            {
                throw new ProtocolError(ResetStatusCode.ProtocolError, "Incoming priority frame with id = 0");
            }

            Http2Logger.LogDebug("Priority frame. StreamId: {0} Priority: {1}", priorityFrame.StreamId,
                                 priorityFrame.Priority);

            stream = GetStream(priorityFrame.StreamId);

            if (!_usePriorities)
                return;

            //09 -> 5.1.  Stream States
            //A receiver can ignore WINDOW_UPDATE [WINDOW_UPDATE] or PRIORITY
            //[PRIORITY] frames in this state.
            if (stream != null && !stream.EndStreamReceived)
            {
                stream.Priority = priorityFrame.Priority;
            }
            //09 -> 5.1.  Stream States
            //WINDOW_UPDATE, PRIORITY, or RST_STREAM frames can be received in
            //this state for a short period after a DATA or HEADERS frame
            //containing an END_STREAM flag is sent.  Until the remote peer
            //receives and processes the frame bearing the END_STREAM flag, it
            //might send frame of any of these types.  Endpoints MUST ignore
            //WINDOW_UPDATE, PRIORITY, or RST_STREAM frames received in this
            //state, though endpoints MAY choose to treat frames that arrive a
            //significant time after sending END_STREAM as a connection error
            //(Section 5.4.1) of type PROTOCOL_ERROR.
        }
        private void HandlePriority(PriorityFrame priorityFrame, out Http2Stream stream)
        {
            //spec 06:
            //The PRIORITY frame is associated with an existing stream.  If a
            //PRIORITY frame is received with a stream identifier of 0x0, the
            //recipient MUST respond with a connection error (Section 5.4.1) of
            //type PROTOCOL_ERROR [PROTOCOL_ERROR].
            if (priorityFrame.StreamId == 0)
            {
                throw new ProtocolError(ResetStatusCode.ProtocolError, "Incoming priority frame with id = 0");
            }

            Http2Logger.LogDebug("Priority frame. StreamId: {0} Priority: {1}", priorityFrame.StreamId,
                                 priorityFrame.Priority);

            stream = GetStream(priorityFrame.StreamId);

            if (!_usePriorities)
                return;

            //06
            //A receiver can ignore WINDOW_UPDATE [WINDOW_UPDATE] or PRIORITY
            //[PRIORITY] frames in this state.
            if (stream != null && !stream.EndStreamReceived)
            {
                stream.Priority = priorityFrame.Priority;
            }
            //Do not signal an error because (06)
            //WINDOW_UPDATE [WINDOW_UPDATE], PRIORITY [PRIORITY], or RST_STREAM
            //[RST_STREAM] frames can be received in this state for a short
            //period after a frame containing an END_STREAM flag is sent.
        }
        private void HandlePriority(PriorityFrame priorityFrame, out Http2Stream stream)
        {
            Http2Logger.LogDebug("PRIORITY frame: stream id={0}, exclusive={1}, dependency={2}, weight={3}",
                priorityFrame.StreamId, priorityFrame.Exclusive, priorityFrame.StreamDependency,
                priorityFrame.Weight);

            /* 12 -> 6.3
            The PRIORITY frame is associated with an existing stream. If a
            PRIORITY frame is received with a stream identifier of 0x0, the
            recipient MUST respond with a connection error of type PROTOCOL_ERROR. */
            if (priorityFrame.StreamId == 0)
                throw new ProtocolError(ResetStatusCode.ProtocolError, "Incoming priority frame with stream id=0");
           
            stream = GetStream(priorityFrame.StreamId);

            /* 12 -> 6.3
            The PRIORITY frame can be sent on a stream in any of the "reserved
            (remote)", "open", "half-closed (local)", or "half closed (remote)"
            states, though it cannot be sent between consecutive frames that
            comprise a single header block. */

            if (stream.Closed)
                throw new Http2StreamNotFoundException(priorityFrame.StreamId);

            if (!(stream.Opened || stream.ReservedRemote || stream.HalfClosedLocal))
                throw new ProtocolError(ResetStatusCode.ProtocolError, "priority for non opened or reserved stream");

            if (!_usePriorities) 
                return;

            stream.Priority = priorityFrame.Weight;
        }