@@ -34,6 +34,13 @@ internal partial class Http1Connection : HttpProtocol, IRequestProcessor
3434 private HttpRequestTarget _requestTargetForm = HttpRequestTarget . Unknown ;
3535 private Uri _absoluteRequestTarget ;
3636
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+
3744 private int _remainingRequestHeadersBytesAllowed ;
3845
3946 public Http1Connection ( HttpConnectionContext context )
@@ -337,6 +344,7 @@ private void OnOriginFormTarget(bool pathEncoded, Span<byte> target, Span<byte>
337344 // Clear parsedData as we won't check it if we come via this path again,
338345 // an setting to null is fast as it doesn't need to use a GC write barrier.
339346 _parsedRawTarget = _parsedPath = _parsedQueryString = null ;
347+ _parsedAbsoluteRequestTarget = null ;
340348 return ;
341349 }
342350
@@ -389,6 +397,10 @@ private void OnOriginFormTarget(bool pathEncoded, Span<byte> target, Span<byte>
389397 Path = _parsedPath ;
390398 QueryString = _parsedQueryString ;
391399 }
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 ;
392404 }
393405 catch ( InvalidOperationException )
394406 {
@@ -441,9 +453,10 @@ private void OnAuthorityFormTarget(HttpMethod method, Span<byte> target)
441453
442454 Path = string . Empty ;
443455 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,
445457 // an setting to null is fast as it doesn't need to use a GC write barrier.
446458 _parsedPath = _parsedQueryString = null ;
459+ _parsedAbsoluteRequestTarget = null ;
447460 }
448461
449462 private void OnAsteriskFormTarget ( HttpMethod method )
@@ -463,6 +476,7 @@ private void OnAsteriskFormTarget(HttpMethod method)
463476 // Clear parsedData as we won't check it if we come via this path again,
464477 // an setting to null is fast as it doesn't need to use a GC write barrier.
465478 _parsedRawTarget = _parsedPath = _parsedQueryString = null ;
479+ _parsedAbsoluteRequestTarget = null ;
466480 }
467481
468482 private void OnAbsoluteFormTarget ( Span < byte > target , Span < byte > query )
@@ -497,7 +511,7 @@ private void OnAbsoluteFormTarget(Span<byte> target, Span<byte> query)
497511 ThrowRequestTargetRejected ( target ) ;
498512 }
499513
500- _absoluteRequestTarget = uri ;
514+ _absoluteRequestTarget = _parsedAbsoluteRequestTarget = uri ;
501515 Path = _parsedPath = uri . LocalPath ;
502516 // don't use uri.Query because we need the unescaped version
503517 previousValue = _parsedQueryString ;
@@ -520,6 +534,7 @@ private void OnAbsoluteFormTarget(Span<byte> target, Span<byte> query)
520534 RawTarget = _parsedRawTarget ;
521535 Path = _parsedPath ;
522536 QueryString = _parsedQueryString ;
537+ _absoluteRequestTarget = _parsedAbsoluteRequestTarget ;
523538 }
524539 }
525540
0 commit comments