Skip to content

Commit abe9bd4

Browse files
committed
Raise field size limit to 32kb #12213
1 parent 90802f2 commit abe9bd4

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

src/Servers/Kestrel/Core/src/Http2Limits.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Http2Limits
1515
private int _maxStreamsPerConnection = 100;
1616
private int _headerTableSize = (int)Http2PeerSettings.DefaultHeaderTableSize;
1717
private int _maxFrameSize = (int)Http2PeerSettings.DefaultMaxFrameSize;
18-
private int _maxRequestHeaderFieldSize = (int)Http2PeerSettings.DefaultMaxFrameSize;
18+
private int _maxRequestHeaderFieldSize = 32 * 1024; // Matches MaxRequestHeadersTotalSize
1919
private int _initialConnectionWindowSize = 1024 * 1024; // Equal to SocketTransportOptions.MaxReadBufferSize and larger than any one single stream.
2020
private int _initialStreamWindowSize = 768 * 1024; // Larger than the default 64kb and able to use most (3/4ths) of the connection window by itself.
2121
private TimeSpan _keepAlivePingDelay = TimeSpan.MaxValue;

src/Servers/Kestrel/Core/src/Http3Limits.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core;
1010
/// </summary>
1111
public class Http3Limits
1212
{
13-
internal const int DefaultMaxRequestHeaderFieldSize = 16 * 1024;
14-
1513
private int _headerTableSize;
16-
private int _maxRequestHeaderFieldSize = DefaultMaxRequestHeaderFieldSize;
14+
private int _maxRequestHeaderFieldSize = 32 * 1024; // Matches MaxRequestHeadersTotalSize
1715

1816
/// <summary>
1917
/// Limits the size of the header compression table, in octets, the QPACK decoder on the server can use.

src/Servers/Kestrel/Core/test/KestrelServerLimitsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public void Http2HeaderTableSizeInvalid(int value)
341341
[Fact]
342342
public void Http2MaxRequestHeaderFieldSizeDefault()
343343
{
344-
Assert.Equal(16 * 1024, new KestrelServerLimits().Http2.MaxRequestHeaderFieldSize);
344+
Assert.Equal(32 * 1024, new KestrelServerLimits().Http2.MaxRequestHeaderFieldSize);
345345
}
346346

347347
[Theory]

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ public async Task RequestHeadersMaxRequestHeaderFieldSize_EndsStream()
135135
new KeyValuePair<string, string>(InternalHeaderNames.Path, "/"),
136136
new KeyValuePair<string, string>(InternalHeaderNames.Scheme, "http"),
137137
new KeyValuePair<string, string>(InternalHeaderNames.Authority, "localhost:80"),
138-
new KeyValuePair<string, string>("test", new string('a', 20000))
138+
new KeyValuePair<string, string>("test", new string('a', 1024 * 32 + 1))
139139
};
140140

141141
var requestStream = await Http3Api.InitializeConnectionAndStreamsAsync(_echoApplication, headers);
142142

143143
await requestStream.WaitForStreamErrorAsync(
144144
Http3ErrorCode.InternalError,
145145
AssertExpectedErrorMessages,
146-
"The HTTP headers length exceeded the set limit of 16384 bytes.");
146+
$"The HTTP headers length exceeded the set limit of {1024 * 32} bytes.");
147147
}
148148

149149
[Fact]

0 commit comments

Comments
 (0)