// TODO: In the next draft there will only be one or two overloads for this.
        public void WriteHeaders(IList<KeyValuePair<string, string>> headers, int streamId, Priority priority, bool isFin, CancellationToken cancel)
        {
            cancel.ThrowIfCancellationRequested();
            // Lock because the compression context is shared across the whole connection.
            // We need to make sure requests are compressed and enqueued atomically.
            // TODO: Prioritization re-ordering will also break decompression. Scrap the priority queue.
            lock (_compressionLock)
            {
                byte[] headerBytes = FrameHelpers.SerializeHeaderBlock(headers);
                headerBytes = _compressor.Compress(headerBytes);
                HeadersFrame frame = new HeadersFrame(streamId, headerBytes);
                frame.IsFin = isFin;

                _writeQueue.WriteFrameAsync(frame, priority);
            }
        }
Ejemplo n.º 2
0
        public void WriteHeadersFrame(HeadersList headers, bool isEndStream, bool isEndHeaders)
        {
            Headers.AddRange(headers);

            byte[] headerBytes = _compressionProc.Compress(headers);

            var frame = new HeadersFrame(_id, headerBytes, Priority)
                {
                    IsEndHeaders = isEndHeaders,
                    IsEndStream = isEndStream,
                };

            _writeQueue.WriteFrame(frame);

            if (frame.IsEndStream)
            {
                EndStreamSent = true;
            }

            if (OnFrameSent != null)
            {
                OnFrameSent(this, new FrameSentArgs(frame));
            }
        }
        public void ReceiveExtraHeaders(HeadersFrame headerFrame, IList<KeyValuePair<string, string>> headers)
        {
            if (Disposed)
            {
                return;
            }

            // TODO: Where do we put them? How do we notify the stream owner that they're here?

            if (headerFrame.IsFin)
            {
                FinReceived = true;
                _incomingStream.Dispose();
            }
        }