public void TestSetMaxHeaderTableSizeToMaxValue() { var buf = Unpooled.Buffer(); hpackEncoder.SetMaxHeaderTableSize(buf, Http2CodecUtil.MaxHeaderTableSize); hpackDecoder.SetMaxHeaderTableSize(Http2CodecUtil.MaxHeaderTableSize); // TODO sometimes throw OutOfMemoryException hpackDecoder.Decode(0, buf, mockHeaders.Object, true); Assert.Equal(Http2CodecUtil.MaxHeaderTableSize, hpackDecoder.GetMaxHeaderTableSize()); buf.Release(); }
internal static HpackEncoder NewTestEncoder(bool ignoreMaxHeaderListSize, long maxHeaderListSize, long maxHeaderTableSize) { HpackEncoder hpackEncoder = new HpackEncoder(false, 16, 0); var buf = Unpooled.Buffer(); try { hpackEncoder.SetMaxHeaderTableSize(buf, maxHeaderTableSize); hpackEncoder.SetMaxHeaderListSize(maxHeaderListSize); } finally { buf.Release(); } return(hpackEncoder); }
private static byte[] Encode(HpackEncoder hpackEncoder, List <HpackHeaderField> headers, int maxHeaderTableSize, bool sensitive) { IHttp2Headers http2Headers = ToHttp2Headers(headers); ISensitivityDetector sensitivityDetector = sensitive ? AlwaysSensitiveDetector.Instance : NeverSensitiveDetector.Instance; var buffer = Unpooled.Buffer(); try { if (maxHeaderTableSize != -1) { hpackEncoder.SetMaxHeaderTableSize(buffer, maxHeaderTableSize); } hpackEncoder.EncodeHeaders(3 /* randomly chosen */, buffer, http2Headers, sensitivityDetector); byte[] bytes = new byte[buffer.ReadableBytes]; buffer.ReadBytes(bytes); return(bytes); } finally { buffer.Release(); } }