@@ -20,8 +20,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
20
20
{
21
21
internal sealed class Request
22
22
{
23
- private NativeRequestContext _nativeRequestContext ;
24
-
25
23
private X509Certificate2 _clientCert ;
26
24
// TODO: https://github.com/aspnet/HttpSysServer/issues/231
27
25
// private byte[] _providedTokenBindingId;
@@ -39,26 +37,25 @@ internal sealed class Request
39
37
40
38
private bool _isDisposed = false ;
41
39
42
- internal Request ( RequestContext requestContext , NativeRequestContext nativeRequestContext )
40
+ internal Request ( RequestContext requestContext )
43
41
{
44
42
// TODO: Verbose log
45
43
RequestContext = requestContext ;
46
- _nativeRequestContext = nativeRequestContext ;
47
44
_contentBoundaryType = BoundaryType . None ;
48
45
49
- RequestId = nativeRequestContext . RequestId ;
50
- UConnectionId = nativeRequestContext . ConnectionId ;
51
- SslStatus = nativeRequestContext . SslStatus ;
46
+ RequestId = requestContext . RequestId ;
47
+ UConnectionId = requestContext . ConnectionId ;
48
+ SslStatus = requestContext . SslStatus ;
52
49
53
- KnownMethod = nativeRequestContext . VerbId ;
54
- Method = _nativeRequestContext . GetVerb ( ) ;
50
+ KnownMethod = requestContext . VerbId ;
51
+ Method = requestContext . GetVerb ( ) ;
55
52
56
- RawUrl = nativeRequestContext . GetRawUrl ( ) ;
53
+ RawUrl = requestContext . GetRawUrl ( ) ;
57
54
58
- var cookedUrl = nativeRequestContext . GetCookedUrl ( ) ;
55
+ var cookedUrl = requestContext . GetCookedUrl ( ) ;
59
56
QueryString = cookedUrl . GetQueryString ( ) ?? string . Empty ;
60
57
61
- var rawUrlInBytes = _nativeRequestContext . GetRawUrlInBytes ( ) ;
58
+ var rawUrlInBytes = requestContext . GetRawUrlInBytes ( ) ;
62
59
var originalPath = RequestUriBuilder . DecodeAndUnescapePath ( rawUrlInBytes ) ;
63
60
64
61
PathBase = string . Empty ;
@@ -72,7 +69,7 @@ internal Request(RequestContext requestContext, NativeRequestContext nativeReque
72
69
}
73
70
else
74
71
{
75
- var prefix = requestContext . Server . Options . UrlPrefixes . GetPrefix ( ( int ) nativeRequestContext . UrlContext ) ;
72
+ var prefix = requestContext . Server . Options . UrlPrefixes . GetPrefix ( ( int ) requestContext . UrlContext ) ;
76
73
// Prefix may be null if the requested has been transfered to our queue
77
74
if ( ! ( prefix is null ) )
78
75
{
@@ -97,11 +94,11 @@ internal Request(RequestContext requestContext, NativeRequestContext nativeReque
97
94
}
98
95
}
99
96
100
- ProtocolVersion = _nativeRequestContext . GetVersion ( ) ;
97
+ ProtocolVersion = RequestContext . GetVersion ( ) ;
101
98
102
- Headers = new RequestHeaders ( _nativeRequestContext ) ;
99
+ Headers = new RequestHeaders ( RequestContext ) ;
103
100
104
- User = _nativeRequestContext . GetUser ( ) ;
101
+ User = RequestContext . GetUser ( ) ;
105
102
106
103
if ( IsHttps )
107
104
{
@@ -111,7 +108,7 @@ internal Request(RequestContext requestContext, NativeRequestContext nativeReque
111
108
// GetTlsTokenBindingInfo(); TODO: https://github.com/aspnet/HttpSysServer/issues/231
112
109
113
110
// Finished directly accessing the HTTP_REQUEST structure.
114
- _nativeRequestContext . ReleasePins ( ) ;
111
+ RequestContext . ReleasePins ( ) ;
115
112
// TODO: Verbose log parameters
116
113
}
117
114
@@ -222,7 +219,7 @@ private AspNetCore.HttpSys.Internal.SocketAddress RemoteEndPoint
222
219
{
223
220
if ( _remoteEndPoint == null )
224
221
{
225
- _remoteEndPoint = _nativeRequestContext . GetRemoteEndPoint ( ) ;
222
+ _remoteEndPoint = RequestContext . GetRemoteEndPoint ( ) ;
226
223
}
227
224
228
225
return _remoteEndPoint ;
@@ -235,7 +232,7 @@ private AspNetCore.HttpSys.Internal.SocketAddress LocalEndPoint
235
232
{
236
233
if ( _localEndPoint == null )
237
234
{
238
- _localEndPoint = _nativeRequestContext . GetLocalEndPoint ( ) ;
235
+ _localEndPoint = RequestContext . GetLocalEndPoint ( ) ;
239
236
}
240
237
241
238
return _localEndPoint ;
@@ -278,15 +275,15 @@ public IReadOnlyDictionary<int, ReadOnlyMemory<byte>> RequestInfo
278
275
{
279
276
if ( _requestInfo == null )
280
277
{
281
- _requestInfo = _nativeRequestContext . GetRequestInfo ( ) ;
278
+ _requestInfo = RequestContext . GetRequestInfo ( ) ;
282
279
}
283
280
return _requestInfo ;
284
281
}
285
282
}
286
283
287
284
private void GetTlsHandshakeResults ( )
288
285
{
289
- var handshake = _nativeRequestContext . GetTlsHandshake ( ) ;
286
+ var handshake = RequestContext . GetTlsHandshake ( ) ;
290
287
291
288
Protocol = handshake . Protocol ;
292
289
// The OS considers client and server TLS as different enum values. SslProtocols choose to combine those for some reason.
@@ -332,7 +329,7 @@ public X509Certificate2 ClientCertificate
332
329
{
333
330
try
334
331
{
335
- _clientCert = _nativeRequestContext . GetClientCertificate ( ) ;
332
+ _clientCert = RequestContext . GetClientCertificate ( ) ;
336
333
}
337
334
catch ( CryptographicException ce )
338
335
{
@@ -426,27 +423,22 @@ private unsafe void GetTlsTokenBindingInfo()
426
423
*/
427
424
internal uint GetChunks ( ref int dataChunkIndex , ref uint dataChunkOffset , byte [ ] buffer , int offset , int size )
428
425
{
429
- return _nativeRequestContext . GetChunks ( ref dataChunkIndex , ref dataChunkOffset , buffer , offset , size ) ;
426
+ return RequestContext . GetChunks ( ref dataChunkIndex , ref dataChunkOffset , buffer , offset , size ) ;
430
427
}
431
428
432
429
// should only be called from RequestContext
433
430
internal void Dispose ( )
434
431
{
435
- // TODO: Verbose log
436
- _isDisposed = true ;
437
- _nativeRequestContext . Dispose ( ) ;
438
- ( User ? . Identity as WindowsIdentity ) ? . Dispose ( ) ;
439
- if ( _nativeStream != null )
440
- {
441
- _nativeStream . Dispose ( ) ;
442
- }
443
- }
444
-
445
- private void CheckDisposed ( )
446
- {
447
- if ( _isDisposed )
432
+ if ( ! _isDisposed )
448
433
{
449
- throw new ObjectDisposedException ( this . GetType ( ) . FullName ) ;
434
+ // TODO: Verbose log
435
+ _isDisposed = true ;
436
+ RequestContext . Dispose ( ) ;
437
+ ( User ? . Identity as WindowsIdentity ) ? . Dispose ( ) ;
438
+ if ( _nativeStream != null )
439
+ {
440
+ _nativeStream . Dispose ( ) ;
441
+ }
450
442
}
451
443
}
452
444
0 commit comments