Set connection close with a switch for ANCM out of process (#16643)
This commit is contained in:
parent
d427e43d78
commit
76193ecdfd
|
|
@ -14,6 +14,7 @@ class ConfigUtility
|
||||||
#define CS_ASPNETCORE_HANDLER_SETTINGS L"handlerSettings"
|
#define CS_ASPNETCORE_HANDLER_SETTINGS L"handlerSettings"
|
||||||
#define CS_ASPNETCORE_HANDLER_VERSION L"handlerVersion"
|
#define CS_ASPNETCORE_HANDLER_VERSION L"handlerVersion"
|
||||||
#define CS_ASPNETCORE_DEBUG_FILE L"debugFile"
|
#define CS_ASPNETCORE_DEBUG_FILE L"debugFile"
|
||||||
|
#define CS_ASPNETCORE_FORWARD_RESPONSE_CONNECTION_HEADER L"forwardResponseConnectionHeader"
|
||||||
#define CS_ASPNETCORE_DEBUG_LEVEL L"debugLevel"
|
#define CS_ASPNETCORE_DEBUG_LEVEL L"debugLevel"
|
||||||
#define CS_ASPNETCORE_HANDLER_SETTINGS_NAME L"name"
|
#define CS_ASPNETCORE_HANDLER_SETTINGS_NAME L"name"
|
||||||
#define CS_ASPNETCORE_HANDLER_SETTINGS_VALUE L"value"
|
#define CS_ASPNETCORE_HANDLER_SETTINGS_VALUE L"value"
|
||||||
|
|
@ -40,6 +41,13 @@ public:
|
||||||
return FindKeyValuePair(pElement, CS_ASPNETCORE_DEBUG_LEVEL, strDebugFile);
|
return FindKeyValuePair(pElement, CS_ASPNETCORE_DEBUG_LEVEL, strDebugFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
HRESULT
|
||||||
|
FindForwardResponseConnectionHeader(IAppHostElement* pElement, STRU& strForwardResponseConnectionHeader)
|
||||||
|
{
|
||||||
|
return FindKeyValuePair(pElement, CS_ASPNETCORE_FORWARD_RESPONSE_CONNECTION_HEADER, strForwardResponseConnectionHeader);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static
|
static
|
||||||
HRESULT
|
HRESULT
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ FORWARDING_HANDLER::FORWARDING_HANDLER(
|
||||||
LOG_TRACE(L"FORWARDING_HANDLER::FORWARDING_HANDLER");
|
LOG_TRACE(L"FORWARDING_HANDLER::FORWARDING_HANDLER");
|
||||||
|
|
||||||
m_fWebSocketSupported = m_pApplication->QueryWebsocketStatus();
|
m_fWebSocketSupported = m_pApplication->QueryWebsocketStatus();
|
||||||
|
m_fForwardResponseConnectionHeader = m_pApplication->QueryConfig()->QueryForwardResponseConnectionHeader()->Equals(L"true", /* ignoreCase */ 1);
|
||||||
InitializeSRWLock(&m_RequestLock);
|
InitializeSRWLock(&m_RequestLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2212,10 +2213,14 @@ FORWARDING_HANDLER::SetStatusAndHeaders(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
__fallthrough;
|
__fallthrough;
|
||||||
case HttpHeaderConnection:
|
|
||||||
case HttpHeaderDate:
|
case HttpHeaderDate:
|
||||||
continue;
|
continue;
|
||||||
|
case HttpHeaderConnection:
|
||||||
|
if (!m_fForwardResponseConnectionHeader)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case HttpHeaderServer:
|
case HttpHeaderServer:
|
||||||
fServerHeaderPresent = TRUE;
|
fServerHeaderPresent = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ private:
|
||||||
HINTERNET m_hRequest;
|
HINTERNET m_hRequest;
|
||||||
FORWARDING_REQUEST_STATUS m_RequestStatus;
|
FORWARDING_REQUEST_STATUS m_RequestStatus;
|
||||||
|
|
||||||
|
BOOL m_fForwardResponseConnectionHeader;
|
||||||
BOOL m_fWebSocketEnabled;
|
BOOL m_fWebSocketEnabled;
|
||||||
BOOL m_fWebSocketSupported;
|
BOOL m_fWebSocketSupported;
|
||||||
BOOL m_fResponseHeadersReceivedAndSet;
|
BOOL m_fResponseHeadersReceivedAndSet;
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,12 @@ REQUESTHANDLER_CONFIG::Populate(
|
||||||
goto Finished;
|
goto Finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr = ConfigUtility::FindForwardResponseConnectionHeader(pAspNetCoreElement, m_struForwardResponseConnectionHeader);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
goto Finished;
|
||||||
|
}
|
||||||
|
|
||||||
Finished:
|
Finished:
|
||||||
|
|
||||||
if (pAspNetCoreElement != NULL)
|
if (pAspNetCoreElement != NULL)
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,12 @@ public:
|
||||||
return &m_struConfigPath;
|
return &m_struConfigPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STRU*
|
||||||
|
QueryForwardResponseConnectionHeader()
|
||||||
|
{
|
||||||
|
return &m_struForwardResponseConnectionHeader;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -249,6 +255,7 @@ protected:
|
||||||
STRU m_struApplicationPhysicalPath;
|
STRU m_struApplicationPhysicalPath;
|
||||||
STRU m_struApplicationVirtualPath;
|
STRU m_struApplicationVirtualPath;
|
||||||
STRU m_struConfigPath;
|
STRU m_struConfigPath;
|
||||||
|
STRU m_struForwardResponseConnectionHeader;
|
||||||
BOOL m_fStdoutLogEnabled;
|
BOOL m_fStdoutLogEnabled;
|
||||||
BOOL m_fForwardWindowsAuthToken;
|
BOOL m_fForwardWindowsAuthToken;
|
||||||
BOOL m_fDisableStartUpErrorPage;
|
BOOL m_fDisableStartUpErrorPage;
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,35 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
||||||
Assert.Equal("NOVALUE", await client.GetStringAsync("/HTTPS_PORT"));
|
Assert.Equal("NOVALUE", await client.GetStringAsync("/HTTPS_PORT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
[RequiresNewHandler]
|
||||||
|
[RequiresNewShim]
|
||||||
|
public async Task SetsConnectionCloseHeader()
|
||||||
|
{
|
||||||
|
// Only tests OutOfProcess as the Connection header is removed for out of process and not inprocess.
|
||||||
|
// This test checks a quirk to allow setting the Connection header.
|
||||||
|
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
|
||||||
|
|
||||||
|
deploymentParameters.HandlerSettings["forwardResponseConnectionHeader"] = "true";
|
||||||
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||||
|
|
||||||
|
var response = await deploymentResult.HttpClient.GetAsync("ConnectionClose");
|
||||||
|
Assert.Equal(true, response.Headers.ConnectionClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
[RequiresNewHandler]
|
||||||
|
[RequiresNewShim]
|
||||||
|
public async Task ConnectionCloseIsNotPropagated()
|
||||||
|
{
|
||||||
|
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
|
||||||
|
|
||||||
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||||
|
|
||||||
|
var response = await deploymentResult.HttpClient.GetAsync("ConnectionClose");
|
||||||
|
Assert.Null(response.Headers.ConnectionClose);
|
||||||
|
}
|
||||||
|
|
||||||
private static HttpClient CreateNonValidatingClient(IISDeploymentResult deploymentResult)
|
private static HttpClient CreateNonValidatingClient(IISDeploymentResult deploymentResult)
|
||||||
{
|
{
|
||||||
var handler = new HttpClientHandler
|
var handler = new HttpClientHandler
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,12 @@ namespace TestSite
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task ConnectionClose(HttpContext context)
|
||||||
|
{
|
||||||
|
context.Response.Headers["connection"] = "close";
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
public Task OverrideServer(HttpContext context)
|
public Task OverrideServer(HttpContext context)
|
||||||
{
|
{
|
||||||
context.Response.Headers["Server"] = "MyServer/7.8";
|
context.Response.Headers["Server"] = "MyServer/7.8";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue