Migrate to netcoreapp2.0
This commit is contained in:
parent
fdfc8c01d1
commit
31001de66a
|
|
@ -3,7 +3,7 @@
|
|||
<Import Project="..\..\build\dependencies.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@ namespace HotAddSample
|
|||
|
||||
public HttpSysOptions ServerOptions { get; set; }
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
loggerfactory.AddConsole(LogLevel.Information);
|
||||
|
||||
var addresses = ServerOptions.UrlPrefixes;
|
||||
addresses.Add("http://localhost:12346/pathBase/");
|
||||
|
||||
|
|
@ -101,6 +99,7 @@ namespace HotAddSample
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.ConfigureLogging(factory => factory.AddConsole())
|
||||
.UseStartup<Startup>()
|
||||
.UseHttpSys()
|
||||
.Build();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<Import Project="..\..\build\dependencies.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -20,10 +20,8 @@ namespace SelfHostServer
|
|||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
loggerfactory.AddConsole(LogLevel.Debug);
|
||||
|
||||
app.Run(async context =>
|
||||
{
|
||||
context.Response.ContentType = "text/plain";
|
||||
|
|
@ -34,6 +32,7 @@ namespace SelfHostServer
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.ConfigureLogging(factory => factory.AddConsole())
|
||||
.UseStartup<Startup>()
|
||||
.UseHttpSys(options =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,13 +25,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
: base(errorCode, message)
|
||||
{
|
||||
}
|
||||
#if NETSTANDARD1_3
|
||||
public int ErrorCode
|
||||
#else
|
||||
|
||||
// the base class returns the HResult with this property
|
||||
// we need the Win32 Error Code, hence the override.
|
||||
public override int ErrorCode
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core HTTP server that uses the Windows HTTP Server API.</Description>
|
||||
<TargetFrameworks>net46;netstandard1.3</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
|
@ -13,13 +13,9 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.RuntimeEnvironment.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="System.Threading.Overlapped" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="$(CoreFxVersion)" />
|
||||
<PackageReference Include="System.Security.Principal.Windows" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,20 +3,11 @@
|
|||
|
||||
namespace Microsoft.AspNetCore.Server.HttpSys
|
||||
{
|
||||
#if NET46
|
||||
/// <devdoc>
|
||||
/// <para>
|
||||
/// Specifies the address families that an instance of the <see cref="System.Net.Sockets.Socket"/>
|
||||
/// class can use.
|
||||
/// </para>
|
||||
/// </devdoc>
|
||||
#else
|
||||
/// <devdoc>
|
||||
/// <para>
|
||||
/// Specifies the address families.
|
||||
/// </para>
|
||||
/// </devdoc>
|
||||
#endif
|
||||
internal enum AddressFamily
|
||||
{
|
||||
/// <devdoc>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
internal static class ComNetOS
|
||||
{
|
||||
// Windows is assumed based on HttpApi.Supported which is checked in the HttpSysListener constructor.
|
||||
// Minimum support for Windows 7 is assumed.
|
||||
internal static readonly bool IsWin8orLater;
|
||||
|
||||
|
|
@ -15,11 +16,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
var win8Version = new Version(6, 2);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
IsWin8orLater = (new Version(RuntimeEnvironment.OperatingSystemVersion) >= win8Version);
|
||||
#else
|
||||
IsWin8orLater = (Environment.OSVersion.Version >= win8Version);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,13 @@ using System.Diagnostics;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
#if !NETSTANDARD1_3
|
||||
using Microsoft.Win32;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.HttpSys
|
||||
{
|
||||
internal static class HttpSysSettings
|
||||
{
|
||||
#if !NETSTANDARD1_3
|
||||
private const string HttpSysParametersKey = @"System\CurrentControlSet\Services\HTTP\Parameters";
|
||||
#endif
|
||||
private const bool EnableNonUtf8Default = true;
|
||||
private const bool FavorUtf8Default = true;
|
||||
private const string EnableNonUtf8Name = "EnableNonUtf8";
|
||||
|
|
@ -41,10 +37,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
|
||||
private static void ReadHttpSysRegistrySettings()
|
||||
#if NETSTANDARD1_3
|
||||
{
|
||||
}
|
||||
#else
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -117,6 +109,5 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
// TODO: log
|
||||
// Logging.PrintWarning(Logging.HttpListener, typeof(HttpSysSettings), methodName, SR.GetString(message, args));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
get
|
||||
{
|
||||
return Environment.HasShutdownStarted
|
||||
#if !NETSTANDARD1_3
|
||||
|| AppDomain.CurrentDomain.IsFinalizingForUnload()
|
||||
#endif
|
||||
;
|
||||
|| AppDomain.CurrentDomain.IsFinalizingForUnload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
internal static unsafe class UnsafeNclNativeMethods
|
||||
{
|
||||
#if NETSTANDARD1_3
|
||||
private const string sspicli_LIB = "sspicli.dll";
|
||||
private const string api_ms_win_core_processthreads_LIB = "api-ms-win-core-processthreads-l1-1-1.dll";
|
||||
private const string api_ms_win_core_io_LIB = "api-ms-win-core-io-l1-1-0.dll";
|
||||
|
|
@ -18,10 +17,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
private const string api_ms_win_core_heap_LIB = "api-ms-win-core-heap-L1-2-0.dll";
|
||||
private const string api_ms_win_core_heap_obsolete_LIB = "api-ms-win-core-heap-obsolete-L1-1-0.dll";
|
||||
private const string api_ms_win_core_kernel32_legacy_LIB = "api-ms-win-core-kernel32-legacy-l1-1-0.dll";
|
||||
#else
|
||||
private const string KERNEL32 = "kernel32.dll";
|
||||
private const string SECUR32 = "secur32.dll";
|
||||
#endif
|
||||
|
||||
private const string TOKENBINDING = "tokenbinding.dll";
|
||||
|
||||
// CONSIDER: Make this an enum, requires changing a lot of types from uint to ErrorCodes.
|
||||
|
|
@ -39,18 +35,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
internal const uint ERROR_CONNECTION_INVALID = 1229;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_io_LIB, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
#endif
|
||||
internal static unsafe extern uint CancelIoEx(SafeHandle handle, SafeNativeOverlapped overlapped);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_kernel32_legacy_LIB, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
#endif
|
||||
internal static unsafe extern bool SetFileCompletionNotificationModes(SafeHandle handle, FileCompletionNotificationModes modes);
|
||||
|
||||
[Flags]
|
||||
|
|
@ -71,19 +59,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
[Out] out HeapAllocHandle resultList);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa366569(v=vs.85).aspx
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_heap_LIB, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
#endif
|
||||
internal static extern IntPtr GetProcessHeap();
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa366701(v=vs.85).aspx
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_heap_LIB, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
#endif
|
||||
internal static extern bool HeapFree(
|
||||
[In] IntPtr hHeap,
|
||||
[In] uint dwFlags,
|
||||
|
|
@ -91,34 +71,17 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
|
||||
internal static class SafeNetHandles
|
||||
{
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(sspicli_LIB, ExactSpelling = true, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(SECUR32, ExactSpelling = true, SetLastError = true)]
|
||||
#endif
|
||||
internal static extern int FreeContextBuffer(
|
||||
[In] IntPtr contextBuffer);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_handle_LIB, ExactSpelling = true, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)]
|
||||
#endif
|
||||
internal static extern bool CloseHandle(IntPtr handle);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_heap_obsolete_LIB, EntryPoint = "LocalAlloc", SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, EntryPoint = "LocalAlloc", SetLastError = true)]
|
||||
#endif
|
||||
|
||||
internal static extern SafeLocalFreeChannelBinding LocalAllocChannelBinding(int uFlags, UIntPtr sizetdwBytes);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
[DllImport(api_ms_win_core_heap_obsolete_LIB, ExactSpelling = true, SetLastError = true)]
|
||||
#else
|
||||
[DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)]
|
||||
#endif
|
||||
internal static extern IntPtr LocalFree(IntPtr handle);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
return _requestStream.ReadByte();
|
||||
}
|
||||
#if !NETSTANDARD1_3
|
||||
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return _requestStream.BeginRead(buffer, offset, count, callback, state);
|
||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
return _requestStream.EndRead(asyncResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return _requestStream.ReadAsync(buffer, offset, count, cancellationToken);
|
||||
|
|
@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
_responseStream.WriteByte(value);
|
||||
}
|
||||
#if !NETSTANDARD1_3
|
||||
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return _responseStream.BeginWrite(buffer, offset, count, callback, state);
|
||||
|
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
_responseStream.EndWrite(asyncResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return _responseStream.WriteAsync(buffer, offset, count, cancellationToken);
|
||||
|
|
|
|||
|
|
@ -190,11 +190,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
public unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
|
||||
#else
|
||||
public override unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
|
||||
#endif
|
||||
{
|
||||
ValidateReadBuffer(buffer, offset, size);
|
||||
if (_closed)
|
||||
|
|
@ -281,11 +277,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
return asyncResult;
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
public int EndRead(IAsyncResult asyncResult)
|
||||
#else
|
||||
public override int EndRead(IAsyncResult asyncResult)
|
||||
#endif
|
||||
{
|
||||
if (asyncResult == null)
|
||||
{
|
||||
|
|
@ -416,20 +408,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
throw new InvalidOperationException(Resources.Exception_ReadOnlyStream);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
public IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
|
||||
#else
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
|
||||
#endif
|
||||
{
|
||||
throw new InvalidOperationException(Resources.Exception_ReadOnlyStream);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
public void EndWrite(IAsyncResult asyncResult)
|
||||
#else
|
||||
public override void EndWrite(IAsyncResult asyncResult)
|
||||
#endif
|
||||
{
|
||||
throw new InvalidOperationException(Resources.Exception_ReadOnlyStream);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,7 +374,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
throw new InvalidOperationException(Resources.Exception_WriteOnlyStream);
|
||||
}
|
||||
|
||||
#if !NETSTANDARD1_3
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new InvalidOperationException(Resources.Exception_WriteOnlyStream);
|
||||
|
|
@ -384,7 +383,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
throw new InvalidOperationException(Resources.Exception_WriteOnlyStream);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -477,19 +475,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
public IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
#else
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
#endif
|
||||
{
|
||||
return WriteAsync(buffer, offset, count).ToIAsyncResult(callback, state);
|
||||
}
|
||||
#if NETSTANDARD1_3
|
||||
public void EndWrite(IAsyncResult asyncResult)
|
||||
#else
|
||||
|
||||
public override void EndWrite(IAsyncResult asyncResult)
|
||||
#endif
|
||||
{
|
||||
if (asyncResult == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
|
||||
public override int Read(byte[] buffer, int offset, int count) => _innerStream.Read(buffer, offset, count);
|
||||
|
||||
#if !NETSTANDARD1_3
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return _innerStream.BeginRead(buffer, offset, count, callback, state);
|
||||
|
|
@ -49,7 +48,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
return _innerStream.EndRead(asyncResult);
|
||||
}
|
||||
#endif
|
||||
public override void Flush()
|
||||
{
|
||||
_onStart().GetAwaiter().GetResult();
|
||||
|
|
@ -73,19 +71,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
await _onStart();
|
||||
await _innerStream.WriteAsync(buffer, offset, count, cancellationToken);
|
||||
}
|
||||
#if NETSTANDARD1_3
|
||||
public IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
#else
|
||||
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
#endif
|
||||
{
|
||||
return ToIAsyncResult(WriteAsync(buffer, offset, count), callback, state);
|
||||
}
|
||||
#if NETSTANDARD1_3
|
||||
public void EndWrite(IAsyncResult asyncResult)
|
||||
#else
|
||||
|
||||
public override void EndWrite(IAsyncResult asyncResult)
|
||||
#endif
|
||||
{
|
||||
if (asyncResult == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
|
||||
namespace Microsoft.Win32.SafeHandles
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Class of critical handle which uses 0 or -1 as an invalid handle.
|
||||
[System.Security.SecurityCritical] // auto-generated_required
|
||||
internal abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle
|
||||
{
|
||||
protected CriticalHandleZeroOrMinusOneIsInvalid()
|
||||
: base(IntPtr.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
[System.Security.SecurityCritical]
|
||||
get { return handle == new IntPtr(0) || handle == new IntPtr(-1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
|
||||
namespace Microsoft.Win32.SafeHandles
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Class of safe handle which uses 0 or -1 as an invalid handle.
|
||||
[System.Security.SecurityCritical] // auto-generated_required
|
||||
internal abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle
|
||||
{
|
||||
protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle)
|
||||
: base(IntPtr.Zero, ownsHandle)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
[System.Security.SecurityCritical]
|
||||
get { return handle == new IntPtr(0) || handle == new IntPtr(-1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -41,12 +41,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthType_RequireAuth_ChallengesAdded(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
@ -61,12 +60,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthType_AllowAnonymousButSpecify401_ChallengesAdded(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
@ -85,8 +83,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded()
|
||||
{
|
||||
string address;
|
||||
|
|
@ -285,13 +282,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationSchemes.Digest)]
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[InlineData(AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthTypes_ChallengeWithoutAuthTypes_AllChallengesSent(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
@ -310,13 +306,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationSchemes.Digest)]
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[InlineData(AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthTypes_ChallengeWithAllAuthTypes_AllChallengesSent(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
@ -338,12 +333,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationSchemes.Digest)]
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthTypes_ChallengeOneAuthType_OneChallengeSent(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
|
|||
|
|
@ -102,13 +102,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
private async Task<string> SendRequestAsync(string uri,
|
||||
X509Certificate cert = null)
|
||||
{
|
||||
#if NET46
|
||||
var handler = new WebRequestHandler();
|
||||
#elif NETCOREAPP2_0
|
||||
var handler = new WinHttpHandler();
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
handler.ServerCertificateValidationCallback = (a, b, c, d) => true;
|
||||
if (cert != null)
|
||||
{
|
||||
|
|
@ -122,13 +116,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
|
||||
private async Task<string> SendRequestAsync(string uri, string upload)
|
||||
{
|
||||
#if NET46
|
||||
var handler = new WebRequestHandler();
|
||||
#elif NETCOREAPP2_0
|
||||
var handler = new WinHttpHandler();
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
handler.ServerCertificateValidationCallback = (a, b, c, d) => true;
|
||||
using (HttpClient client = new HttpClient(handler))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,12 +41,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationType.Digest)] // TODO: Not implemented
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthType_RequireAuth_ChallengesAdded(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
@ -61,12 +60,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
[InlineData(AuthenticationSchemes.Negotiate)]
|
||||
[InlineData(AuthenticationSchemes.NTLM)]
|
||||
// [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented
|
||||
[InlineData(AuthenticationSchemes.Basic)]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
public async Task AuthType_AllowAnonymousButSpecify401_ChallengesAdded(AuthenticationSchemes authType)
|
||||
{
|
||||
string address;
|
||||
|
|
@ -87,8 +85,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")]
|
||||
[ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")]
|
||||
public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded()
|
||||
{
|
||||
string address;
|
||||
|
|
@ -169,8 +166,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[SkipOffDomain]
|
||||
[ConditionalFact(Skip = "Requires a domain joined machine - https://github.com/aspnet/HttpSysServer/issues/357")]
|
||||
public async Task AuthTypes_RequireKerberosAuth_Success()
|
||||
{
|
||||
string address;
|
||||
|
|
@ -189,8 +185,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
}
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[SkipOffDomain]
|
||||
[ConditionalFact(Skip = "Requires a domain joined machine - https://github.com/aspnet/HttpSysServer/issues/357")]
|
||||
public async Task MultipleAuthTypes_KerberosAllowAnonymousButSpecify401_ChallengesAdded()
|
||||
{
|
||||
string address;
|
||||
|
|
|
|||
|
|
@ -109,13 +109,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
private async Task<string> SendRequestAsync(string uri,
|
||||
X509Certificate cert = null)
|
||||
{
|
||||
#if NET46
|
||||
WebRequestHandler handler = new WebRequestHandler();
|
||||
#elif NETCOREAPP2_0
|
||||
WinHttpHandler handler = new WinHttpHandler();
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
handler.ServerCertificateValidationCallback = (a, b, c, d) => true;
|
||||
if (cert != null)
|
||||
{
|
||||
|
|
@ -129,13 +123,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
|
||||
private async Task<string> SendRequestAsync(string uri, string upload)
|
||||
{
|
||||
#if NET46
|
||||
WebRequestHandler handler = new WebRequestHandler();
|
||||
#elif NETCOREAPP2_0
|
||||
WinHttpHandler handler = new WinHttpHandler();
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
handler.ServerCertificateValidationCallback = (a, b, c, d) => true;
|
||||
using (HttpClient client = new HttpClient(handler))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
Assert.Equal("Hello World", response);
|
||||
}
|
||||
}
|
||||
#if NET46
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task RequestBody_ReadBeginEnd_Success()
|
||||
{
|
||||
|
|
@ -72,10 +72,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
Assert.Equal("Hello World", response);
|
||||
}
|
||||
}
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task RequestBody_InvalidBuffer_ArgumentException()
|
||||
|
|
|
|||
|
|
@ -98,13 +98,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
var context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
context.Response.Headers["Content-lenGth"] = " 30 ";
|
||||
var stream = context.Response.Body;
|
||||
#if NET46
|
||||
stream.EndWrite(stream.BeginWrite(new byte[10], 0, 10, null, null));
|
||||
#elif NETCOREAPP2_0
|
||||
await stream.WriteAsync(new byte[10], 0, 10);
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
stream.Write(new byte[10], 0, 10);
|
||||
await stream.WriteAsync(new byte[10], 0, 10);
|
||||
context.Dispose();
|
||||
|
|
@ -131,15 +125,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
var context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
context.Response.Headers["Content-lenGth"] = " 20 ";
|
||||
context.Dispose();
|
||||
#if NET46
|
||||
// HttpClient retries the request because it didn't get a response.
|
||||
context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
context.Response.Headers["Content-lenGth"] = " 20 ";
|
||||
context.Dispose();
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
|
||||
}
|
||||
}
|
||||
|
|
@ -287,19 +273,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#if NET46
|
||||
// .NET 4.5 HttpClient automatically retries a request if it does not get a response.
|
||||
context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
// First write sends headers
|
||||
writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
|
||||
}
|
||||
}
|
||||
|
|
@ -319,19 +293,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#if NET46
|
||||
// .NET 4.5 HttpClient automatically retries a request if it does not get a response.
|
||||
context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
// First write sends headers
|
||||
writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,13 +221,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
Assert.Equal(0, response.ContentLength);
|
||||
Assert.NotNull(response.Headers["Date"]);
|
||||
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]);
|
||||
#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR.
|
||||
// WebHeaderCollection.GetValues() not available in CoreCLR.
|
||||
Assert.Equal("custom1, and custom2, custom3", response.Headers["WWW-Authenticate"]);
|
||||
#elif NET46
|
||||
Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("WWW-Authenticate"));
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,13 +247,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
Assert.Equal(0, response.ContentLength);
|
||||
Assert.NotNull(response.Headers["Date"]);
|
||||
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]);
|
||||
#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR.
|
||||
// WebHeaderCollection.GetValues() not available in CoreCLR.
|
||||
Assert.Equal("custom1, and custom2, custom3", response.Headers["Custom-Header1"]);
|
||||
#elif NET46
|
||||
Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("Custom-Header1"));
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -362,19 +362,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#if NET46
|
||||
// .NET 4.5 HttpClient automatically retries a request if it does not get a response.
|
||||
context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
// First write sends headers
|
||||
writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
|
||||
}
|
||||
}
|
||||
|
|
@ -394,19 +382,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#if NET46
|
||||
// .NET 4.5 HttpClient automatically retries a request if it does not get a response.
|
||||
context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
// First write sends headers
|
||||
writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token);
|
||||
Assert.True(writeTask.IsCanceled);
|
||||
context.Dispose();
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,14 +186,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
context.Abort();
|
||||
Assert.True(canceled.WaitOne(interval), "Aborted");
|
||||
Assert.True(ct.IsCancellationRequested, "IsCancellationRequested");
|
||||
#if NET46
|
||||
// HttpClient re-tries the request because it doesn't know if the request was received.
|
||||
context = await server.AcceptAsync(Utilities.DefaultTimeout);
|
||||
context.Abort();
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
||||
{
|
||||
/// <summary>
|
||||
/// Skips an auth test if the machine is not joined to a Windows domain.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public class SkipOffDomainAttribute : Attribute, ITestCondition
|
||||
{
|
||||
public bool IsMet
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
#if NET46
|
||||
return !string.IsNullOrEmpty(System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().Name);
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string SkipReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Machine is not joined to a domain.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,13 +24,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
|
|||
static Utilities()
|
||||
{
|
||||
var win8Version = new Version(6, 2);
|
||||
#if NET46
|
||||
IsWin8orLater = (Environment.OSVersion.Version >= win8Version);
|
||||
#elif NETCOREAPP2_0
|
||||
IsWin8orLater = (new Version(RuntimeEnvironment.OperatingSystemVersion) >= win8Version);
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static HttpSysListener CreateHttpAuthServer(AuthenticationSchemes authScheme, bool allowAnonymos, out string baseAddress)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal("Hello World", response);
|
||||
}
|
||||
}
|
||||
#if NET46
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task RequestBody_ReadBeginEnd_Success()
|
||||
{
|
||||
|
|
@ -68,10 +68,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal("Hello World", response);
|
||||
}
|
||||
}
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task RequestBody_InvalidBuffer_ArgumentException()
|
||||
|
|
|
|||
|
|
@ -87,13 +87,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
httpContext.Response.Headers["Content-lenGth"] = " 30 ";
|
||||
Stream stream = httpContext.Response.Body;
|
||||
#if NET46
|
||||
stream.EndWrite(stream.BeginWrite(new byte[10], 0, 10, null, null));
|
||||
#elif NETCOREAPP2_0
|
||||
await stream.WriteAsync(new byte[10], 0, 10);
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
stream.Write(new byte[10], 0, 10);
|
||||
await stream.WriteAsync(new byte[10], 0, 10);
|
||||
}))
|
||||
|
|
@ -223,7 +217,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal(new byte[10], await response.Content.ReadAsByteArrayAsync());
|
||||
}
|
||||
}
|
||||
#if NET46
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task ResponseBody_BeginWrite_TriggersOnStarting()
|
||||
{
|
||||
|
|
@ -251,10 +245,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal(new byte[10], await response.Content.ReadAsByteArrayAsync());
|
||||
}
|
||||
}
|
||||
#elif NETCOREAPP2_0
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task ResponseBody_WriteAsync_TriggersOnStarting()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,13 +81,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal(0, response.ContentLength);
|
||||
Assert.NotNull(response.Headers["Date"]);
|
||||
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]);
|
||||
#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR.
|
||||
Assert.Equal("custom1, and custom2, custom3", response.Headers["WWW-Authenticate"]);
|
||||
#elif NET46
|
||||
Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("WWW-Authenticate"));
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,13 +105,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Assert.Equal(0, response.ContentLength);
|
||||
Assert.NotNull(response.Headers["Date"]);
|
||||
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]);
|
||||
#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR.
|
||||
Assert.Equal("custom1, and custom2, custom3", response.Headers["Custom-Header1"]);
|
||||
#elif NET46
|
||||
Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("Custom-Header1"));
|
||||
#else
|
||||
#error Target framework needs to be updated
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue