Example #1
0
        public static byte[] PackHeaders(NameValueCollection headers, uint maxHeaderTableSize)
        {
            byte[] headerData = new byte[0];

            // Header Block Fragments
            var hpackEncoder = new HPack.Encoder((int)maxHeaderTableSize);

            using (var ms = new MemoryStream()) {
                using (var bw = new BinaryWriter(ms)) {
                    foreach (var key in headers.AllKeys)
                    {
                        var values = headers.GetValues(key);

                        foreach (var value in values)
                        {
                            hpackEncoder.EncodeHeader(bw, key, value, false);
                        }
                    }
                }

                headerData = ms.ToArray();
            }

            return(headerData);
        }
Example #2
0
        public ConnectionWriter(
            Connection connection, IWriteAndCloseableByteStream outStream,
            Options options, HPack.Encoder.Options hpackOptions)
        {
            this.Connection            = connection;
            this.outStream             = outStream;
            this.DynamicTableSizeLimit = options.DynamicTableSizeLimit;
            this.MaxFrameSize          = options.MaxFrameSize;
            this.MaxHeaderListSize     = options.MaxHeaderListSize;
            this.hEncoder = new HPack.Encoder(hpackOptions);

            shared.Mutex             = new object();
            shared.CloseRequested    = false;
            shared.InitialWindowSize = options.InitialWindowSize;
            shared.WriteQueue        = new Queue <WriteRequest>();
            shared.Streams           = new List <StreamData>();

            this.writeTask = Task.Run(() => this.RunAsync());
        }
Example #3
0
        public static byte[] PackHeaders (NameValueCollection headers, uint maxHeaderTableSize)
        {
            byte[] headerData = new byte[0];

            // Header Block Fragments
            var hpackEncoder = new HPack.Encoder ((int)maxHeaderTableSize);

            using (var ms = new MemoryStream ()) {
                using (var bw = new BinaryWriter (ms)) {

                    foreach (var key in headers.AllKeys) {
                        var values = headers.GetValues (key);

                        foreach (var value in values)
                            hpackEncoder.EncodeHeader (bw, key, value, false);
                    }
                }

                headerData = ms.ToArray ();
            }

            return headerData;
        }