示例#1
0
        public void TestDecodeResponseHeadersWithContentLength()
        {
            EmbeddedChannel ch      = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(false));
            IHttp2Headers   headers = new DefaultHttp2Headers();

            headers.Scheme = HttpScheme.Http.Name;
            headers.Status = HttpResponseStatus.OK.CodeAsText;
            headers.SetInt((AsciiString)"content-length", 0);

            Assert.True(ch.WriteInbound(new DefaultHttp2HeadersFrame(headers)));

            IHttpResponse response = ch.ReadInbound <IHttpResponse>();

            Assert.Equal(HttpResponseStatus.OK, response.Status);
            Assert.Equal(HttpVersion.Http11, response.ProtocolVersion);
            Assert.False(response is IFullHttpResponse);
            Assert.False(HttpUtil.IsTransferEncodingChunked(response));

            Assert.Null(ch.ReadInbound <object>());
            Assert.False(ch.Finish());
        }
示例#2
0
        public void TestDowngradeHeadersWithContentLength()
        {
            EmbeddedChannel ch      = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(true));
            IHttp2Headers   headers = new DefaultHttp2Headers
            {
                Path   = (AsciiString)"/",
                Method = (AsciiString)"GET"
            };

            headers.SetInt((AsciiString)"content-length", 0);

            Assert.True(ch.WriteInbound(new DefaultHttp2HeadersFrame(headers)));

            var request = ch.ReadInbound <IHttpRequest>();

            Assert.Equal("/", request.Uri);
            Assert.Equal(HttpMethod.Get, request.Method);
            Assert.Equal(HttpVersion.Http11, request.ProtocolVersion);
            Assert.False(request is IFullHttpRequest);
            Assert.False(HttpUtil.IsTransferEncodingChunked(request));

            Assert.Null(ch.ReadInbound <object>());
            Assert.False(ch.Finish());
        }