Skip to content
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

HttpWebRequest.MaximumResponseHeadersLength does not accept -1 #27296

Closed
Mpdreamz opened this issue Sep 3, 2018 · 3 comments
Closed

HttpWebRequest.MaximumResponseHeadersLength does not accept -1 #27296

Mpdreamz opened this issue Sep 3, 2018 · 3 comments
Labels
area-System.Net bug tenet-compatibility Incompatibility with previous versions or .NET Framework
Milestone

Comments

@Mpdreamz
Copy link
Contributor

Mpdreamz commented Sep 3, 2018

HttpWebRequest.MaximumResponseHeadersLength accepts -1 as value on desktop CLR

However on corefx any value lower then 0 throws.

https://github.com/dotnet/corefx/blob/72119235e294e711871cf453f2ffc66ba17ff23b/src/System.Net.Requests/src/System/Net/HttpWebRequest.cs#L166

Is this by design?

@Tornhoof
Copy link
Contributor

Tornhoof commented Sep 3, 2018

I guess you should add a repro and/or specify the version you're using.

            HttpWebRequest hwr = WebRequest.CreateHttp("https://www.github.com");
            hwr.MaximumResponseHeadersLength = -1;

works fine for me on netcoreapp2.1, as System.Threading.Timeout.Infinite = -1

@karelz
Copy link
Member

karelz commented Sep 4, 2018

@Mpdreamz does it break any real-world scenarios / applications?

@davidsh
Copy link
Contributor

davidsh commented Sep 11, 2018

@Mpdreamz Do you actually see this bug by running code? Or just by inspecting the sources?

The source code you reference above is doing the right thing:

if (value < 0 && value != System.Threading.Timeout.Infinite) 

System.Threading.Timeout.Infinite is equal to -1:
https://docs.microsoft.com/en-us/dotnet/api/system.threading.timeout.infinite?redirectedfrom=MSDN&view=netframework-4.7.2

So, this code doesn't actually throw any exception. And it works the same on .NET Core as .NET Framework:

HttpWebRequest hwr = WebRequest.CreateHttp("https://www.github.com");
hwr.MaximumResponseHeadersLength = -1;

Let us know if you can repro the exception you are talking about.

@davidsh davidsh closed this as completed Sep 11, 2018
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net bug tenet-compatibility Incompatibility with previous versions or .NET Framework
Projects
None yet
Development

No branches or pull requests

5 participants