示例#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);
        }
示例#2
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;
        }