Merge pull request #1419 from dotnet-maestro-bot/merge/release/2.2-to-master
[automated] Merge branch 'release/2.2' => 'master'
This commit is contained in:
commit
3784548494
|
|
@ -318,29 +318,23 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
|
||||||
{
|
{
|
||||||
var headerValues = headerPair.Value;
|
var headerValues = headerPair.Value;
|
||||||
var knownHeaderIndex = HttpApiTypes.HTTP_RESPONSE_HEADER_ID.IndexOfKnownHeader(headerPair.Key);
|
var knownHeaderIndex = HttpApiTypes.HTTP_RESPONSE_HEADER_ID.IndexOfKnownHeader(headerPair.Key);
|
||||||
if (knownHeaderIndex == -1)
|
for (var i = 0; i < headerValues.Count; i++)
|
||||||
{
|
{
|
||||||
var headerNameBytes = Encoding.UTF8.GetBytes(headerPair.Key);
|
var isFirst = i == 0;
|
||||||
for (var i = 0; i < headerValues.Count; i++)
|
var headerValueBytes = Encoding.UTF8.GetBytes(headerValues[i]);
|
||||||
|
fixed (byte* pHeaderValue = headerValueBytes)
|
||||||
{
|
{
|
||||||
var headerValueBytes = Encoding.UTF8.GetBytes(headerValues[i]);
|
if (knownHeaderIndex == -1)
|
||||||
fixed (byte* pHeaderName = headerNameBytes)
|
|
||||||
{
|
{
|
||||||
fixed (byte* pHeaderValue = headerValueBytes)
|
var headerNameBytes = Encoding.UTF8.GetBytes(headerPair.Key);
|
||||||
|
fixed (byte* pHeaderName = headerNameBytes)
|
||||||
{
|
{
|
||||||
NativeMethods.HttpResponseSetUnknownHeader(_pInProcessHandler, pHeaderName, pHeaderValue, (ushort)headerValueBytes.Length, fReplace: false);
|
NativeMethods.HttpResponseSetUnknownHeader(_pInProcessHandler, pHeaderName, pHeaderValue, (ushort)headerValueBytes.Length, fReplace: isFirst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (var i = 0; i < headerValues.Count; i++)
|
|
||||||
{
|
|
||||||
var headerValueBytes = Encoding.UTF8.GetBytes(headerValues[i]);
|
|
||||||
fixed (byte* pHeaderValue = headerValueBytes)
|
|
||||||
{
|
{
|
||||||
NativeMethods.HttpResponseSetKnownHeader(_pInProcessHandler, knownHeaderIndex, pHeaderValue, (ushort)headerValueBytes.Length, fReplace: false);
|
NativeMethods.HttpResponseSetKnownHeader(_pInProcessHandler, knownHeaderIndex, pHeaderValue, (ushort)headerValueBytes.Length, fReplace: isFirst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,5 +74,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
// ReadAsStringAsync returns empty string for empty results
|
// ReadAsStringAsync returns empty string for empty results
|
||||||
Assert.Equal(body ?? string.Empty, await response.Content.ReadAsStringAsync());
|
Assert.Equal(body ?? string.Empty, await response.Content.ReadAsStringAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
public async Task ServerHeaderIsOverriden()
|
||||||
|
{
|
||||||
|
var response = await _fixture.Client.GetAsync("OverrideServer");
|
||||||
|
Assert.Equal("MyServer/7.8", response.Headers.Server.Single().Product.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,18 +62,15 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
|
|
||||||
public async Task Send(params string[] lines)
|
public async Task Send(params string[] lines)
|
||||||
{
|
{
|
||||||
var text = string.Join("\r\n", lines);
|
var bytes = Encoding.ASCII.GetBytes(string.Join("\r\n", lines));
|
||||||
var writer = new StreamWriter(_stream, Encoding.GetEncoding("iso-8859-1"));
|
|
||||||
for (var index = 0; index < text.Length; index++)
|
for (var index = 0; index < bytes.Length; index++)
|
||||||
{
|
{
|
||||||
var ch = text[index];
|
await _stream.WriteAsync(bytes, index, 1).ConfigureAwait(false);
|
||||||
writer.Write(ch);
|
await _stream.FlushAsync().ConfigureAwait(false);
|
||||||
await writer.FlushAsync().ConfigureAwait(false);
|
|
||||||
// Re-add delay to help find socket input consumption bugs more consistently
|
// Re-add delay to help find socket input consumption bugs more consistently
|
||||||
//await Task.Delay(TimeSpan.FromMilliseconds(5));
|
//await Task.Delay(TimeSpan.FromMilliseconds(5));
|
||||||
}
|
}
|
||||||
await writer.FlushAsync().ConfigureAwait(false);
|
|
||||||
await _stream.FlushAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> ReadCharAsync()
|
public async Task<int> ReadCharAsync()
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
public async Task ReaderThrowsResetExceptionOnInvalidBody()
|
public async Task ReaderThrowsResetExceptionOnInvalidBody()
|
||||||
{
|
{
|
||||||
|
var requestStartedCompletionSource = CreateTaskCompletionSource();
|
||||||
var requestCompletedCompletionSource = CreateTaskCompletionSource();
|
var requestCompletedCompletionSource = CreateTaskCompletionSource();
|
||||||
|
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
|
|
@ -213,6 +214,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
var data = new byte[1024];
|
var data = new byte[1024];
|
||||||
using (var testServer = await TestServer.Create(async ctx =>
|
using (var testServer = await TestServer.Create(async ctx =>
|
||||||
{
|
{
|
||||||
|
requestStartedCompletionSource.SetResult(true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ctx.Request.Body.ReadAsync(data);
|
await ctx.Request.Body.ReadAsync(data);
|
||||||
|
|
@ -233,10 +235,19 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
"Host: localhost",
|
"Host: localhost",
|
||||||
"Connection: close",
|
"Connection: close",
|
||||||
"",
|
"",
|
||||||
"ZZZ",
|
|
||||||
"");
|
"");
|
||||||
await requestCompletedCompletionSource.Task.DefaultTimeout();
|
|
||||||
|
await requestStartedCompletionSource.Task;
|
||||||
|
await connection.Send(
|
||||||
|
"ZZZZZZZZZZZZZ");
|
||||||
|
|
||||||
|
await connection.Receive(
|
||||||
|
"HTTP/1.1 400 Bad Request",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
await requestCompletedCompletionSource.Task.DefaultTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.IsType<ConnectionResetException>(exception);
|
Assert.IsType<ConnectionResetException>(exception);
|
||||||
|
|
|
||||||
|
|
@ -82,5 +82,11 @@ namespace TestSite
|
||||||
}
|
}
|
||||||
await context.Response.WriteAsync(_applicationInitializationCalled.ToString());
|
await context.Response.WriteAsync(_applicationInitializationCalled.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task OverrideServer(HttpContext context)
|
||||||
|
{
|
||||||
|
context.Response.Headers["Server"] = "MyServer/7.8";
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue