5
5
using System . Threading ;
6
6
using System . Threading . Tasks ;
7
7
using System . Threading . Tasks . Sources ;
8
- using Microsoft . AspNetCore . Http ;
9
8
using Microsoft . AspNetCore . HttpSys . Internal ;
10
9
11
10
namespace Microsoft . AspNetCore . Server . HttpSys
@@ -14,6 +13,8 @@ internal unsafe class AsyncAcceptContext : IValueTaskSource<RequestContext>, IDi
14
13
{
15
14
private static readonly IOCompletionCallback IOCallback = IOWaitCallback ;
16
15
private readonly PreAllocatedOverlapped _preallocatedOverlapped ;
16
+ private readonly IRequestContextFactory _requestContextFactory ;
17
+
17
18
private NativeOverlapped * _overlapped ;
18
19
19
20
// mutable struct; do not make this readonly
@@ -24,7 +25,6 @@ internal unsafe class AsyncAcceptContext : IValueTaskSource<RequestContext>, IDi
24
25
} ;
25
26
26
27
private RequestContext _requestContext ;
27
- private readonly IRequestContextFactory _requestContextFactory ;
28
28
29
29
internal AsyncAcceptContext ( HttpSysListener server , IRequestContextFactory requestContextFactory )
30
30
{
@@ -55,7 +55,6 @@ internal ValueTask<RequestContext> AcceptAsync()
55
55
56
56
private static void IOCompleted ( AsyncAcceptContext asyncContext , uint errorCode , uint numBytes )
57
57
{
58
- var complete = false ;
59
58
// This is important to stash a ref to as it's a mutable struct
60
59
ref var mrvts = ref asyncContext . _mrvts ;
61
60
var requestContext = asyncContext . _requestContext ;
@@ -73,48 +72,18 @@ private static void IOCompleted(AsyncAcceptContext asyncContext, uint errorCode,
73
72
HttpSysListener server = asyncContext . Server ;
74
73
if ( errorCode == UnsafeNclNativeMethods . ErrorCodes . ERROR_SUCCESS )
75
74
{
76
- // at this point we have received an unmanaged HTTP_REQUEST and memoryBlob
77
- // points to it we need to hook up our authentication handling code here.
78
- try
79
- {
80
- if ( server . ValidateRequest ( requestContext ) && server . ValidateAuth ( requestContext ) )
81
- {
82
- // It's important that we clear the request context before we set the result
83
- // we want to reuse the acceptContext object for future accepts.
84
- asyncContext . _requestContext = null ;
75
+ // It's important that we clear the request context before we set the result
76
+ // we want to reuse the acceptContext object for future accepts.
77
+ asyncContext . _requestContext = null ;
85
78
86
- // Initialize features here once we're successfully validated the request
87
- // TODO: In the future defer this work to the thread pool so we can get off the IO thread
88
- // as quickly as possible
89
- requestContext . InitializeFeatures ( ) ;
90
-
91
- mrvts . SetResult ( requestContext ) ;
92
-
93
- complete = true ;
94
- }
95
- }
96
- catch ( Exception ex )
97
- {
98
- server . SendError ( requestId , StatusCodes . Status400BadRequest ) ;
99
- mrvts . SetException ( ex ) ;
100
- }
101
- finally
102
- {
103
- if ( ! complete )
104
- {
105
- asyncContext . AllocateNativeRequest ( size : requestContext . Size ) ;
106
- }
107
- }
79
+ mrvts . SetResult ( requestContext ) ;
108
80
}
109
81
else
110
82
{
111
83
// (uint)backingBuffer.Length - AlignmentPadding
112
84
asyncContext . AllocateNativeRequest ( numBytes , requestId ) ;
113
- }
114
85
115
- // We need to issue a new request, either because auth failed, or because our buffer was too small the first time.
116
- if ( ! complete )
117
- {
86
+ // We need to issue a new request, either because auth failed, or because our buffer was too small the first time.
118
87
uint statusCode = asyncContext . QueueBeginGetContext ( ) ;
119
88
120
89
if ( statusCode != UnsafeNclNativeMethods . ErrorCodes . ERROR_SUCCESS &&
0 commit comments