Ejemplo n.º 1
0
        public async Task HttpRequestMustParseRequestHostFromStream()
        {
            MemoryStream stream = GetRequest();

            var httpRequest = new HttpRequest(stream);
            await httpRequest.ReadHeadersAsync();

            Assert.Equal("api.service.com", httpRequest.Host);
            Assert.NotEqual(stream.Position, stream.Length);
        }
Ejemplo n.º 2
0
        public async Task HttpRequestMustParseRequestFirstLineFromStream()
        {
            MemoryStream stream = GetRequest();

            var httpRequest = new HttpRequest(stream);
            await httpRequest.ReadFirstLineAsync();

            Assert.Equal("GET", httpRequest.Method);
            Assert.Equal("/api/someresource", httpRequest.Uri);
            Assert.Equal("HTTP/1.1", httpRequest.Version);
        }
Ejemplo n.º 3
0
        public async Task HttpRequestMustStreamAllRequest()
        {
            MemoryStream stream = GetRequest();
            MemoryStream stream2 = new MemoryStream();

            var httpRequest = new HttpRequest(stream);
            await httpRequest.ReadHeadersAsync();
            await httpRequest.RedirectToAsync(stream2);
            
            Assert.Equal(stream.Position, stream.Length);
            Assert.Equal(stream2.Length, stream.Length);
        }
Ejemplo n.º 4
0
        public async Task HttpRequestMustStreamAppendedHeaders()
        {
            MemoryStream stream = GetRequest();
            MemoryStream stream2 = new MemoryStream();

            var httpRequest = new HttpRequest(stream);
            await httpRequest.ReadHeadersAsync();
            httpRequest.AddHeader("SOMEHEADER", "VALUE");

            await httpRequest.RedirectToAsync(stream2);

            Assert.Equal(stream.Position, stream.Length);
            //SOMEHEADER: VALUE\r\n = 19bytes
            Assert.Equal(stream2.Length, stream.Length + 19);
        }