Skip to content

Commit

Permalink
[Foundation] Set the MaxInputInMemory to match the limit from other B…
Browse files Browse the repository at this point in the history
…CL classes. Fixes #21537

The MaxInputInMemory property is set by default to be long.MaxValue.
This value is much larger than the one we can find in other BCL classes
such as the HttpContent [max value](https://github.com/microsoft/referencesource/blob/master/System/net/System/Net/Http/HttpContent.cs#L20)
and the MemoryStream [max value](https://github.com/dotnet/runtime/blob/1d1bf92fcf43aa6981804dc53c5174445069c9e4/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs#L37).

It is important to notice that the HttpContent.MaxValue is used to
limit the value of the MaxResponseContentBufferSize property in the
HttpClient. This means that by making this move we are following the
rest of the BCL.

Fixes #21537
  • Loading branch information
mandel-macaque committed Nov 19, 2024
1 parent 6bfecec commit 10aa1d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void BackgroundNotificationCb (NSNotification obj)
}
#endif

public long MaxInputInMemory { get; set; } = long.MaxValue;
public long MaxInputInMemory { get; set; } = (long) int.MaxValue; // use int.MaxValue since it is the same max value used by both HttpContent and MemoryStream.

void RemoveInflightData (NSUrlSessionTask task, bool cancel = true)
{
Expand Down

0 comments on commit 10aa1d9

Please sign in to comment.