public void DisableHeaderValidation() { IByteBuffer input = Unpooled.Buffer(200); try { HpackEncoder hpackEncoder = new HpackEncoder(true); IHttp2Headers toEncode = new DefaultHttp2Headers(); toEncode.Add((AsciiString)":test", (AsciiString)"1"); toEncode.Add((AsciiString)":status", (AsciiString)"200"); toEncode.Add((AsciiString)":method", (AsciiString)"GET"); hpackEncoder.EncodeHeaders(1, input, toEncode, NeverSensitiveDetector.Instance); IHttp2Headers decoded = new DefaultHttp2Headers(); hpackDecoder.Decode(1, input, decoded, false); Assert.Equal("1", decoded.GetAll((AsciiString)":test")[0]); Assert.Equal("200", decoded.Status); Assert.Equal("GET", decoded.Method); } finally { input.Release(); } }
public void MultipleCookieEntriesAreCombined() { this.BootstrapEnv(2, 1, 0); IFullHttpRequest request = new DefaultFullHttpRequest(DotNetty.Codecs.Http.HttpVersion.Http11, HttpMethod.Get, "http://[email protected]:5555/example"); HttpHeaders httpHeaders = request.Headers; httpHeaders.SetInt(HttpConversionUtil.ExtensionHeaderNames.StreamId, 5); httpHeaders.Set(HttpHeaderNames.Host, "[email protected]:5555"); httpHeaders.Set(HttpConversionUtil.ExtensionHeaderNames.Scheme, "http"); httpHeaders.Set(HttpHeaderNames.Cookie, "a=b; c=d; e=f"); var http2Headers = new DefaultHttp2Headers() { Method = new AsciiString("GET"), Path = new AsciiString("/example"), Authority = new AsciiString("www.example.org:5555"), Scheme = new AsciiString("http") }; http2Headers.Add(HttpHeaderNames.Cookie, new AsciiString("a=b")); http2Headers.Add(HttpHeaderNames.Cookie, new AsciiString("c=d")); http2Headers.Add(HttpHeaderNames.Cookie, new AsciiString("e=f")); var writePromise = this.NewPromise(); this.VerifyHeadersOnly(http2Headers, writePromise, this.clientChannel.WriteAndFlushAsync(request, writePromise)); }
public void SuccessiveCallsShouldSucceed() { var input = new DefaultHttp2Headers(); input.Method = new AsciiString("GET"); input.Scheme = new AsciiString("https"); input.Authority = new AsciiString("example.org"); input.Path = new AsciiString("/some/path"); input.Add(new AsciiString("accept"), new AsciiString("*/*")); this.AssertRoundtripSuccessful(input); input = new DefaultHttp2Headers(); input.Method = new AsciiString("GET"); input.Scheme = new AsciiString("https"); input.Authority = new AsciiString("example.org"); input.Path = new AsciiString("/some/path/resource1"); input.Add(new AsciiString("accept"), new AsciiString("image/jpeg")); input.Add(new AsciiString("cache-control"), new AsciiString("no-cache")); this.AssertRoundtripSuccessful(input); input = new DefaultHttp2Headers(); input.Method = new AsciiString("GET"); input.Scheme = new AsciiString("https"); input.Authority = new AsciiString("example.org"); input.Path = new AsciiString("/some/path/resource2"); input.Add(new AsciiString("accept"), new AsciiString("image/png")); input.Add(new AsciiString("cache-control"), new AsciiString("no-cache")); this.AssertRoundtripSuccessful(input); }
public void AddHttp2ToHttpHeadersCombinesCookies() { var inHeaders = new DefaultHttp2Headers(); inHeaders.Add((AsciiString)"yes", (AsciiString)"no"); inHeaders.Add(HttpHeaderNames.Cookie, (AsciiString)"foo=bar"); inHeaders.Add(HttpHeaderNames.Cookie, (AsciiString)"bax=baz"); HttpHeaders outHeaders = new DefaultHttpHeaders(); HttpConversionUtil.AddHttp2ToHttpHeaders(5, inHeaders, outHeaders, HttpVersion.Http11, false, false); Assert.Equal("no", outHeaders.Get((AsciiString)"yes", null)); Assert.Equal("foo=bar; bax=baz", outHeaders.Get(HttpHeaderNames.Cookie, null)); }
private static IHttp2Headers NewHeaders() { var headers = new DefaultHttp2Headers(); headers.Add(AsciiString.Of("name1"), new[] { AsciiString.Of("value1"), AsciiString.Of("value2") }); headers.Method = AsciiString.Of("POST"); headers.Add(AsciiString.Of("2name"), AsciiString.Of("value3")); headers.Path = AsciiString.Of("/index.html"); headers.Status = AsciiString.Of("200"); headers.Authority = AsciiString.Of("netty.io"); headers.Add(AsciiString.Of("name3"), AsciiString.Of("value4")); headers.Scheme = AsciiString.Of("https"); return(headers); }
public void TestAccountForHeaderOverhead() { IByteBuffer input = Unpooled.Buffer(100); try { string headerName = "12345"; string headerValue = "56789"; long headerSize = headerName.Length + headerValue.Length; hpackDecoder.SetMaxHeaderListSize(headerSize); HpackEncoder hpackEncoder = new HpackEncoder(true); IHttp2Headers toEncode = new DefaultHttp2Headers(); toEncode.Add((AsciiString)headerName, (AsciiString)headerValue); hpackEncoder.EncodeHeaders(1, input, toEncode, NeverSensitiveDetector.Instance); IHttp2Headers decoded = new DefaultHttp2Headers(); // SETTINGS_MAX_HEADER_LIST_SIZE is big enough for the header to fit... Assert.True(hpackDecoder.GetMaxHeaderListSize() >= headerSize); // ... but decode should fail because we add some overhead for each header entry Assert.Throws <HeaderListSizeException>(() => hpackDecoder.Decode(1, input, decoded, true)); } finally { input.Release(); } }
public void FailedWhenContinuationFrameStreamIdMismatch() { var input = Unpooled.Buffer(); try { var headers = new DefaultHttp2Headers { Authority = (AsciiString)"foo", Method = (AsciiString)"get", Path = (AsciiString)"/", Scheme = (AsciiString)"https" }; this.WriteHeaderFrame(input, 1, headers, new Http2Flags().EndOfHeaders(false).EndOfStream(true)); var headers0 = new DefaultHttp2Headers(); headers0.Add((AsciiString)"foo", (AsciiString)"bar"); this.WriteContinuationFrame(input, 3, headers0, new Http2Flags().EndOfHeaders(true)); Assert.Throws <Http2Exception>(() => frameReader.ReadFrame(this.ctx.Object, input, this.listener.Object)); } finally { input.Release(); } }
public void ReadHeaderFrameAndContinuationFrame() { int streamId = 1; var input = Unpooled.Buffer(); try { var headers = new DefaultHttp2Headers { Authority = (AsciiString)"foo", Method = (AsciiString)"get", Path = (AsciiString)"/", Scheme = (AsciiString)"https" }; this.WriteHeaderFrame(input, streamId, headers, new Http2Flags().EndOfHeaders(false).EndOfStream(true)); var headers0 = new DefaultHttp2Headers(); headers0.Add((AsciiString)"foo", (AsciiString)"bar"); this.WriteContinuationFrame(input, streamId, headers0, new Http2Flags().EndOfHeaders(true)); this.frameReader.ReadFrame(this.ctx.Object, input, this.listener.Object); headers.Add((AsciiString)"foo", (AsciiString)"bar"); this.listener.Verify(x => x.OnHeadersRead(this.ctx.Object, 1, headers, 0, true)); } finally { input.Release(); } }
public void TestPseudoHeadersWithClearDoesNotLeak() { var headers = NewHeaders(); Assert.False(headers.IsEmpty); headers.Clear(); Assert.True(headers.IsEmpty); // Combine 2 headers together, make sure pseudo headers stay up front. headers.Add((AsciiString)"name1", (AsciiString)"value1"); headers.Scheme = (AsciiString)"nothing"; VerifyPseudoHeadersFirst(headers); var other = new DefaultHttp2Headers(); other.Add((AsciiString)"name2", (AsciiString)"value2"); other.Authority = (AsciiString)"foo"; VerifyPseudoHeadersFirst(other); headers.Add(other); VerifyPseudoHeadersFirst(headers); // Make sure the headers are what we expect them to be, and no leaking behind the scenes. Assert.Equal(4, headers.Size); Assert.Equal("value1", headers.Get((AsciiString)"name1", null)); Assert.Equal("value2", headers.Get((AsciiString)"name2", null)); Assert.Equal("nothing", headers.Scheme); Assert.Equal("foo", headers.Authority); }
public void TestPseudoHeadersWithRemovePreservesPseudoIterationOrder() { var headers = NewHeaders(); var nonPseudoHeaders = new DefaultHttp2Headers(); foreach (var entry in headers) { if (entry.Key.Count == 0 || entry.Key[0] != ':' && !nonPseudoHeaders.Contains(entry.Key)) { nonPseudoHeaders.Add(entry.Key, entry.Value); } } Assert.False(nonPseudoHeaders.IsEmpty); // Remove all the non-pseudo headers and verify foreach (var nonPseudoHeaderEntry in nonPseudoHeaders) { Assert.True(headers.Remove(nonPseudoHeaderEntry.Key)); VerifyPseudoHeadersFirst(headers); VerifyAllPseudoHeadersPresent(headers); } // Add back all non-pseudo headers foreach (var nonPseudoHeaderEntry in nonPseudoHeaders) { headers.Add(nonPseudoHeaderEntry.Key, AsciiString.Of("goo")); VerifyPseudoHeadersFirst(headers); VerifyAllPseudoHeadersPresent(headers); } }
private static IHttp2Headers Headers() { var headers = new DefaultHttp2Headers(); headers.Method = new AsciiString("GET"); headers.Add(new AsciiString("a"), new AsciiString("1")) .Add(new AsciiString("a"), new AsciiString("2")); return(headers); }
private static IHttp2Headers BinaryHeaders() { DefaultHttp2Headers headers = new DefaultHttp2Headers(false); for (int ix = 0; ix < 10; ++ix) { headers.Add(Http2TestUtil.RandomString(), Http2TestUtil.RandomString()); } return(headers); }
private static IHttp2Headers ToHttp2Headers(List <HpackHeaderField> inHeaders) { IHttp2Headers headers = new DefaultHttp2Headers(false); foreach (HpackHeaderField e in inHeaders) { headers.Add(e._name, e._value); } return(headers); }
private static IHttp2Headers Headers() { var headers = new DefaultHttp2Headers(false); headers.Method = AsciiString.Of("GET"); headers.Scheme = AsciiString.Of("https"); headers.Authority = AsciiString.Of("example.org"); headers.Path = AsciiString.Of("/some/path/resource2"); headers.Add(Http2TestUtil.RandomString(), Http2TestUtil.RandomString()); return(headers); }
private static IHttp2Headers HeadersOfSize(int minSize) { AsciiString singleByte = new AsciiString(new byte[] { 0 }, false); DefaultHttp2Headers headers = new DefaultHttp2Headers(false); for (int size = 0; size < minSize; size += 2) { headers.Add(singleByte, singleByte); } return(headers); }
public void ClientRequestSingleHeaderCookieSplitIntoMultipleEntries() { this.BootstrapEnv(1, 1, 1); IFullHttpRequest request = new DefaultFullHttpRequest(DotNetty.Codecs.Http.HttpVersion.Http11, HttpMethod.Get, "/some/path/resource2", true); try { HttpHeaders httpHeaders = request.Headers; httpHeaders.Set(HttpConversionUtil.ExtensionHeaderNames.Scheme, "https"); httpHeaders.Set(HttpHeaderNames.Host, "example.org"); httpHeaders.SetInt(HttpConversionUtil.ExtensionHeaderNames.StreamId, 3); httpHeaders.SetInt(HttpHeaderNames.ContentLength, 0); httpHeaders.Set(HttpHeaderNames.Cookie, "a=b; c=d; e=f"); httpHeaders.SetShort(HttpConversionUtil.ExtensionHeaderNames.StreamWeight, 16); var http2Headers = new DefaultHttp2Headers() { Method = new AsciiString("GET"), Scheme = new AsciiString("https"), Authority = new AsciiString("example.org"), Path = new AsciiString("/some/path/resource2"), }; http2Headers.Add(HttpHeaderNames.Cookie, (AsciiString)"a=b"); http2Headers.Add(HttpHeaderNames.Cookie, (AsciiString)"c=d"); http2Headers.Add(HttpHeaderNames.Cookie, (AsciiString)"e=f"); Http2TestUtil.RunInChannel(this.clientChannel, () => { this.clientHandler.Encoder.WriteHeadersAsync(this.CtxClient(), 3, http2Headers, 0, true, this.NewPromiseClient()); this.clientChannel.Flush(); }); this.AwaitRequests(); var requestCaptor = new ArgumentCaptor <IFullHttpMessage>(); this.serverListener.Verify(x => x.MessageReceived(It.Is <IHttpObject>(v => requestCaptor.Capture((IFullHttpMessage)v)))); this.capturedRequests = requestCaptor.GetAllValues(); Assert.Equal(request, (IFullHttpRequest)this.capturedRequests[0]); } finally { request.Release(); } }
private static IHttp2Headers LargeHeaders() { DefaultHttp2Headers headers = new DefaultHttp2Headers(false); for (int i = 0; i < 100; ++i) { string key = "this-is-a-test-header-key-" + i; string value = "this-is-a-test-header-value-" + i; headers.Add(AsciiString.Of(key), AsciiString.Of(value)); } return(headers); }
public void TestDecodeLargerThanMaxHeaderListSizeUpdatesDynamicTable() { IByteBuffer input = Unpooled.Buffer(300); try { hpackDecoder.SetMaxHeaderListSize(200); HpackEncoder hpackEncoder = new HpackEncoder(true); // encode headers that are slightly larger than maxHeaderListSize IHttp2Headers toEncode = new DefaultHttp2Headers(); toEncode.Add((AsciiString)"test_1", (AsciiString)"1"); toEncode.Add((AsciiString)"test_2", (AsciiString)"2"); toEncode.Add((AsciiString)"long", (AsciiString)"A".PadRight(100, 'A')); //string.Format("{0,0100:d}", 0).Replace('0', 'A') toEncode.Add((AsciiString)"test_3", (AsciiString)"3"); hpackEncoder.EncodeHeaders(1, input, toEncode, NeverSensitiveDetector.Instance); // decode the headers, we should get an exception IHttp2Headers decoded = new DefaultHttp2Headers(); Assert.Throws <HeaderListSizeException>(() => hpackDecoder.Decode(1, input, decoded, true)); // but the dynamic table should have been updated, so that later blocks // can refer to earlier headers input.Clear(); // 0x80, "indexed header field representation" // index 62, the first (most recent) dynamic table entry input.WriteByte(0x80 | 62); IHttp2Headers decoded2 = new DefaultHttp2Headers(); hpackDecoder.Decode(1, input, decoded2, true); IHttp2Headers golden = new DefaultHttp2Headers(); golden.Add((AsciiString)"test_3", (AsciiString)"3"); Assert.Equal(golden, decoded2); } finally { input.Release(); } }
public void ResponsePseudoHeaderInRequest() { IByteBuffer input = Unpooled.Buffer(200); try { HpackEncoder hpackEncoder = new HpackEncoder(true); IHttp2Headers toEncode = new DefaultHttp2Headers(); toEncode.Add((AsciiString)":method", (AsciiString)"GET"); toEncode.Add((AsciiString)":status", (AsciiString)"200"); hpackEncoder.EncodeHeaders(1, input, toEncode, NeverSensitiveDetector.Instance); IHttp2Headers decoded = new DefaultHttp2Headers(); Assert.Throws <StreamException>(() => hpackDecoder.Decode(1, input, decoded, true)); } finally { input.Release(); } }
private static IByteBuffer Encode(params byte[][] entries) { HpackEncoder hpackEncoder = Http2TestUtil.NewTestEncoder(); var output = Unpooled.Buffer(); var http2Headers = new DefaultHttp2Headers(false); for (int ix = 0; ix < entries.Length;) { http2Headers.Add(new AsciiString(entries[ix++], false), new AsciiString(entries[ix++], false)); } hpackEncoder.EncodeHeaders(3 /* randomly chosen */, output, http2Headers, NeverSensitiveDetector.Instance); return(output); }
public void TestSetHeadersOrdersPseudoHeadersCorrectly() { var headers = NewHeaders(); var other = new DefaultHttp2Headers(); other.Add((AsciiString)"name2", (AsciiString)"value2"); other.Authority = (AsciiString)"foo"; headers.Set(other); VerifyPseudoHeadersFirst(headers); Assert.Equal(other.Size, headers.Size); Assert.Equal("foo", headers.Authority); Assert.Equal("value2", headers.Get((AsciiString)"name2", null)); }
public void TestDecodeCountsNamesOnlyOnce() { IByteBuffer input = Unpooled.Buffer(200); try { hpackDecoder.SetMaxHeaderListSize(3500); HpackEncoder hpackEncoder = new HpackEncoder(true); // encode headers that are slightly larger than maxHeaderListSize IHttp2Headers toEncode = new DefaultHttp2Headers(); toEncode.Add((AsciiString)("0".PadRight(3000, '0').Replace('0', 'f')), (AsciiString)"value"); toEncode.Add((AsciiString)"accept", (AsciiString)"value"); hpackEncoder.EncodeHeaders(1, input, toEncode, NeverSensitiveDetector.Instance); IHttp2Headers decoded = new DefaultHttp2Headers(); hpackDecoder.Decode(1, input, decoded, true); Assert.Equal(2, decoded.Size); } finally { input.Release(); } }
public void FailedValidationDoesntCorruptHpack() { IByteBuffer in1 = Unpooled.Buffer(200); IByteBuffer in2 = Unpooled.Buffer(200); try { HpackEncoder hpackEncoder = new HpackEncoder(true); IHttp2Headers toEncode = new DefaultHttp2Headers(); toEncode.Add((AsciiString)":method", (AsciiString)"GET"); toEncode.Add((AsciiString)":status", (AsciiString)"200"); toEncode.Add((AsciiString)"foo", (AsciiString)"bar"); hpackEncoder.EncodeHeaders(1, in1, toEncode, NeverSensitiveDetector.Instance); IHttp2Headers decoded = new DefaultHttp2Headers(); var expected = Assert.Throws <StreamException>(() => hpackDecoder.Decode(1, in1, decoded, true)); Assert.Equal(1, expected.StreamId); // Do it again, this time without validation, to make sure the HPACK state is still sane. decoded.Clear(); hpackEncoder.EncodeHeaders(1, in2, toEncode, NeverSensitiveDetector.Instance); hpackDecoder.Decode(1, in2, decoded, false); Assert.Equal(3, decoded.Size); Assert.Equal("GET", decoded.Method); Assert.Equal("200", decoded.Status); Assert.Equal("bar", decoded.Get((AsciiString)"foo", null)); } finally { in1.Release(); in2.Release(); } }
public void FailedWhenContinuationFrameNotFollowHeaderFrame() { var input = Unpooled.Buffer(); try { var headers0 = new DefaultHttp2Headers(); headers0.Add((AsciiString)"foo", (AsciiString)"bar"); this.WriteContinuationFrame(input, 1, headers0, new Http2Flags().EndOfHeaders(true)); Assert.Throws <Http2Exception>(() => frameReader.ReadFrame(this.ctx.Object, input, this.listener.Object)); } finally { input.Release(); } }
public void TestSetAllOrdersPseudoHeadersCorrectly() { var headers = NewHeaders(); var other = new DefaultHttp2Headers(); other.Add((AsciiString)"name2", (AsciiString)"value2"); other.Authority = (AsciiString)"foo"; int headersSizeBefore = headers.Size; headers.SetAll(other); VerifyPseudoHeadersFirst(headers); VerifyAllPseudoHeadersPresent(headers); Assert.Equal(headersSizeBefore + 1, headers.Size); Assert.Equal((AsciiString)"foo", headers.Authority); Assert.Equal((AsciiString)"value2", headers.Get((AsciiString)"name2", null)); }
public void ClientRequestTrailingHeaders() { this.BootstrapEnv(1, 1, 1); string text = "some data"; IByteBuffer content = Unpooled.CopiedBuffer(Encoding.UTF8.GetBytes(text)); IFullHttpRequest request = new DefaultFullHttpRequest(DotNetty.Codecs.Http.HttpVersion.Http11, HttpMethod.Get, "/some/path/resource2", content, true); try { HttpHeaders httpHeaders = request.Headers; httpHeaders.SetInt(HttpConversionUtil.ExtensionHeaderNames.StreamId, 3); httpHeaders.SetInt(HttpHeaderNames.ContentLength, text.Length); httpHeaders.SetShort(HttpConversionUtil.ExtensionHeaderNames.StreamWeight, 16); HttpHeaders trailingHeaders = request.TrailingHeaders; trailingHeaders.Set(AsciiString.Of("Foo"), AsciiString.Of("goo")); trailingHeaders.Set(AsciiString.Of("fOo2"), AsciiString.Of("goo2")); trailingHeaders.Add(AsciiString.Of("foO2"), AsciiString.Of("goo3")); var http2Headers = new DefaultHttp2Headers() { Method = new AsciiString("GET"), Path = new AsciiString("/some/path/resource2"), }; IHttp2Headers http2Headers2 = new DefaultHttp2Headers(); http2Headers2.Set(new AsciiString("foo"), new AsciiString("goo")); http2Headers2.Set(new AsciiString("foo2"), new AsciiString("goo2")); http2Headers2.Add(new AsciiString("foo2"), new AsciiString("goo3")); Http2TestUtil.RunInChannel(this.clientChannel, () => { this.clientHandler.Encoder.WriteHeadersAsync(this.CtxClient(), 3, http2Headers, 0, false, this.NewPromiseClient()); this.clientHandler.Encoder.WriteDataAsync(this.CtxClient(), 3, content.RetainedDuplicate(), 0, false, this.NewPromiseClient()); this.clientHandler.Encoder.WriteHeadersAsync(this.CtxClient(), 3, http2Headers2, 0, true, this.NewPromiseClient()); this.clientChannel.Flush(); }); this.AwaitRequests(); var requestCaptor = new ArgumentCaptor <IFullHttpMessage>(); this.serverListener.Verify(x => x.MessageReceived(It.Is <IHttpObject>(v => requestCaptor.Capture((IFullHttpMessage)v)))); this.capturedRequests = requestCaptor.GetAllValues(); Assert.Equal(request, (IFullHttpRequest)this.capturedRequests[0]); } finally { request.Release(); } }
private static IHttp2Headers Headers() { var headers = new DefaultHttp2Headers(false); headers.Method = new AsciiString("GET"); headers.Scheme = new AsciiString("https"); headers.Authority = new AsciiString("example.org"); headers.Path = new AsciiString("/some/path/resource2"); headers.Add(new AsciiString("accept"), new AsciiString("image/png")); headers.Add(new AsciiString("cache-control"), new AsciiString("no-cache")); headers.Add(new AsciiString("custom"), new AsciiString("value1")); headers.Add(new AsciiString("custom"), new AsciiString("value2")); headers.Add(new AsciiString("custom"), new AsciiString("value3")); headers.Add(new AsciiString("custom"), new AsciiString("custom4")); headers.Add(Http2TestUtil.RandomString(), Http2TestUtil.RandomString()); return(headers); }
public void ClientRequestSingleHeaderNonAsciiShouldThrow() { this.BootstrapEnv(1, 1, 1); var http2Headers = new DefaultHttp2Headers() { Method = new AsciiString("GET"), Scheme = new AsciiString("https"), Authority = new AsciiString("example.org"), Path = new AsciiString("/some/path/resource2"), }; http2Headers.Add(new AsciiString(Encoding.UTF8.GetBytes("çã"), true), new AsciiString(Encoding.UTF8.GetBytes("Ãã"), true)); Http2TestUtil.RunInChannel(this.clientChannel, () => { this.clientHandler.Encoder.WriteHeadersAsync(this.CtxClient(), 3, http2Headers, 0, true, this.NewPromiseClient()); this.clientChannel.Flush(); }); this.AwaitResponses(); Assert.True(Http2Exception.IsStreamError(this.clientException)); }
public void TestWillEncode16MBHeaderByDefault() { var buf = Unpooled.Buffer(); var bigHeaderName = "x-big-header"; int bigHeaderSize = 1024 * 1024 * 16; var bigHeaderVal = new string(new char[bigHeaderSize]).Replace('\0', 'X'); IHttp2Headers headersIn = new DefaultHttp2Headers(); headersIn.Add((AsciiString)"x-big-header", (AsciiString)bigHeaderVal); IHttp2Headers headersOut = new DefaultHttp2Headers(); try { hpackEncoder.EncodeHeaders(0, buf, headersIn, NeverSensitiveDetector.Instance); hpackDecoder.SetMaxHeaderListSize(bigHeaderSize + 1024); hpackDecoder.Decode(0, buf, headersOut, false); } finally { buf.Release(); } Assert.Equal(bigHeaderVal, headersOut.Get((AsciiString)bigHeaderName, null).ToString()); }
public void TestSetMaxHeaderListSizeEnforcedAfterSet() { Assert.Throws <Http2Exception>(() => { var buf = Unpooled.Buffer(); IHttp2Headers headers = new DefaultHttp2Headers(); headers.Add( (AsciiString)"x-big-header", (AsciiString) new string(new char[1024 * 16]).Replace('\0', 'X') ); hpackEncoder.SetMaxHeaderListSize(1000); try { hpackEncoder.EncodeHeaders(0, buf, headers, NeverSensitiveDetector.Instance); } finally { buf.Release(); } }); }