SocketsHttpHandler.Mono.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Globalization;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Net.Http
  8. {
  9. partial class SocketsHttpHandler : IMonoHttpClientHandler
  10. {
  11. bool IMonoHttpClientHandler.SupportsAutomaticDecompression => true;
  12. long IMonoHttpClientHandler.MaxRequestContentBufferSize {
  13. // This property is not supported. In the .NET Framework it was only used when the handler needed to
  14. // automatically buffer the request content. That only happened if neither 'Content-Length' nor
  15. // 'Transfer-Encoding: chunked' request headers were specified. So, the handler thus needed to buffer
  16. // in the request content to determine its length and then would choose 'Content-Length' semantics when
  17. // POST'ing. In .NET Core and UAP platforms, the handler will resolve the ambiguity by always choosing
  18. // 'Transfer-Encoding: chunked'. The handler will never automatically buffer in the request content.
  19. get {
  20. return 0; // Returning zero is appropriate since in .NET Framework it means no limit.
  21. }
  22. set {
  23. if (value < 0) {
  24. throw new ArgumentOutOfRangeException (nameof (value));
  25. }
  26. if (value > HttpContent.MaxBufferSize) {
  27. throw new ArgumentOutOfRangeException (nameof (value), value,
  28. string.Format (CultureInfo.InvariantCulture, SR.net_http_content_buffersize_limit,
  29. HttpContent.MaxBufferSize));
  30. }
  31. CheckDisposedOrStarted ();
  32. // No-op on property setter.
  33. }
  34. }
  35. Task<HttpResponseMessage> IMonoHttpClientHandler.SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) => SendAsync (request, cancellationToken);
  36. }
  37. }