From a0d69a4e876834412ba676f544d447ec331e7c01 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 8 Apr 2020 02:42:03 -0700 Subject: [PATCH] Produce System.Net.Http.WebAssemblyHttpHandler (#19260) * Produce System.Net.Http.WebAssemblyMessageHandler * Branding changes for WebAssembly.Net.Http -> System.Net.Http.WebAssemblyMessageHandler * Change how fetch options are configured * Fixup tests * More fixup * Update submodule --- external/binary-reference-assemblies | 2 +- mcs/class/System.Net.Http/Makefile | 2 +- mcs/class/System.Net.Http/System.Net.Http.csproj | 4 +- .../System.Net.Http/HttpClient.wasm.cs | 2 +- .../System.Net.Http/HttpClientHandler.wasm.cs | 4 +- sdks/wasm/Makefile | 8 +- sdks/wasm/docs/getting-started/sample.md | 24 +-- sdks/wasm/framework/.gitignore | 2 +- .../System.Net.Http.WebAssemblyHttpHandler.csproj} | 8 +- .../WebAssemblyHttpHandler.cs} | 171 ++++----------------- sdks/wasm/framework/src/WebAssembly.Framework.sln | 43 +++--- sdks/wasm/packager.cs | 12 +- sdks/wasm/sample.cs | 1 - .../Mono.WebAssembly.Build/WasmLinkAssemblies.cs | 4 +- sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props | 6 +- .../sdk/Sdk.props.buildschema.json | 4 +- sdks/wasm/sdk/MonoWasmSdk.sln | 2 +- sdks/wasm/sdk/MonoWasmSdkCLI.sln | 2 +- .../System.Net.Http.WebAssemblyHttpHandler.csproj} | 6 +- sdks/wasm/src/driver.c | 1 + .../BrowserTestSuite/http-spec-with-prom-lib.js | 167 +++++++++----------- .../browser/src/BrowserTestSuite/http-spec.js | 157 +++++++++---------- .../browser/src/HttpTestSuite/HttpTestSuite.cs | 40 ++--- .../browser/src/HttpTestSuite/HttpTestSuite.csproj | 2 +- .../src/IssuesTestSuite/IssuesTestSuite.csproj | 2 +- sdks/wasm/tests/browser/src/Packages.props | 4 +- .../WebSocketTestSuite/WebSocketTestSuite.csproj | 2 +- 27 files changed, 264 insertions(+), 418 deletions(-) rename sdks/wasm/framework/src/{WebAssembly.Net.Http/WebAssembly.Net.Http.csproj => System.Net.Http.WebAssemblyHttpHandler/System.Net.Http.WebAssemblyHttpHandler.csproj} (73%) rename sdks/wasm/framework/src/{WebAssembly.Net.Http/WasmHttpMessageHandler.cs => System.Net.Http.WebAssemblyHttpHandler/WebAssemblyHttpHandler.cs} (74%) rename sdks/wasm/sdk/{WebAssembly.Net.Http.Framework/WebAssembly.Net.Http.csproj => System.Net.Http.WebAssemblyHttpHandler.Framework/System.Net.Http.WebAssemblyHttpHandler.csproj} (53%) diff --git a/external/binary-reference-assemblies b/external/binary-reference-assemblies index e68046d5106..680013abda9 160000 --- a/external/binary-reference-assemblies +++ b/external/binary-reference-assemblies @@ -1 +1 @@ -Subproject commit e68046d5106aa0349c23f95821456955fc15b96b +Subproject commit 680013abda911528f6befca67eed5669d80c85d5 diff --git a/mcs/class/System.Net.Http/Makefile b/mcs/class/System.Net.Http/Makefile index 9e56625a14d..fd869b28bc1 100644 --- a/mcs/class/System.Net.Http/Makefile +++ b/mcs/class/System.Net.Http/Makefile @@ -38,7 +38,7 @@ LIB_MCS_FLAGS += -d:XAMARIN_MODERN endif ifeq (wasm,$(PROFILE)) -API_BIN_REFS := WebAssembly.Net.Http +API_BIN_REFS := System.Net.Http.WebAssemblyHttpHandler endif TEST_LIB_REFS = System System.Core diff --git a/mcs/class/System.Net.Http/System.Net.Http.csproj b/mcs/class/System.Net.Http/System.Net.Http.csproj index 554e2d19150..38ebec3fbf3 100644 --- a/mcs/class/System.Net.Http/System.Net.Http.csproj +++ b/mcs/class/System.Net.Http/System.Net.Http.csproj @@ -1407,9 +1407,9 @@ - + False - ./../../../external/binary-reference-assemblies/build/monowasm/WebAssembly.Net.Http.dll + ./../../../external/binary-reference-assemblies/build/monowasm/System.Net.Http.WebAssemblyHttpHandler.dll False diff --git a/mcs/class/System.Net.Http/System.Net.Http/HttpClient.wasm.cs b/mcs/class/System.Net.Http/System.Net.Http/HttpClient.wasm.cs index e98dc08a7e2..73200a85986 100644 --- a/mcs/class/System.Net.Http/System.Net.Http/HttpClient.wasm.cs +++ b/mcs/class/System.Net.Http/System.Net.Http/HttpClient.wasm.cs @@ -2,6 +2,6 @@ namespace System.Net.Http { public partial class HttpClient { - static HttpMessageHandler CreateDefaultHandler () => new WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler (); + static HttpMessageHandler CreateDefaultHandler () => new System.Net.Http.WebAssemblyHttpHandler (); } } diff --git a/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.wasm.cs b/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.wasm.cs index 20196dbdf61..6dbdea177a8 100644 --- a/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.wasm.cs +++ b/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.wasm.cs @@ -13,11 +13,11 @@ namespace System.Net.Http { public class HttpClientHandler : HttpMessageHandler { - WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler wasmHandler; + System.Net.Http.WebAssemblyHttpHandler wasmHandler; public HttpClientHandler () { - wasmHandler = new WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler (); + wasmHandler = new System.Net.Http.WebAssemblyHttpHandler (); } protected override void Dispose (bool disposing) diff --git a/sdks/wasm/Makefile b/sdks/wasm/Makefile index aaa8086d084..a7c770a3ce2 100644 --- a/sdks/wasm/Makefile +++ b/sdks/wasm/Makefile @@ -68,7 +68,7 @@ MINI_TEST_SOURCES = $(patsubst %,$(MINI_PATH)/%,$(MINI_TEST_FILES)) WASM_FRAMEWORK=$(TOP)/sdks/wasm/framework WASM_FRAMEWORK_SOURCE=$(TOP)/sdks/wasm/framework/src WASM_FRAMEWORK_SOURCES=$(WASM_FRAMEWORK_SOURCE)/**/* -WASM_FRAMEWORK_DEPS=/r:$(WASM_FRAMEWORK)/WebAssembly.Bindings.dll /r:$(WASM_FRAMEWORK)/WebAssembly.Net.Http.dll /r:$(WASM_FRAMEWORK)/WebAssembly.Net.WebSockets.dll +WASM_FRAMEWORK_DEPS=/r:$(WASM_FRAMEWORK)/WebAssembly.Bindings.dll /r:$(WASM_FRAMEWORK)/System.Net.Http.WebAssemblyHttpHandler.dll /r:$(WASM_FRAMEWORK)/WebAssembly.Net.WebSockets.dll BROWSER_TEST=$(TOP)/sdks/wasm/tests/browser BROWSER_TEST_THREADS=$(TOP)/sdks/wasm/tests/browser @@ -766,9 +766,9 @@ package: build build-sdk build-dbg-proxy cp framework/WebAssembly.Bindings.dll tmp/framework cp framework/WebAssembly.Bindings.pdb tmp/framework cp framework/WebAssembly.Bindings.xml tmp/framework - cp framework/WebAssembly.Net.Http.dll tmp/framework - cp framework/WebAssembly.Net.Http.pdb tmp/framework - cp framework/WebAssembly.Net.Http.xml tmp/framework + cp framework/System.Net.Http.WebAssemblyHttpHandler.dll tmp/framework + cp framework/System.Net.Http.WebAssemblyHttpHandler.pdb tmp/framework + cp framework/System.Net.Http.WebAssemblyHttpHandler.xml tmp/framework cp framework/WebAssembly.Net.WebSockets.dll tmp/framework cp framework/WebAssembly.Net.WebSockets.pdb tmp/framework cp framework/WebAssembly.Net.WebSockets.xml tmp/framework diff --git a/sdks/wasm/docs/getting-started/sample.md b/sdks/wasm/docs/getting-started/sample.md index bd1f4c96f3d..bd0e183d334 100644 --- a/sdks/wasm/docs/getting-started/sample.md +++ b/sdks/wasm/docs/getting-started/sample.md @@ -1,13 +1,13 @@ # Getting Started with the sample -The goal of this doc is to get you setup with a workable WebAssembly SDK and run the sample. +The goal of this doc is to get you setup with a workable WebAssembly SDK and run the sample. ## Content -    [Requirements](#requirements) -    [Create sample](#create-sample) -    [Serving sample](#serving-sample) - +    [Requirements](#requirements) +    [Create sample](#create-sample) +    [Serving sample](#serving-sample) + ## Requirements @@ -36,17 +36,17 @@ The WebAssembly SDK includes the sample code that we can use. 1. Compile sample ``` - csc /target:library -out:sample.dll /noconfig /nostdlib /r:$WASM_SDK/wasm-bcl/wasm/mscorlib.dll /r:$WASM_SDK/wasm-bcl/wasm/System.dll /r:$WASM_SDK/wasm-bcl/wasm/System.Core.dll /r:$WASM_SDK/wasm-bcl/wasm/Facades/netstandard.dll /r:$WASM_SDK/wasm-bcl/wasm/System.Net.Http.dll /r:$WASM_SDK/framework/WebAssembly.Bindings.dll /r:$WASM_SDK/framework/WebAssembly.Net.Http.dll dependency.cs sample.cs + csc /target:library -out:sample.dll /noconfig /nostdlib /r:$WASM_SDK/wasm-bcl/wasm/mscorlib.dll /r:$WASM_SDK/wasm-bcl/wasm/System.dll /r:$WASM_SDK/wasm-bcl/wasm/System.Core.dll /r:$WASM_SDK/wasm-bcl/wasm/Facades/netstandard.dll /r:$WASM_SDK/wasm-bcl/wasm/System.Net.Http.dll /r:$WASM_SDK/framework/WebAssembly.Bindings.dll /r:$WASM_SDK/framework/System.Net.Http.WebAssemblyHttpHandler.dll dependency.cs sample.cs ``` -1. Package and publish sample +1. Package and publish sample ``` mono $WASM_SDK/packager.exe --copy=always --out=./publish --asset=./sample.html --asset=server.py sample.dll ``` The `package` command will generate a `runtime.js` file that will properly load the runtime and call `App.Init` after that. - + It will copy the required files such as the support libraries and assets. @@ -54,8 +54,8 @@ You should now have the following directory structure ``` . -|--- my-app - |--- publish // Output from the `packager.exe` application +|--- my-app + |--- publish // Output from the `packager.exe` application |--- managed // Where to find the managed assemblies generated by packager.exe |--- mono-config.js // Configuration file referenced in `sample.html` and `runtime.js` |--- dotnet.js // Mono WebAssembly implementations @@ -89,9 +89,9 @@ publish$ python server.py ('python 3 serving at port', 8000) ``` -From a browser got to `http://localhost:8000/sample.html` or `http://127.0.0.1:8000/sample.html` depending on the browser. +From a browser got to `http://localhost:8000/sample.html` or `http://127.0.0.1:8000/sample.html` depending on the browser. -Change the port number to what the server specifies. +Change the port number to what the server specifies. diff --git a/sdks/wasm/framework/.gitignore b/sdks/wasm/framework/.gitignore index 1a2fc3d4db6..0d19e45abc2 100644 --- a/sdks/wasm/framework/.gitignore +++ b/sdks/wasm/framework/.gitignore @@ -1,4 +1,4 @@ *.xml *.json !src/WebAssembly.Bindings/LinkDescriptor/* -!src/WebAssembly.Net.Http/LinkDescriptor/* \ No newline at end of file +!src/System.Net.Http.WebAssemblyHttpHandler/LinkDescriptor/* \ No newline at end of file diff --git a/sdks/wasm/framework/src/WebAssembly.Net.Http/WebAssembly.Net.Http.csproj b/sdks/wasm/framework/src/System.Net.Http.WebAssemblyHttpHandler/System.Net.Http.WebAssemblyHttpHandler.csproj similarity index 73% rename from sdks/wasm/framework/src/WebAssembly.Net.Http/WebAssembly.Net.Http.csproj rename to sdks/wasm/framework/src/System.Net.Http.WebAssemblyHttpHandler/System.Net.Http.WebAssemblyHttpHandler.csproj index 824a6dfa370..21b62c3174e 100644 --- a/sdks/wasm/framework/src/WebAssembly.Net.Http/WebAssembly.Net.Http.csproj +++ b/sdks/wasm/framework/src/System.Net.Http.WebAssemblyHttpHandler/System.Net.Http.WebAssemblyHttpHandler.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -9,15 +9,15 @@ 1701;1702;1591; 1570; 1572; 1573 ..\..\ - ..\..\netstandard2.0\WebAssembly.Net.Http.xml + ..\..\netstandard2.0\System.Net.Http.WebAssemblyHttpHandler.xml true 1701;1702;1591; 1570; 1572; 1573 ..\..\ - ..\..\netstandard2.0\WebAssembly.Net.Http.xml + ..\..\netstandard2.0\System.Net.Http.WebAssemblyHttpHandler.xml - + \ No newline at end of file diff --git a/sdks/wasm/framework/src/WebAssembly.Net.Http/WasmHttpMessageHandler.cs b/sdks/wasm/framework/src/System.Net.Http.WebAssemblyHttpHandler/WebAssemblyHttpHandler.cs similarity index 74% rename from sdks/wasm/framework/src/WebAssembly.Net.Http/WasmHttpMessageHandler.cs rename to sdks/wasm/framework/src/System.Net.Http.WebAssemblyHttpHandler/WebAssemblyHttpHandler.cs index 4b13509a4b0..89bb3995f04 100644 --- a/sdks/wasm/framework/src/WebAssembly.Net.Http/WasmHttpMessageHandler.cs +++ b/sdks/wasm/framework/src/System.Net.Http.WebAssemblyHttpHandler/WebAssemblyHttpHandler.cs @@ -1,48 +1,34 @@ -using System; +using System.Collections.Generic; using System.IO; -using System.Net; -using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using WebAssembly; using WebAssembly.Core; using WebAssembly.Host; -namespace WebAssembly.Net.Http.HttpClient { - public class WasmHttpMessageHandler : HttpMessageHandler { +namespace System.Net.Http +{ + /// + /// is a specialty message handler based on the + /// Fetch API for use in WebAssembly environments. + /// + /// See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API + public class WebAssemblyHttpHandler : HttpMessageHandler { static JSObject fetch; static JSObject window; /// - /// Gets or sets the default value of the 'credentials' option on outbound HTTP requests. - /// Defaults to . - /// - public static FetchCredentialsOption DefaultCredentials { get; set; } - = FetchCredentialsOption.SameOrigin; - - public static RequestCache Cache { get; set; } - = RequestCache.Default; - - public static RequestMode Mode { get; set; } - = RequestMode.Cors; - - - /// /// Gets whether the current Browser supports streaming responses /// - public static bool StreamingSupported { get; } + private static bool StreamingSupported { get; } - /// - /// Gets or sets whether responses should be streamed if supported - /// - public static bool StreamingEnabled { get; set; } = false; - - static WasmHttpMessageHandler () + static WebAssemblyHttpHandler() { using (var streamingSupported = new Function ("return typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream === 'function'")) StreamingSupported = (bool)streamingSupported.Call (); } - public WasmHttpMessageHandler () + public WebAssemblyHttpHandler() { handlerInit (); } @@ -72,19 +58,15 @@ namespace WebAssembly.Net.Http.HttpClient { { try { var requestObject = new JSObject (); - requestObject.SetObjectProperty ("method", request.Method.Method); - - // See https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials for - // standard values and meanings - requestObject.SetObjectProperty ("credentials", DefaultCredentials); - // See https://developer.mozilla.org/en-US/docs/Web/API/Request/cache for - // standard values and meanings - requestObject.SetObjectProperty ("cache", Cache); + if (request.Properties.TryGetValue("WebAssemblyFetchOptions", out var fetchOoptionsValue) && + fetchOoptionsValue is IDictionary fetchOptions) { + foreach (var item in fetchOptions) { + requestObject.SetObjectProperty(item.Key, item.Value); + } + } - // See https://developer.mozilla.org/en-US/docs/Web/API/Request/mode for - // standard values and meanings - requestObject.SetObjectProperty ("mode", Mode); + requestObject.SetObjectProperty ("method", request.Method.Method); // We need to check for body content if (request.Content != null) { @@ -139,7 +121,7 @@ namespace WebAssembly.Net.Http.HttpClient { wasmHttpReadStream?.Dispose (); })); - var args = new Core.Array(); + var args = new WebAssembly.Core.Array(); args.Push (request.RequestUri.ToString ()); args.Push (requestObject); @@ -164,9 +146,11 @@ namespace WebAssembly.Net.Http.HttpClient { HttpResponseMessage httpresponse = new HttpResponseMessage ((HttpStatusCode)Enum.Parse (typeof (HttpStatusCode), status.Status.ToString ())); - httpresponse.Content = StreamingSupported && StreamingEnabled - ? new StreamContent (wasmHttpReadStream = new WasmHttpReadStream (status)) - : (HttpContent)new WasmHttpContent (status); + var streamingEnabled = request.Properties.TryGetValue("WebAssemblyEnableStreamingResponse", out var streamingEnabledValue) && (bool)streamingEnabledValue; + + httpresponse.Content = StreamingSupported && streamingEnabled + ? new StreamContent (wasmHttpReadStream = new WasmHttpReadStream (status)) + : (HttpContent)new WasmHttpContent (status); // Fill the response headers // CORS will only allow access to certain headers. @@ -365,7 +349,7 @@ namespace WebAssembly.Net.Http.HttpClient { return 0; } - try { + try { using (var body = _status.Body) { _reader = (JSObject)body.Invoke ("getReader"); } @@ -449,105 +433,4 @@ namespace WebAssembly.Net.Http.HttpClient { } } } - - /// - /// Specifies a value for the 'credentials' option on outbound HTTP requests. - /// - public enum FetchCredentialsOption { - /// - /// Advises the browser never to send credentials (such as cookies or HTTP auth headers). - /// - [Export (EnumValue = ConvertEnum.ToLower)] - Omit, - - /// - /// Advises the browser to send credentials (such as cookies or HTTP auth headers) - /// only if the target URL is on the same origin as the calling application. - /// - [Export ("same-origin")] - SameOrigin, - - /// - /// Advises the browser to send credentials (such as cookies or HTTP auth headers) - /// even for cross-origin requests. - /// - [Export (EnumValue = ConvertEnum.ToLower)] - Include, - } - - - /// - /// The cache mode of the request. It controls how the request will interact with the browser's HTTP cache. - /// - public enum RequestCache { - /// - /// The browser looks for a matching request in its HTTP cache. - /// - [Export (EnumValue = ConvertEnum.ToLower)] - Default, - - /// - /// The browser fetches the resource from the remote server without first looking in the cache, - /// and will not update the cache with the downloaded resource. - /// - [Export ("no-store")] - NoStore, - - /// - /// The browser fetches the resource from the remote server without first looking in the cache, - /// but then will update the cache with the downloaded resource. - /// - [Export (EnumValue = ConvertEnum.ToLower)] - Reload, - - /// - /// The browser looks for a matching request in its HTTP cache. - /// - [Export ("no-cache")] - NoCache, - - /// - /// The browser looks for a matching request in its HTTP cache. - /// - [Export ("force-cache")] - ForceCache, - - /// - /// The browser looks for a matching request in its HTTP cache. - /// Mode can only be used if the request's mode is "same-origin" - /// - [Export ("only-if-cached")] - OnlyIfCached, - } - - /// - /// The mode of the request. This is used to determine if cross-origin requests lead to valid responses - /// - public enum RequestMode { - /// - /// If a request is made to another origin with this mode set, the result is simply an error - /// - [Export ("same-origin")] - SameOrigin, - - /// - /// Prevents the method from being anything other than HEAD, GET or POST, and the headers from - /// being anything other than simple headers. - /// - [Export ("no-cors")] - NoCors, - - /// - /// Allows cross-origin requests, for example to access various APIs offered by 3rd party vendors. - /// - [Export (EnumValue = ConvertEnum.ToLower)] - Cors, - - /// - /// A mode for supporting navigation. - /// - [Export (EnumValue = ConvertEnum.ToLower)] - Navigate, - } - } diff --git a/sdks/wasm/framework/src/WebAssembly.Framework.sln b/sdks/wasm/framework/src/WebAssembly.Framework.sln index b74e4ae0643..68c80f46dbd 100644 --- a/sdks/wasm/framework/src/WebAssembly.Framework.sln +++ b/sdks/wasm/framework/src/WebAssembly.Framework.sln @@ -1,13 +1,13 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29905.134 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Bindings", "WebAssembly.Bindings\WebAssembly.Bindings.csproj", "{176A0D0C-41F0-4C2F-A440-617518A30032}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAssembly.Bindings", "WebAssembly.Bindings\WebAssembly.Bindings.csproj", "{176A0D0C-41F0-4C2F-A440-617518A30032}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Net.Http", "WebAssembly.Net.Http\WebAssembly.Net.Http.csproj", "{D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAssembly.Net.WebSockets", "WebAssembly.Net.WebSockets\WebAssembly.Net.WebSockets.csproj", "{D399ED16-6F8E-4D6D-BF44-434D5F2986D7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Net.WebSockets", "WebAssembly.Net.WebSockets\WebAssembly.Net.WebSockets.csproj", "{D399ED16-6F8E-4D6D-BF44-434D5F2986D7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Http.WebAssemblyHttpHandler", "System.Net.Http.WebAssemblyHttpHandler\System.Net.Http.WebAssemblyHttpHandler.csproj", "{EDD5C733-081C-49E2-944F-588729543B74}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -18,9 +18,6 @@ Global Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {176A0D0C-41F0-4C2F-A440-617518A30032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {176A0D0C-41F0-4C2F-A440-617518A30032}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -34,18 +31,6 @@ Global {176A0D0C-41F0-4C2F-A440-617518A30032}.Release|x64.Build.0 = Release|Any CPU {176A0D0C-41F0-4C2F-A440-617518A30032}.Release|x86.ActiveCfg = Release|Any CPU {176A0D0C-41F0-4C2F-A440-617518A30032}.Release|x86.Build.0 = Release|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Debug|x64.ActiveCfg = Debug|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Debug|x64.Build.0 = Debug|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Debug|x86.ActiveCfg = Debug|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Debug|x86.Build.0 = Debug|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Release|Any CPU.Build.0 = Release|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Release|x64.ActiveCfg = Release|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Release|x64.Build.0 = Release|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Release|x86.ActiveCfg = Release|Any CPU - {D721826B-CD18-4FBC-A3BC-7CDDEA41F3A2}.Release|x86.Build.0 = Release|Any CPU {D399ED16-6F8E-4D6D-BF44-434D5F2986D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D399ED16-6F8E-4D6D-BF44-434D5F2986D7}.Debug|Any CPU.Build.0 = Debug|Any CPU {D399ED16-6F8E-4D6D-BF44-434D5F2986D7}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -58,6 +43,24 @@ Global {D399ED16-6F8E-4D6D-BF44-434D5F2986D7}.Release|x64.Build.0 = Release|Any CPU {D399ED16-6F8E-4D6D-BF44-434D5F2986D7}.Release|x86.ActiveCfg = Release|Any CPU {D399ED16-6F8E-4D6D-BF44-434D5F2986D7}.Release|x86.Build.0 = Release|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Debug|x64.ActiveCfg = Debug|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Debug|x64.Build.0 = Debug|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Debug|x86.ActiveCfg = Debug|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Debug|x86.Build.0 = Debug|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Release|Any CPU.Build.0 = Release|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Release|x64.ActiveCfg = Release|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Release|x64.Build.0 = Release|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Release|x86.ActiveCfg = Release|Any CPU + {EDD5C733-081C-49E2-944F-588729543B74}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {555E8AE4-1D6A-4DFE-A358-C8C54A93C6E3} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/sdks/wasm/packager.cs b/sdks/wasm/packager.cs index 78a3bbf9bb5..78ba71df873 100644 --- a/sdks/wasm/packager.cs +++ b/sdks/wasm/packager.cs @@ -62,7 +62,7 @@ class Driver { const string BINDINGS_ASM_NAME = "WebAssembly.Bindings"; const string BINDINGS_RUNTIME_CLASS_NAME = "WebAssembly.Runtime"; - const string HTTP_ASM_NAME = "WebAssembly.Net.Http"; + const string HTTP_ASM_NAME = "System.Net.Http.WebAssemblyHttpHandler"; const string WEBSOCKETS_ASM_NAME = "WebAssembly.Net.WebSockets"; const string BINDINGS_MODULE = "corebindings.o"; const string BINDINGS_MODULE_SUPPORT = "$tool_prefix/src/binding_support.js"; @@ -252,7 +252,7 @@ class Driver { foreach (var prefix in bcl_prefixes) resolver.AddSearchDirectory (prefix); resolver.AddSearchDirectory(bcl_facades_prefix); - resolver.AddSearchDirectory(framework_prefix); + resolver.AddSearchDirectory(framework_prefix); rp.AssemblyResolver = resolver; rp.InMemory = true; @@ -341,7 +341,7 @@ class Driver { { Default, Always, - IfNewer + IfNewer } enum ExecMode { @@ -353,7 +353,7 @@ class Driver { enum LinkMode { SdkOnly, - All + All } class WasmOptions { @@ -740,7 +740,7 @@ class Driver { } foreach(var asset in assets) { - CopyFile (asset, + CopyFile (asset, Path.Combine (out_prefix, Path.GetFileName (asset)), copyType, "Asset: "); } } @@ -1178,7 +1178,7 @@ class Driver { { var srcInfo = new FileInfo (sourceFileName); var dstInfo = new FileInfo (destFileName); - + if (srcInfo.LastWriteTime.Ticks > dstInfo.LastWriteTime.Ticks || srcInfo.Length > dstInfo.Length) File.Copy(sourceFileName, destFileName, true); else diff --git a/sdks/wasm/sample.cs b/sdks/wasm/sample.cs index 848fc0890b5..4f9e761a280 100644 --- a/sdks/wasm/sample.cs +++ b/sdks/wasm/sample.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Net.Http; using System.Reflection; using WebAssembly; -using WebAssembly.Net.Http.HttpClient; public class Math { public static int IntAdd (int a, int b) { diff --git a/sdks/wasm/sdk/Mono.WebAssembly.Build/WasmLinkAssemblies.cs b/sdks/wasm/sdk/Mono.WebAssembly.Build/WasmLinkAssemblies.cs index eadb1eb0738..ca1c6d89015 100644 --- a/sdks/wasm/sdk/Mono.WebAssembly.Build/WasmLinkAssemblies.cs +++ b/sdks/wasm/sdk/Mono.WebAssembly.Build/WasmLinkAssemblies.cs @@ -111,7 +111,7 @@ namespace Mono.WebAssembly.Build return base.ValidateParameters (); } - static List bindingNames = new List {"WebAssembly.Bindings","WebAssembly.Net.Http","WebAssembly.Net.WebSockets"}; + static List bindingNames = new List {"WebAssembly.Bindings","System.Net.Http.WebAssemblyHttpHandler","WebAssembly.Net.WebSockets"}; protected override string GenerateCommandLineCommands () { @@ -256,7 +256,7 @@ namespace Mono.WebAssembly.Build if (!File.Exists(toolsPath)) toolsPath = Path.GetFullPath(Path.Combine (GetParentDirectoryOf(dir,6), "out", "wasm-bcl", "wasm_tools", "monolinker.exe")); return toolsPath; - } + } static string GetParentDirectoryOf (string path, int up) { diff --git a/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props b/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props index 0a1fee9ae28..49e137f57f3 100644 --- a/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props +++ b/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props @@ -29,7 +29,7 @@ - + @@ -38,13 +38,13 @@ - + - + diff --git a/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props.buildschema.json b/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props.buildschema.json index 68cebf6d620..55672f91c50 100644 --- a/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props.buildschema.json +++ b/sdks/wasm/sdk/Mono.WebAssembly.Sdk/sdk/Sdk.props.buildschema.json @@ -5,7 +5,7 @@ "MonoWasmFrameworkPath": "Overrides the path to the Mono WebAssembly framework assemblies.", "MonoWasmRuntimePath": "Overrides the path to the Mono WebAssembly runtime.", "MonoWasmTargetsPath": "Overrides the path to the Mono WebAssembly build targets.", - "MonoWasmBindingsPath": "Overrides the path to the Mono WebAssembly binding assemblies (WebAssembly.Bindings and WebAssembly.Net.Http).", - "DisableImplicitWasmBindingReferences": "Whether to omit references to the WebAssembly binding assemblies (WebAssembly.Bindings and WebAssembly.Net.Http)" + "MonoWasmBindingsPath": "Overrides the path to the Mono WebAssembly binding assemblies (WebAssembly.Bindings and System.Net.Http.WebAssemblyHttpHandler).", + "DisableImplicitWasmBindingReferences": "Whether to omit references to the WebAssembly binding assemblies (WebAssembly.Bindings and System.Net.Http.WebAssemblyHttpHandler)" } } \ No newline at end of file diff --git a/sdks/wasm/sdk/MonoWasmSdk.sln b/sdks/wasm/sdk/MonoWasmSdk.sln index 34422ceca21..1565f762e3c 100644 --- a/sdks/wasm/sdk/MonoWasmSdk.sln +++ b/sdks/wasm/sdk/MonoWasmSdk.sln @@ -21,7 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.WebAssembly.SdkTests", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.WebAssembly.Runtime", "Mono.WebAssembly.Runtime.Framework\Mono.WebAssembly.Runtime.csproj", "{7DD2FF9E-D36E-417D-806F-899087BE9C54}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Net.Http", "WebAssembly.Net.Http.Framework\WebAssembly.Net.Http.csproj", "{F905CB2B-2EC2-4375-AC10-07F98E27822D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.WebAssemblyHttpHandler", "System.Net.Http.WebAssemblyHttpHandler.Framework\System.Net.Http.WebAssemblyHttpHandler.csproj", "{F905CB2B-2EC2-4375-AC10-07F98E27822D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Bindings", "WebAssembly.Bindings.Framework\WebAssembly.Bindings.csproj", "{B8FDEB6F-F3CF-4C39-9275-C47CC1D34F22}" EndProject diff --git a/sdks/wasm/sdk/MonoWasmSdkCLI.sln b/sdks/wasm/sdk/MonoWasmSdkCLI.sln index 20c34dc75f6..f8035aa0a97 100644 --- a/sdks/wasm/sdk/MonoWasmSdkCLI.sln +++ b/sdks/wasm/sdk/MonoWasmSdkCLI.sln @@ -19,7 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{EBC911EF EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.WebAssembly.Runtime", "Mono.WebAssembly.Runtime.Framework\Mono.WebAssembly.Runtime.csproj", "{7DD2FF9E-D36E-417D-806F-899087BE9C54}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Net.Http", "WebAssembly.Net.Http.Framework\WebAssembly.Net.Http.csproj", "{F905CB2B-2EC2-4375-AC10-07F98E27822D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.WebAssemblyHttpHandler", "System.Net.Http.WebAssemblyHttpHandler.Framework\System.Net.Http.WebAssemblyHttpHandler.csproj", "{F905CB2B-2EC2-4375-AC10-07F98E27822D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAssembly.Bindings", "WebAssembly.Bindings.Framework\WebAssembly.Bindings.csproj", "{B8FDEB6F-F3CF-4C39-9275-C47CC1D34F22}" EndProject diff --git a/sdks/wasm/sdk/WebAssembly.Net.Http.Framework/WebAssembly.Net.Http.csproj b/sdks/wasm/sdk/System.Net.Http.WebAssemblyHttpHandler.Framework/System.Net.Http.WebAssemblyHttpHandler.csproj similarity index 53% rename from sdks/wasm/sdk/WebAssembly.Net.Http.Framework/WebAssembly.Net.Http.csproj rename to sdks/wasm/sdk/System.Net.Http.WebAssemblyHttpHandler.Framework/System.Net.Http.WebAssemblyHttpHandler.csproj index bf1627fc5ec..7ffeb982187 100644 --- a/sdks/wasm/sdk/WebAssembly.Net.Http.Framework/WebAssembly.Net.Http.csproj +++ b/sdks/wasm/sdk/System.Net.Http.WebAssemblyHttpHandler.Framework/System.Net.Http.WebAssemblyHttpHandler.csproj @@ -7,9 +7,9 @@ true - - - + + + diff --git a/sdks/wasm/src/driver.c b/sdks/wasm/src/driver.c index 1a6ff36d448..9a24ce42901 100644 --- a/sdks/wasm/src/driver.c +++ b/sdks/wasm/src/driver.c @@ -313,6 +313,7 @@ icall_table_lookup_symbol (void *func) void mono_initialize_internals () { mono_add_internal_call ("WebAssembly.Runtime::InvokeJS", mono_wasm_invoke_js); + // TODO: what happens when two types in different assemblies have the same FQN? // Blazor specific custom routines - see dotnet_support.js for backing code mono_add_internal_call ("WebAssembly.JSInterop.InternalCalls::InvokeJSMarshalled", mono_wasm_invoke_js_marshalled); diff --git a/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec-with-prom-lib.js b/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec-with-prom-lib.js index a0c302992a9..792338024b2 100644 --- a/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec-with-prom-lib.js +++ b/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec-with-prom-lib.js @@ -1,18 +1,18 @@ //describe, beforeAll, it, expect - are the Jasmine default methods //karmaHTML is the karma-html package object with the access to all its features - + describe("The WebAssembly Http Test Suite with Promise Library",function(){ - + const DEFAULT_TIMEOUT = 1000; const DEFAULT_WS_TIMEOUT = 5000; beforeAll(function(done){ //load DOM custom matchers from karma-jasmine-dom package jasmine.addMatchers(DOMCustomMatchers); - + //lets open our 'http-spec.html' file in the browser by 'index' tag as you specified in 'karma.conf.js' karmaHTML.httpspecwithpromlib.open(); - + //karmaHTML.httpspecwithpromlib.onstatechange fires when the Document is loaded //now the tests can be executed on the DOM karmaHTML.httpspecwithpromlib.onstatechange = function(ready){ @@ -28,40 +28,25 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ }; }); - + it("should be a real Document object with Promise",function(){ var _document = karmaHTML.httpspecwithpromlib.document; expect(_document.constructor.name).toEqual('HTMLDocument'); }); - it('should support streaming', () => { - //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file - var _document = karmaHTML.httpspecwithpromlib.document; - - assert.equal(_document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:IsStreamingSupported", []), true); - }); - - - it('should have streaming enabled', () => { - //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file - var _document = karmaHTML.httpspecwithpromlib.document; - - assert.equal(_document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:IsStreamingEnabled", []), true); - }); - it('should have base path', () => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; assert.equal(_document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:BasePath", []), "http://localhost:9876/"); - }); + }); it('RequestStream: should return size of Stream with streaming', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [true, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -74,7 +59,7 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + }, DEFAULT_TIMEOUT); it('RequestStream: blob should return size of Stream with streaming', (done) => { @@ -82,9 +67,9 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ var _document = karmaHTML.httpspecwithpromlib.document; var blob = new Blob([JSON.stringify({hello: "world"}, null, 2)], {type : 'application/json'}); var blobUrl = URL.createObjectURL(blob); - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [true, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -97,16 +82,16 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); }, DEFAULT_TIMEOUT); it('RequestByteArray: should return size of ByteArray with streaming', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [true, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -119,7 +104,7 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + }, DEFAULT_TIMEOUT); it('RequestByteArray: blob should return size of ByteArray with streaming', (done) => { @@ -129,7 +114,7 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ var blobUrl = URL.createObjectURL(blob); _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [true, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -142,16 +127,16 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); }, DEFAULT_TIMEOUT); it('RequestStream: should return size of Stream without streaming', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [false, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -164,8 +149,8 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('RequestStream: blob should return size of Stream without streaming', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file @@ -174,7 +159,7 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ var blobUrl = URL.createObjectURL(blob); _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [false, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -187,16 +172,16 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); - }, DEFAULT_TIMEOUT); + }, DEFAULT_TIMEOUT); it('RequestByteArray: should return size of ByteArray without streaming', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [false, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -209,7 +194,7 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + }, DEFAULT_TIMEOUT); it('RequestByteArray: blob should return size of ByteArray without streaming', (done) => { @@ -219,7 +204,7 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ var blobUrl = URL.createObjectURL(blob); _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [false, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -232,16 +217,16 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); }, DEFAULT_TIMEOUT); it('GetStreamAsync_ReadZeroBytes_Success: should return 0', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:GetStreamAsync_ReadZeroBytes_Success", []).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -254,15 +239,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('ConnectWebSocketStatus: should return Error Code 1006 because unresolved host.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatus", ["ws://localhost", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -274,15 +259,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); - + + }, DEFAULT_WS_TIMEOUT); + it('ConnectWebSocketStatus: should return Error Code 1006 because of invalid protocol.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatus", ["ws://localhost:8889", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -294,15 +279,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); + + }, DEFAULT_WS_TIMEOUT); it('ConnectWebSocketStatusWithToken: should return Error Code 1006 because unresolved host.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatusWithToken", ["ws://localhost", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -314,15 +299,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); - + + }, DEFAULT_WS_TIMEOUT); + it('ConnectWebSocketStatusWithToken: should return Error Code 1006 because of invalid protocol.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatusWithToken", ["ws://localhost:8889", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -334,15 +319,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); + + }, DEFAULT_WS_TIMEOUT); it('OpenWebSocket: should return Open.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:OpenWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { assert.equal(result, 'Open', "result doesn't match expected result Open."); @@ -354,15 +339,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); - + + }, DEFAULT_TIMEOUT); + it('CloseWebSocket: should return Closed.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:CloseWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { assert.equal(result, 'Closed', "result doesn't match expected result Closed."); @@ -374,16 +359,16 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); - + }, DEFAULT_TIMEOUT); + + it('ReceiveHostCloseWebSocket: should return Closed.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ReceiveHostCloseWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { assert.equal(result, 'Closed', "result doesn't match expected result Closed."); @@ -395,15 +380,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('CloseStatusDescCloseWebSocket: should return Close Code and Description.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:CloseStatusDescCloseWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { var resultObj = JSON.parse(result); @@ -417,15 +402,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('WebSocketSendText: should return echoed text.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:WebSocketSendText", ["ws://localhost:8889", "echo-protocol", "Hello WebSockets"]).then( - (result) => + (result) => { try { assert.equal(result, 'Hello WebSockets', "result does not match Hello WebSockets."); @@ -437,15 +422,15 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('WebSocketSendBinary: should return echoed text.', (done) => { //karmaHTML.httpspecwithpromlib.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspecwithpromlib.document; var binBuffer = new Uint8Array([49,50,51,52,53,54,55,56,57]) _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:WebSocketSendBinary", ["ws://localhost:8889", "echo-protocol", "Hello WebSockets"]).then( - (result) => + (result) => { try { assert.equal(result, 'Hello WebSockets', "result does not match Hello WebSockets."); @@ -457,6 +442,6 @@ describe("The WebAssembly Http Test Suite with Promise Library",function(){ (error) => done.fail(error) ); - }, DEFAULT_WS_TIMEOUT); - + }, DEFAULT_WS_TIMEOUT); + }); diff --git a/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec.js b/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec.js index bd00115a627..ce4467f5e11 100644 --- a/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec.js +++ b/sdks/wasm/tests/browser/src/BrowserTestSuite/http-spec.js @@ -1,18 +1,18 @@ //describe, beforeAll, it, expect - are the Jasmine default methods //karmaHTML is the karma-html package object with the access to all its features - + describe("The WebAssembly Http Test Suite",function(){ - + const DEFAULT_TIMEOUT = 1000; const DEFAULT_WS_TIMEOUT = 5000; beforeAll(function(done){ //load DOM custom matchers from karma-jasmine-dom package jasmine.addMatchers(DOMCustomMatchers); - + //lets open our 'http-spec.html' file in the browser by 'index' tag as you specified in 'karma.conf.js' karmaHTML.httpspec.open(); - + //karmaHTML.httpspec.onstatechange fires when the Document is loaded //now the tests can be executed on the DOM karmaHTML.httpspec.onstatechange = function(ready){ @@ -28,40 +28,25 @@ describe("The WebAssembly Http Test Suite",function(){ }; }); - + it("should be a real Document object",function(){ var _document = karmaHTML.httpspec.document; expect(_document.constructor.name).toEqual('HTMLDocument'); }); - it('should support streaming', () => { - //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file - var _document = karmaHTML.httpspec.document; - - assert.equal(_document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:IsStreamingSupported", []), true); - }); - - - it('should have streaming enabled', () => { - //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file - var _document = karmaHTML.httpspec.document; - - assert.equal(_document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:IsStreamingEnabled", []), true); - }); - it('should have base path', () => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; assert.equal(_document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:BasePath", []), "http://localhost:9876/"); - }); + }); it('RequestStream: should return size of Stream with streaming', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [true, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -74,7 +59,7 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + }, DEFAULT_TIMEOUT); it('RequestStream: blob should return size of Stream with streaming', (done) => { @@ -82,9 +67,9 @@ describe("The WebAssembly Http Test Suite",function(){ var _document = karmaHTML.httpspec.document; var blob = new Blob([JSON.stringify({hello: "world"}, null, 2)], {type : 'application/json'}); var blobUrl = URL.createObjectURL(blob); - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [true, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -97,16 +82,16 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); }, DEFAULT_TIMEOUT); it('RequestByteArray: should return size of ByteArray with streaming', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [true, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -119,7 +104,7 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + }, DEFAULT_TIMEOUT); it('RequestByteArray: blob should return size of ByteArray with streaming', (done) => { @@ -129,7 +114,7 @@ describe("The WebAssembly Http Test Suite",function(){ var blobUrl = URL.createObjectURL(blob); _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [true, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -142,16 +127,16 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); }, DEFAULT_TIMEOUT); it('RequestStream: should return size of Stream without streaming', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [false, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -164,8 +149,8 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('RequestStream: blob should return size of Stream without streaming', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file @@ -174,7 +159,7 @@ describe("The WebAssembly Http Test Suite",function(){ var blobUrl = URL.createObjectURL(blob); _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestStream", [false, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -187,16 +172,16 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); - }, DEFAULT_TIMEOUT); + }, DEFAULT_TIMEOUT); it('RequestByteArray: should return size of ByteArray without streaming', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [false, "base/publish/NowIsTheTime.txt"]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -209,7 +194,7 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + }, DEFAULT_TIMEOUT); it('RequestByteArray: blob should return size of ByteArray without streaming', (done) => { @@ -219,7 +204,7 @@ describe("The WebAssembly Http Test Suite",function(){ var blobUrl = URL.createObjectURL(blob); _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:RequestByteArray", [false, blobUrl]).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -232,16 +217,16 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - + URL.revokeObjectURL(blobUrl); }, DEFAULT_TIMEOUT); it('GetStreamAsync_ReadZeroBytes_Success: should return 0', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[HttpTestSuite]TestSuite.Program:GetStreamAsync_ReadZeroBytes_Success", []).then( - (result) => + (result) => { //console.log("we are here: " + result); try { @@ -254,15 +239,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('ConnectWebSocketStatus: should return Error Code 1006 because unresolved host.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatus", ["ws://localhost", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -274,15 +259,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); - + + }, DEFAULT_WS_TIMEOUT); + it('ConnectWebSocketStatus: should return Error Code 1006 because of invalid protocol.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatus", ["ws://localhost:8889", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -294,15 +279,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); + + }, DEFAULT_WS_TIMEOUT); it('ConnectWebSocketStatusWithToken: should return Error Code 1006 because unresolved host.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatusWithToken", ["ws://localhost", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -314,15 +299,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); - + + }, DEFAULT_WS_TIMEOUT); + it('ConnectWebSocketStatusWithToken: should return Error Code 1006 because of invalid protocol.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ConnectWebSocketStatusWithToken", ["ws://localhost:8889", ""]).then( - (result) => + (result) => { try { assert.equal(result, '1006', "result doesn't match expected result 1006."); @@ -334,15 +319,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_WS_TIMEOUT); + + }, DEFAULT_WS_TIMEOUT); it('OpenWebSocket: should return Open.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:OpenWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { assert.equal(result, 'Open', "result doesn't match expected result Open."); @@ -354,15 +339,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); - + + }, DEFAULT_TIMEOUT); + it('CloseWebSocket: should return Closed.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:CloseWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { assert.equal(result, 'Closed', "result doesn't match expected result Closed."); @@ -374,16 +359,16 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); - + }, DEFAULT_TIMEOUT); + + it('ReceiveHostCloseWebSocket: should return Closed.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:ReceiveHostCloseWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { assert.equal(result, 'Closed', "result doesn't match expected result Closed."); @@ -395,15 +380,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('CloseStatusDescCloseWebSocket: should return Close Code and Description.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:CloseStatusDescCloseWebSocket", ["ws://localhost:8889", "echo-protocol"]).then( - (result) => + (result) => { try { var resultObj = JSON.parse(result); @@ -417,15 +402,15 @@ describe("The WebAssembly Http Test Suite",function(){ (error) => done.fail(error) ); - - }, DEFAULT_TIMEOUT); + + }, DEFAULT_TIMEOUT); it('WebSocketSendText: should return echoed text.', (done) => { //karmaHTML.httpspec.document gives the access to the Document object of 'http-spec.html' file var _document = karmaHTML.httpspec.document; - + _document.Module.BINDING.call_static_method("[WebSocketTestSuite]TestSuite.Program:WebSocketSendText", ["ws://localhost:8889", "echo-protocol", "Hello WebSockets"]).then( - (result) => + (result) => { try { assert.equal(result, 'Hello WebSockets', "result does not match Hello WebSockets."); diff --git a/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.cs b/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.cs index c04ec247d0a..b7cd390ef65 100644 --- a/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.cs +++ b/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.cs @@ -1,6 +1,5 @@ using System; using System.Net.Http; -using WebAssembly.Net.Http.HttpClient; using System.Threading.Tasks; using WebAssembly; using System.Threading; @@ -12,18 +11,6 @@ namespace TestSuite { static CancellationTokenSource cts = null; - public static bool IsStreamingSupported() - { - using (HttpClient httpClient = CreateHttpClient()) - return WasmHttpMessageHandler.StreamingSupported; - } - - public static bool IsStreamingEnabled() - { - using (HttpClient httpClient = CreateHttpClient()) - return WasmHttpMessageHandler.StreamingEnabled; - } - public static string BasePath() { using (HttpClient httpClient = CreateHttpClient()) @@ -39,10 +26,9 @@ namespace TestSuite { using (HttpClient httpClient = CreateHttpClient()) { - Console.WriteLine($"streaming supported: { WasmHttpMessageHandler.StreamingSupported}"); - WasmHttpMessageHandler.StreamingEnabled = streamingEnabled; - Console.WriteLine($"streaming enabled: {WasmHttpMessageHandler.StreamingEnabled}"); - using (var rspMsg = await httpClient.GetAsync(url, cts.Token)) + var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); + httpRequestMessage.Properties["WebAssemblyEnableStreamingResponse"] = streamingEnabled; + using (var rspMsg = await httpClient.SendAsync(httpRequestMessage, cts.Token)) { requestTcs.SetResult((int)rspMsg.Content?.ReadAsStreamAsync().Result.Length); } @@ -65,12 +51,11 @@ namespace TestSuite { using (HttpClient httpClient = CreateHttpClient()) { - Console.WriteLine($"streaming supported: { WasmHttpMessageHandler.StreamingSupported}"); - WasmHttpMessageHandler.StreamingEnabled = streamingEnabled; - Console.WriteLine($"streaming enabled: {WasmHttpMessageHandler.StreamingEnabled}"); + var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); + httpRequestMessage.Properties["WebAssemblyEnableStreamingResponse"] = streamingEnabled; Console.WriteLine($"url: {url}"); - using (var rspMsg = await httpClient.GetAsync(url, cts.Token)) + using (var rspMsg = await httpClient.SendAsync(httpRequestMessage, cts.Token)) { requestTcs.SetResult(rspMsg.Content?.ReadAsByteArrayAsync().Result.Length); } @@ -88,9 +73,15 @@ namespace TestSuite var requestTcs = new TaskCompletionSource(); using (HttpClient client = CreateHttpClient()) - using (Stream stream = await client.GetStreamAsync("base/publish/NowIsTheTime.txt")) { - requestTcs.SetResult(await stream.ReadAsync(new byte[1], 0, 0)); + var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "base/publish/NowIsTheTime.txt"); + httpRequestMessage.Properties["WebAssemblyEnableStreamingResponse"] = true; + + using (var response = await client.SendAsync(httpRequestMessage)) + using (Stream stream = await response.Content.ReadAsStreamAsync()) + { + requestTcs.SetResult(await stream.ReadAsync(new byte[1], 0, 0)); + } } return requestTcs.Task; @@ -105,8 +96,7 @@ namespace TestSuite { BaseApiUrl = (string)location.GetObjectProperty("origin"); } - WasmHttpMessageHandler.StreamingEnabled = true; return new HttpClient() { BaseAddress = new Uri(BaseApiUrl) }; } } -} +} \ No newline at end of file diff --git a/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.csproj b/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.csproj index e0d123ccbc6..bf80ea24ab0 100644 --- a/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.csproj +++ b/sdks/wasm/tests/browser/src/HttpTestSuite/HttpTestSuite.csproj @@ -20,7 +20,7 @@ - + diff --git a/sdks/wasm/tests/browser/src/IssuesTestSuite/IssuesTestSuite.csproj b/sdks/wasm/tests/browser/src/IssuesTestSuite/IssuesTestSuite.csproj index eae942f37d9..901f1d31cbc 100644 --- a/sdks/wasm/tests/browser/src/IssuesTestSuite/IssuesTestSuite.csproj +++ b/sdks/wasm/tests/browser/src/IssuesTestSuite/IssuesTestSuite.csproj @@ -20,7 +20,7 @@ - + diff --git a/sdks/wasm/tests/browser/src/Packages.props b/sdks/wasm/tests/browser/src/Packages.props index 7e3af1f6926..224a53c4cc3 100644 --- a/sdks/wasm/tests/browser/src/Packages.props +++ b/sdks/wasm/tests/browser/src/Packages.props @@ -2,8 +2,8 @@ - - + + \ No newline at end of file diff --git a/sdks/wasm/tests/browser/src/WebSocketTestSuite/WebSocketTestSuite.csproj b/sdks/wasm/tests/browser/src/WebSocketTestSuite/WebSocketTestSuite.csproj index eae942f37d9..901f1d31cbc 100644 --- a/sdks/wasm/tests/browser/src/WebSocketTestSuite/WebSocketTestSuite.csproj +++ b/sdks/wasm/tests/browser/src/WebSocketTestSuite/WebSocketTestSuite.csproj @@ -20,7 +20,7 @@ - + -- 2.11.4.GIT