parent
c9829d073f
commit
6dd3d6ec49
|
|
@ -37,8 +37,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
string IHttpRequestFeature.Protocol
|
string IHttpRequestFeature.Protocol
|
||||||
{
|
{
|
||||||
get => HttpVersion;
|
get => _httpProtocol ??= HttpVersion;
|
||||||
set => HttpVersion = value;
|
set => _httpProtocol = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
string IHttpRequestFeature.Scheme
|
string IHttpRequestFeature.Scheme
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
private BadHttpRequestException _requestRejectedException;
|
private BadHttpRequestException _requestRejectedException;
|
||||||
|
|
||||||
protected HttpVersion _httpVersion;
|
protected HttpVersion _httpVersion;
|
||||||
|
// This should only be used by the application, not the server. This is settable on HttpRequest but we don't want that to affect
|
||||||
|
// how Kestrel processes requests/responses.
|
||||||
|
private string _httpProtocol;
|
||||||
|
|
||||||
private string _requestId;
|
private string _requestId;
|
||||||
private int _requestHeadersParsed;
|
private int _requestHeadersParsed;
|
||||||
|
|
@ -351,6 +354,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
RawTarget = null;
|
RawTarget = null;
|
||||||
QueryString = null;
|
QueryString = null;
|
||||||
_httpVersion = Http.HttpVersion.Unknown;
|
_httpVersion = Http.HttpVersion.Unknown;
|
||||||
|
_httpProtocol = null;
|
||||||
_statusCode = StatusCodes.Status200OK;
|
_statusCode = StatusCodes.Status200OK;
|
||||||
_reasonPhrase = null;
|
_reasonPhrase = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,42 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task IgnoresChangesToHttpProtocol()
|
||||||
|
{
|
||||||
|
var testContext = new TestServiceContext(LoggerFactory);
|
||||||
|
|
||||||
|
await using (var server = new TestServer(async httpContext =>
|
||||||
|
{
|
||||||
|
httpContext.Request.Protocol = "HTTP/2"; // Doesn't support chunking. This change should be ignored.
|
||||||
|
var response = httpContext.Response;
|
||||||
|
await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello "), 0, 6));
|
||||||
|
await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("World!"), 0, 6));
|
||||||
|
}, testContext))
|
||||||
|
{
|
||||||
|
using (var connection = server.CreateConnection())
|
||||||
|
{
|
||||||
|
await connection.Send(
|
||||||
|
"GET / HTTP/1.1",
|
||||||
|
"Host:",
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
await connection.Receive(
|
||||||
|
"HTTP/1.1 200 OK",
|
||||||
|
$"Date: {testContext.DateHeaderValue}",
|
||||||
|
"Transfer-Encoding: chunked",
|
||||||
|
"",
|
||||||
|
"6",
|
||||||
|
"Hello ",
|
||||||
|
"6",
|
||||||
|
"World!",
|
||||||
|
"0",
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ResponsesAreChunkedAutomaticallyForHttp11NonKeepAliveRequests()
|
public async Task ResponsesAreChunkedAutomaticallyForHttp11NonKeepAliveRequests()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue