Better fix

This commit is contained in:
Pavel Krymets 2018-03-22 13:14:20 -07:00
parent f6f5e575fb
commit e2e5a226c2
2 changed files with 5 additions and 11 deletions

View File

@ -68,8 +68,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
[DllImport(AspNetCoreModuleDll)]
internal unsafe static extern HttpApiTypes.HTTP_RESPONSE_V2* http_get_raw_response(IntPtr pInProcessHandler);
[DllImport(AspNetCoreModuleDll)]
public unsafe static extern void http_set_response_status_code(IntPtr pInProcessHandler, ushort statusCode, byte* pszReason);
[DllImport(AspNetCoreModuleDll, CharSet = CharSet.Ansi)]
public unsafe static extern void 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

@ -333,15 +333,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
{
// Verifies we have sent the statuscode before writing a header
var reasonPhrase = string.IsNullOrEmpty(ReasonPhrase) ? ReasonPhrases.GetReasonPhrase(StatusCode) : ReasonPhrase;
var reasonPhraseBytes = new byte [reasonPhrase.Length + 1];
Encoding.ASCII.GetBytes(reasonPhrase, 0, reasonPhrase.Length, reasonPhraseBytes, 0);
fixed (byte* pReasonPhrase = reasonPhraseBytes)
{
Debug.Assert((IntPtr)pReasonPhrase != IntPtr.Zero);
// This copies data into the underlying buffer
NativeMethods.http_set_response_status_code(_pInProcessHandler, (ushort)StatusCode, pReasonPhrase);
}
// 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)