runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Ability to set the HttpWebRequest.DefaultMaximumErrorResponseLength on a per request basis

Open niemyjski opened this issue 11 years ago • 3 comments

I realize the http code hasn't been imported yet.. But it would be really nice if this could be changed in >=4.6

Currently the only way you can set the DefaultMaximumErrorResponseLength for a request is AppDomain wide. We should also be able to be set on a per request basis (like we can do with ServicePoint).

niemyjski avatar Jan 07 '15 18:01 niemyjski

Hi @niemyjski , we have now completed porting System.Net.Http as well as System.Net.Requests to this repo. System.Net.HttpWebRequest and System.Net.HttpWebResponse classes are provided only for backward compatibility reasons and only a small subset of the .NET framework API surface of these classes is supported in .NET Core. The recommended API for HTTP client role is HttpClient along with its handlers such as HttpClientHandler or WinHttpHandler.

Now, as for this specific property, this is not currently supported in the .NET Core subset of HttpWebRequest and there are no plans to add support for it. The HttpClient API family does not have such a static property - instead, the WinHttpHandler.MaxResponseHeadersLength property addresses the same scenario - protecting the client from an overly large response payload from a bad server. The recommended approach is to use this property instead.

Please let me know if you have any questions about this - otherwise, I will go ahead and close this issue.

Thanks, Sid.

SidharthNabar avatar Jul 27 '15 18:07 SidharthNabar

Thanks for the follow up :) So just to confirm, this is something you could set on a per instance basis of the handler (WinHttpHandler.MaxResponseHeadersLength)..

niemyjski avatar Jul 28 '15 15:07 niemyjski

Yes.

SidharthNabar avatar Jul 28 '15 15:07 SidharthNabar