@@ -34,6 +34,13 @@ internal partial class Http1Connection : HttpProtocol, IRequestProcessor
34
34
private HttpRequestTarget _requestTargetForm = HttpRequestTarget . Unknown ;
35
35
private Uri _absoluteRequestTarget ;
36
36
37
+ // The _parsed fields cache the Path, QueryString, RawTarget, and/or _absoluteRequestTarget
38
+ // from the previous request when DisableStringReuse is false.
39
+ private string _parsedPath = null ;
40
+ private string _parsedQueryString = null ;
41
+ private string _parsedRawTarget = null ;
42
+ private Uri _parsedAbsoluteRequestTarget ;
43
+
37
44
private int _remainingRequestHeadersBytesAllowed ;
38
45
39
46
public Http1Connection ( HttpConnectionContext context )
@@ -337,6 +344,7 @@ private void OnOriginFormTarget(bool pathEncoded, Span<byte> target, Span<byte>
337
344
// Clear parsedData as we won't check it if we come via this path again,
338
345
// an setting to null is fast as it doesn't need to use a GC write barrier.
339
346
_parsedRawTarget = _parsedPath = _parsedQueryString = null ;
347
+ _parsedAbsoluteRequestTarget = null ;
340
348
return ;
341
349
}
342
350
@@ -389,6 +397,10 @@ private void OnOriginFormTarget(bool pathEncoded, Span<byte> target, Span<byte>
389
397
Path = _parsedPath ;
390
398
QueryString = _parsedQueryString ;
391
399
}
400
+
401
+ // Clear parsedData for absolute target as we won't check it if we come via this path again,
402
+ // an setting to null is fast as it doesn't need to use a GC write barrier.
403
+ _parsedAbsoluteRequestTarget = null ;
392
404
}
393
405
catch ( InvalidOperationException )
394
406
{
@@ -441,9 +453,10 @@ private void OnAuthorityFormTarget(HttpMethod method, Span<byte> target)
441
453
442
454
Path = string . Empty ;
443
455
QueryString = string . Empty ;
444
- // Clear parsedData for path and queryString as we won't check it if we come via this path again,
456
+ // Clear parsedData for path, queryString and absolute target as we won't check it if we come via this path again,
445
457
// an setting to null is fast as it doesn't need to use a GC write barrier.
446
458
_parsedPath = _parsedQueryString = null ;
459
+ _parsedAbsoluteRequestTarget = null ;
447
460
}
448
461
449
462
private void OnAsteriskFormTarget ( HttpMethod method )
@@ -463,6 +476,7 @@ private void OnAsteriskFormTarget(HttpMethod method)
463
476
// Clear parsedData as we won't check it if we come via this path again,
464
477
// an setting to null is fast as it doesn't need to use a GC write barrier.
465
478
_parsedRawTarget = _parsedPath = _parsedQueryString = null ;
479
+ _parsedAbsoluteRequestTarget = null ;
466
480
}
467
481
468
482
private void OnAbsoluteFormTarget ( Span < byte > target , Span < byte > query )
@@ -497,7 +511,7 @@ private void OnAbsoluteFormTarget(Span<byte> target, Span<byte> query)
497
511
ThrowRequestTargetRejected ( target ) ;
498
512
}
499
513
500
- _absoluteRequestTarget = uri ;
514
+ _absoluteRequestTarget = _parsedAbsoluteRequestTarget = uri ;
501
515
Path = _parsedPath = uri . LocalPath ;
502
516
// don't use uri.Query because we need the unescaped version
503
517
previousValue = _parsedQueryString ;
@@ -520,6 +534,7 @@ private void OnAbsoluteFormTarget(Span<byte> target, Span<byte> query)
520
534
RawTarget = _parsedRawTarget ;
521
535
Path = _parsedPath ;
522
536
QueryString = _parsedQueryString ;
537
+ _absoluteRequestTarget = _parsedAbsoluteRequestTarget ;
523
538
}
524
539
}
525
540
0 commit comments