HttpClientHandler.wasm.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.Collections.Generic;
  5. using System.Net.Security;
  6. using System.Security.Authentication;
  7. using System.Security.Cryptography.X509Certificates;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace System.Net.Http
  11. {
  12. public partial class HttpClientHandler : HttpMessageHandler
  13. {
  14. HttpMessageHandler wasmHandler;
  15. public HttpClientHandler () : this (HttpClient.CreateDefaultHandler ()) { }
  16. HttpClientHandler (HttpMessageHandler wasmHandler)
  17. {
  18. this.wasmHandler = wasmHandler;
  19. }
  20. protected override void Dispose (bool disposing)
  21. {
  22. if (disposing) {
  23. if (wasmHandler != null) {
  24. wasmHandler.Dispose ();
  25. wasmHandler = null;
  26. }
  27. }
  28. base.Dispose (disposing);
  29. }
  30. const string EXCEPTION_MESSAGE = "System.Net.Http.HttpClientHandler is not supported on the current platform.";
  31. public virtual bool SupportsAutomaticDecompression => false;
  32. public virtual bool SupportsProxy => false;
  33. public virtual bool SupportsRedirectConfiguration => false;
  34. public bool UseCookies {
  35. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  36. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  37. }
  38. public CookieContainer CookieContainer {
  39. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  40. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  41. }
  42. public ClientCertificateOption ClientCertificateOptions {
  43. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  44. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  45. }
  46. public X509CertificateCollection ClientCertificates {
  47. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  48. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  49. }
  50. public Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> ServerCertificateCustomValidationCallback {
  51. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  52. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  53. }
  54. public bool CheckCertificateRevocationList {
  55. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  56. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  57. }
  58. public SslProtocols SslProtocols {
  59. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  60. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  61. }
  62. public DecompressionMethods AutomaticDecompression {
  63. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  64. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  65. }
  66. public bool UseProxy {
  67. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  68. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  69. }
  70. public IWebProxy Proxy {
  71. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  72. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  73. }
  74. public ICredentials DefaultProxyCredentials {
  75. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  76. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  77. }
  78. public bool PreAuthenticate {
  79. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  80. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  81. }
  82. public bool UseDefaultCredentials {
  83. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  84. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  85. }
  86. public ICredentials Credentials {
  87. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  88. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  89. }
  90. public bool AllowAutoRedirect {
  91. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  92. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  93. }
  94. public int MaxAutomaticRedirections {
  95. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  96. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  97. }
  98. public int MaxConnectionsPerServer {
  99. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  100. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  101. }
  102. public int MaxResponseHeadersLength {
  103. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  104. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  105. }
  106. public long MaxRequestContentBufferSize {
  107. get => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  108. set => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  109. }
  110. public IDictionary<string, object> Properties => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  111. protected internal override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
  112. {
  113. if (wasmHandler == null)
  114. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  115. return wasmHandler.SendAsync (request, cancellationToken);
  116. }
  117. }
  118. }