make BrowserHttpMessage.Send throw PNSE (#42990)
authorLarry Ewing <lewing@microsoft.com>
Sun, 4 Oct 2020 19:44:53 +0000 (14:44 -0500)
committerGitHub <noreply@github.com>
Sun, 4 Oct 2020 19:44:53 +0000 (14:44 -0500)
* Throw PNSE on sync version of BrowserHttpHandler.Send

* Mark HttpClientHandler.Send as unsupported on browser

* Update reference source

src/libraries/System.Net.Http/ref/System.Net.Http.cs
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs

index 43b8ddb..c13f88d 100644 (file)
@@ -143,6 +143,7 @@ namespace System.Net.Http
         [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
         public bool UseProxy { get { throw null; } set { } }
         protected override void Dispose(bool disposing) { }
+        [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
         protected internal override System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; }
         protected internal override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; }
     }
index 2c77c78..f4aa20a 100644 (file)
@@ -137,6 +137,11 @@ namespace System.Net.Http
         private Dictionary<string, object?>? _properties;
         public IDictionary<string, object?> Properties => _properties ??= new Dictionary<string, object?>();
 
+        protected internal override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken)
+        {
+            throw new PlatformNotSupportedException ();
+        }
+
         protected internal override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
         {
             try
index 93eb452..81de5ba 100644 (file)
@@ -287,6 +287,7 @@ namespace System.Net.Http
 
         public IDictionary<string, object?> Properties => _underlyingHandler.Properties;
 
+        [UnsupportedOSPlatform("browser")]
         protected internal override HttpResponseMessage Send(HttpRequestMessage request,
             CancellationToken cancellationToken)
         {