-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Add configurable SSE parser buffer limit #132275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1f57ec1
Initial plan
Copilot 5984a75
Add SseParser buffer options
Copilot 681f797
Restore existing SseParser Create overloads
Copilot eb47059
Address review: use ArgumentNullException.ThrowIfNull and validate Ma…
Copilot fee9f0c
Address SSE parser review feedback
Copilot d60b319
Apply suggestions from code review
MihaZupan 0fe7c83
Revert unrelated test wrapping and fix MaxBufferSize enforcement bug
Copilot 6674fb1
Fix SSE MaxBufferSize read enforcement
Copilot 9765a2d
Fix netstandard2.0/.NET Framework compat for SseParserOptions
Copilot 532dba5
Silently raise MaxBufferSize values below 128 to that minimum
Copilot c76a3ad
Reuse DefaultArrayPoolRentSize instead of a separate MinMaxBufferSize…
Copilot f2fa2fd
Keep SSE parser initial buffer size
Copilot 2fea097
Remove SSE buffer rent max cap
Copilot 71d63bd
Use full rented capacity for SSE reads
Copilot 65cb3d9
Adjust SSE max-buffer enforcement to grow-time check
Copilot 158a15d
Manual corrections and logic movements.
mrek-msft cc3d2b5
Improve comments
mrek-msft c941e35
Resolving PR comments
mrek-msft 9655642
Remove duplicate test
mrek-msft 9866b9a
SImplify code, fix too late check for skipping if large enough
mrek-msft f33b397
Code cleanup
mrek-msft 7d836a9
Simplify code, work in uint to prevent explicit overflow checks, add …
mrek-msft 4ad284e
Do not "grow" if current sioze equals requested.
mrek-msft 3cc0fa5
Typos in comments
mrek-msft d1962d4
Removing confusing comments
mrek-msft 975536b
Refactor typos in code.
mrek-msft ff27e48
Update src/libraries/System.Net.ServerSentEvents/src/System/Net/Serve…
mrek-msft afa6232
remove Array.MaxLength check
mrek-msft b64eaea
Merge branch 'copilot/add-sseparser-options' of https://github.com/do…
mrek-msft 0ed6ad8
Handle above Array.MaxLength edge case
mrek-msft 27de8f5
Fix typo
mrek-msft 4a10b2a
Fix bad comparison operator
mrek-msft 93c49c2
Improve comment
mrek-msft 16ebdf1
Fix 'allows' test
MihaZupan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...libraries/System.Net.ServerSentEvents/src/System/Net/ServerSentEvents/SseParserOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace System.Net.ServerSentEvents | ||
| { | ||
| /// <summary>Provides options for parsing server-sent events.</summary> | ||
| /// <typeparam name="T">Specifies the type of data parsed from an event.</typeparam> | ||
| public sealed class SseParserOptions<T> | ||
| { | ||
| /// <summary>Initializes a new instance of the <see cref="SseParserOptions{T}"/> class.</summary> | ||
| /// <param name="itemParser">The parser to use to transform each payload of bytes into a data element.</param> | ||
| /// <exception cref="ArgumentNullException"><paramref name="itemParser"/> is null.</exception> | ||
| public SseParserOptions(SseItemParser<T> itemParser) | ||
| { | ||
| ThrowHelper.ThrowIfNull(itemParser, nameof(itemParser)); | ||
|
|
||
| ItemParser = itemParser; | ||
| } | ||
|
|
||
| /// <summary>Gets the parser to use to transform each payload of bytes into a data element.</summary> | ||
| public SseItemParser<T> ItemParser { get; } | ||
|
|
||
| /// <summary>Gets or sets the maximum buffer size requested from the underlying allocator, or -1 to use the default limit.</summary> | ||
| /// <exception cref="ArgumentOutOfRangeException">The value set is less than -1.</exception> | ||
| /// <remarks>The limit is enforced on a best-effort basis. The permitted memory consumption may be several times higher than the configured limit. Values smaller than the internal minimum buffer size are treated as that minimum.</remarks> | ||
| public int MaxBufferSize | ||
| { | ||
| get => _maxBufferSize; | ||
| set | ||
| { | ||
| if (value < -1) | ||
| { | ||
| ThrowHelper.ThrowArgumentOutOfRangeException(nameof(value)); | ||
| } | ||
|
|
||
| _maxBufferSize = value; | ||
| } | ||
| } | ||
|
|
||
| private int _maxBufferSize = -1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.