HTTP2: Fix HttpRequestHeaders no longer being pooled (#19329)
This commit is contained in:
parent
169f07c667
commit
f5eb3dc339
|
|
@ -6105,7 +6105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
|
|
||||||
// We didn't have a previous matching header value, or have already added a header, so get the string for this value.
|
// We didn't have a previous matching header value, or have already added a header, so get the string for this value.
|
||||||
var valueStr = value.GetRequestHeaderStringNonNullCharacters(_useLatin1);
|
var valueStr = value.GetRequestHeaderStringNonNullCharacters(UseLatin1);
|
||||||
if ((_bits & flag) == 0)
|
if ((_bits & flag) == 0)
|
||||||
{
|
{
|
||||||
// We didn't already have a header set, so add a new one.
|
// We didn't already have a header set, so add a new one.
|
||||||
|
|
@ -6123,7 +6123,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
// The header was not one of the "known" headers.
|
// The header was not one of the "known" headers.
|
||||||
// Convert value to string first, because passing two spans causes 8 bytes stack zeroing in
|
// Convert value to string first, because passing two spans causes 8 bytes stack zeroing in
|
||||||
// this method with rep stosd, which is slower than necessary.
|
// this method with rep stosd, which is slower than necessary.
|
||||||
var valueStr = value.GetRequestHeaderStringNonNullCharacters(_useLatin1);
|
var valueStr = value.GetRequestHeaderStringNonNullCharacters(UseLatin1);
|
||||||
AppendUnknownHeaders(name, valueStr);
|
AppendUnknownHeaders(name, valueStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using System.IO;
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
@ -81,14 +82,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
ServerOptions = ServiceContext.ServerOptions;
|
ServerOptions = ServiceContext.ServerOptions;
|
||||||
|
|
||||||
HttpRequestHeaders = new HttpRequestHeaders(
|
|
||||||
reuseHeaderValues: !ServerOptions.DisableStringReuse,
|
|
||||||
useLatin1: ServerOptions.Latin1RequestHeaders);
|
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
HttpRequestHeaders.ReuseHeaderValues = !ServerOptions.DisableStringReuse;
|
|
||||||
|
|
||||||
HttpResponseControl = this;
|
HttpResponseControl = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,6 +366,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
ConnectionIdFeature = ConnectionId;
|
ConnectionIdFeature = ConnectionId;
|
||||||
|
|
||||||
HttpRequestHeaders.Reset();
|
HttpRequestHeaders.Reset();
|
||||||
|
HttpRequestHeaders.UseLatin1 = ServerOptions.Latin1RequestHeaders;
|
||||||
|
HttpRequestHeaders.ReuseHeaderValues = !ServerOptions.DisableStringReuse;
|
||||||
HttpResponseHeaders.Reset();
|
HttpResponseHeaders.Reset();
|
||||||
RequestHeaders = HttpRequestHeaders;
|
RequestHeaders = HttpRequestHeaders;
|
||||||
ResponseHeaders = HttpResponseHeaders;
|
ResponseHeaders = HttpResponseHeaders;
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
{
|
{
|
||||||
internal sealed partial class HttpRequestHeaders : HttpHeaders
|
internal sealed partial class HttpRequestHeaders : HttpHeaders
|
||||||
{
|
{
|
||||||
private readonly bool _useLatin1;
|
|
||||||
private long _previousBits = 0;
|
private long _previousBits = 0;
|
||||||
|
|
||||||
|
public bool ReuseHeaderValues { get; set; }
|
||||||
|
public bool UseLatin1 { get; set; }
|
||||||
|
|
||||||
public HttpRequestHeaders(bool reuseHeaderValues = true, bool useLatin1 = false)
|
public HttpRequestHeaders(bool reuseHeaderValues = true, bool useLatin1 = false)
|
||||||
{
|
{
|
||||||
ReuseHeaderValues = reuseHeaderValues;
|
ReuseHeaderValues = reuseHeaderValues;
|
||||||
_useLatin1 = useLatin1;
|
UseLatin1 = useLatin1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ReuseHeaderValues { get; set; }
|
|
||||||
|
|
||||||
public void OnHeadersComplete()
|
public void OnHeadersComplete()
|
||||||
{
|
{
|
||||||
var bitsToClear = _previousBits & ~_bits;
|
var bitsToClear = _previousBits & ~_bits;
|
||||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
parsed < 0 ||
|
parsed < 0 ||
|
||||||
consumed != value.Length)
|
consumed != value.Length)
|
||||||
{
|
{
|
||||||
BadHttpRequestException.Throw(RequestRejectionReason.InvalidContentLength, value.GetRequestHeaderStringNonNullCharacters(_useLatin1));
|
BadHttpRequestException.Throw(RequestRejectionReason.InvalidContentLength, value.GetRequestHeaderStringNonNullCharacters(UseLatin1));
|
||||||
}
|
}
|
||||||
|
|
||||||
_contentLength = parsed;
|
_contentLength = parsed;
|
||||||
|
|
|
||||||
|
|
@ -986,7 +986,7 @@ $@" private void Clear(long bitsToClear)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// We didn't have a previous matching header value, or have already added a header, so get the string for this value.
|
// We didn't have a previous matching header value, or have already added a header, so get the string for this value.
|
||||||
var valueStr = value.GetRequestHeaderStringNonNullCharacters(_useLatin1);
|
var valueStr = value.GetRequestHeaderStringNonNullCharacters(UseLatin1);
|
||||||
if ((_bits & flag) == 0)
|
if ((_bits & flag) == 0)
|
||||||
{{
|
{{
|
||||||
// We didn't already have a header set, so add a new one.
|
// We didn't already have a header set, so add a new one.
|
||||||
|
|
@ -1004,7 +1004,7 @@ $@" private void Clear(long bitsToClear)
|
||||||
// The header was not one of the ""known"" headers.
|
// The header was not one of the ""known"" headers.
|
||||||
// Convert value to string first, because passing two spans causes 8 bytes stack zeroing in
|
// Convert value to string first, because passing two spans causes 8 bytes stack zeroing in
|
||||||
// this method with rep stosd, which is slower than necessary.
|
// this method with rep stosd, which is slower than necessary.
|
||||||
var valueStr = value.GetRequestHeaderStringNonNullCharacters(_useLatin1);
|
var valueStr = value.GetRequestHeaderStringNonNullCharacters(UseLatin1);
|
||||||
AppendUnknownHeaders(name, valueStr);
|
AppendUnknownHeaders(name, valueStr);
|
||||||
}}
|
}}
|
||||||
}}" : "")}
|
}}" : "")}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue