What about now?
This commit is contained in:
parent
80e799d17c
commit
ee2e46a614
|
|
@ -1,8 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core components for working with the IIS AspNetCoreModule.</Description>
|
||||
<TargetFrameworks>netstandard2.0;netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>aspnetcore;iis</PackageTags>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
|
||||
protected readonly IntPtr _pInProcessHandler;
|
||||
|
||||
private readonly IISOptions _options;
|
||||
|
||||
private bool _reading; // To know whether we are currently in a read operation.
|
||||
private volatile bool _hasResponseStarted;
|
||||
|
||||
|
|
@ -62,13 +64,45 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
internal unsafe IISHttpContext(MemoryPool<byte> memoryPool, IntPtr pInProcessHandler, IISOptions options, IISHttpServer server)
|
||||
: base((HttpApiTypes.HTTP_REQUEST*)NativeMethods.HttpGetRawRequest(pInProcessHandler))
|
||||
{
|
||||
_thisHandle = GCHandle.Alloc(this);
|
||||
|
||||
_memoryPool = memoryPool;
|
||||
_pInProcessHandler = pInProcessHandler;
|
||||
_options = options;
|
||||
_server = server;
|
||||
}
|
||||
|
||||
public Version HttpVersion { get; set; }
|
||||
public string Scheme { get; set; }
|
||||
public string Method { get; set; }
|
||||
public string PathBase { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string QueryString { get; set; }
|
||||
public string RawTarget { get; set; }
|
||||
public CancellationToken RequestAborted { get; set; }
|
||||
public bool HasResponseStarted => _hasResponseStarted;
|
||||
public IPAddress RemoteIpAddress { get; set; }
|
||||
public int RemotePort { get; set; }
|
||||
public IPAddress LocalIpAddress { get; set; }
|
||||
public int LocalPort { get; set; }
|
||||
public string RequestConnectionId { get; set; }
|
||||
public string TraceIdentifier { get; set; }
|
||||
public ClaimsPrincipal User { get; set; }
|
||||
internal WindowsPrincipal WindowsUser { get; set; }
|
||||
public Stream RequestBody { get; set; }
|
||||
public Stream ResponseBody { get; set; }
|
||||
public Pipe Input { get; set; }
|
||||
public OutputProducer Output { get; set; }
|
||||
|
||||
public IHeaderDictionary RequestHeaders { get; set; }
|
||||
public IHeaderDictionary ResponseHeaders { get; set; }
|
||||
private HeaderCollection HttpResponseHeaders { get; set; }
|
||||
internal HttpApiTypes.HTTP_VERB KnownMethod { get; private set; }
|
||||
|
||||
protected void InitializeContext()
|
||||
{
|
||||
_thisHandle = GCHandle.Alloc(this);
|
||||
|
||||
NativeMethods.HttpSetManagedContext(_pInProcessHandler, (IntPtr)_thisHandle);
|
||||
|
||||
NativeMethods.HttpSetManagedContext(pInProcessHandler, (IntPtr)_thisHandle);
|
||||
Method = GetVerb();
|
||||
|
||||
RawTarget = GetRawUrl();
|
||||
|
|
@ -100,10 +134,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
HttpResponseHeaders = new HeaderCollection();
|
||||
ResponseHeaders = HttpResponseHeaders;
|
||||
|
||||
if (options.ForwardWindowsAuthentication)
|
||||
if (_options.ForwardWindowsAuthentication)
|
||||
{
|
||||
WindowsUser = GetWindowsPrincipal();
|
||||
if (options.AutomaticAuthentication)
|
||||
if (_options.AutomaticAuthentication)
|
||||
{
|
||||
User = WindowsUser;
|
||||
}
|
||||
|
|
@ -111,7 +145,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
|
||||
ResetFeatureCollection();
|
||||
|
||||
if (!_server.IsWebSocketAvailible(pInProcessHandler))
|
||||
if (!_server.IsWebSocketAvailible(_pInProcessHandler))
|
||||
{
|
||||
_currentIHttpUpgradeFeature = null;
|
||||
}
|
||||
|
|
@ -130,33 +164,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
Output = new OutputProducer(pipe);
|
||||
}
|
||||
|
||||
public Version HttpVersion { get; set; }
|
||||
public string Scheme { get; set; }
|
||||
public string Method { get; set; }
|
||||
public string PathBase { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string QueryString { get; set; }
|
||||
public string RawTarget { get; set; }
|
||||
public CancellationToken RequestAborted { get; set; }
|
||||
public bool HasResponseStarted => _hasResponseStarted;
|
||||
public IPAddress RemoteIpAddress { get; set; }
|
||||
public int RemotePort { get; set; }
|
||||
public IPAddress LocalIpAddress { get; set; }
|
||||
public int LocalPort { get; set; }
|
||||
public string RequestConnectionId { get; set; }
|
||||
public string TraceIdentifier { get; set; }
|
||||
public ClaimsPrincipal User { get; set; }
|
||||
internal WindowsPrincipal WindowsUser { get; set; }
|
||||
public Stream RequestBody { get; set; }
|
||||
public Stream ResponseBody { get; set; }
|
||||
public Pipe Input { get; set; }
|
||||
public OutputProducer Output { get; set; }
|
||||
|
||||
public IHeaderDictionary RequestHeaders { get; set; }
|
||||
public IHeaderDictionary ResponseHeaders { get; set; }
|
||||
private HeaderCollection HttpResponseHeaders { get; set; }
|
||||
internal HttpApiTypes.HTTP_VERB KnownMethod { get; }
|
||||
|
||||
public int StatusCode
|
||||
{
|
||||
get { return _statusCode; }
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
|
||||
public override async Task<bool> ProcessRequestAsync()
|
||||
{
|
||||
InitializeContext();
|
||||
|
||||
var context = default(TContext);
|
||||
var success = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -144,21 +144,15 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
|||
var server = (IISHttpServer)GCHandle.FromIntPtr(pvRequestContext).Target;
|
||||
Interlocked.Increment(ref server._outstandingRequests);
|
||||
|
||||
#if NETCOREAPP2_1
|
||||
ThreadPool.QueueUserWorkItem<(IISHttpServer, IntPtr)>(
|
||||
state => _ = HandleRequest(state.Item1, state.Item2),
|
||||
(server, pInProcessHandler),
|
||||
preferLocal: false);
|
||||
#else
|
||||
ThreadPool.QueueUserWorkItem(
|
||||
state => _ = HandleRequest(server, pInProcessHandler));
|
||||
#endif
|
||||
var context = server._iisContextFactory.CreateHttpContext(pInProcessHandler);
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state => _ = HandleRequest((IISHttpContext)state), context);
|
||||
|
||||
return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING;
|
||||
}
|
||||
|
||||
private static async Task HandleRequest(IISHttpServer server, IntPtr handler)
|
||||
private static async Task HandleRequest(IISHttpContext context)
|
||||
{
|
||||
var context = server._iisContextFactory.CreateHttpContext(handler);
|
||||
var result = await context.ProcessRequestAsync();
|
||||
CompleteRequest(context, result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue