Return HRESULT

This commit is contained in:
Pavel Krymets 2018-03-22 14:01:00 -07:00
parent e2e5a226c2
commit 1686a71046
4 changed files with 8 additions and 6 deletions

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
internal unsafe static extern HttpApiTypes.HTTP_RESPONSE_V2* http_get_raw_response(IntPtr pInProcessHandler);
[DllImport(AspNetCoreModuleDll, CharSet = CharSet.Ansi)]
public unsafe static extern void http_set_response_status_code(IntPtr pInProcessHandler, ushort statusCode, string pszReason);
public unsafe static extern int http_set_response_status_code(IntPtr pInProcessHandler, ushort statusCode, string pszReason);
[DllImport(AspNetCoreModuleDll)]
public unsafe static extern int http_read_request_bytes(IntPtr pInProcessHandler, byte* pvBuffer, int cbBuffer, out int dwBytesReceived, out bool fCompletionExpected);

View File

@ -336,7 +336,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
// This copies data into the underlying buffer
NativeMethods.http_set_response_status_code(_pInProcessHandler, (ushort)StatusCode, reasonPhrase);
HttpResponseHeaders.IsReadOnly = true;
foreach (var headerPair in HttpResponseHeaders)
{

View File

@ -74,13 +74,15 @@ Finished:
return hr;
}
EXTERN_C __MIDL_DECLSPEC_DLLEXPORT VOID http_set_response_status_code(
EXTERN_C __MIDL_DECLSPEC_DLLEXPORT
HRESULT
http_set_response_status_code(
_In_ IN_PROCESS_HANDLER* pInProcessHandler,
_In_ USHORT statusCode,
_In_ PCSTR pszReason
)
{
pInProcessHandler->QueryHttpContext()->GetResponse()->SetStatus(statusCode, pszReason);
return pInProcessHandler->QueryHttpContext()->GetResponse()->SetStatus(statusCode, pszReason);
}
EXTERN_C __MIDL_DECLSPEC_DLLEXPORT

View File

@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
}
[ConditionalFact]
public async Task ErrorCodeIsSetForExceoptionDuringRequest()
public async Task ErrorCodeIsSetForExceptionDuringRequest()
{
var response = await _fixture.Client.GetAsync("Throw");
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
}
[ConditionalTheory]
[InlineData(1, "custom", "custom")]
[InlineData(200, "custom", "custom")]
[InlineData(500, "", "Internal Server Error")]
[InlineData(999, "", "")]
public async Task CustomErrorCodeWorks(int code, string reason, string expectedReason)