nextcloud/windows-universal

Use `System.Net.Http` instead of `Windows.Web.Http`

Opened this issue · 4 comments

In Windows 10, the implementation of the System.Net.Http API for UWP has been changed to layer it on top of Windows.Web.Http and the WinINet HTTP stack of Windows.

System.Net.Http seems more general and more widely used. We should change our implementation to use the "new" API.

See: Demystifying HttpClient APIs in the Universal Windows Platform

HTTP/2 Support (Windows 10)

HTTP/2 is a new version of the HTTP protocol that provides much better connection utilization (fewer round-trips between client and server), resulting in lower latency web page loading for users. Web pages (as opposed to services) benefit the most from HTTP/2, since the protocol optimizes for multiple artifacts being requested as part of a single experience. HTTP/2 support has been added to ASP.NET in the .NET Framework 4.6. Because networking functionality exists at multiple layers, new features were required in Windows, in IIS, and in ASP.NET to enable HTTP/2. You must be running on Windows 10 to use HTTP/2 with ASP.NET.

HTTP/2 is also supported and on by default for Windows 10 Universal Windows Platform (UWP) apps that use the System.Net.Http.HttpClient API.
➡️ What's new in the .NET Framework

System.Net.Http is implemented atop of Windows.Web.Http

For example, here's a stacktrace:

>	KernelBase.dll!RaiseException�()	Unknown	Non-user code. Symbols loaded.
 	combase.dll!SendReport(HRESULT error=0x8000000b, unsigned int cchMax=0, const wchar_t * message=0x00007ff854b2d8e4, unsigned short pSid=0x0000000000000000, void * pExceptionObject=0x0000000000000000, IUnknown *) Line 438	C++	Non-user code. Symbols loaded.
 	combase.dll!RoOriginateError(HRESULT error=0x8000000b, HSTRING__ * message) Line 590	C++	Non-user code. Symbols loaded.
 	Windows.Web.Http.dll!Windows::Foundation::Collections::Internal::HashMap<struct HSTRING__ *,struct HSTRING__ *,struct StringCaseInsensitiveHash,struct StringCaseInsensitiveEquals,struct Windows::Foundation::Collections::Internal::DefaultLifetimeTraits<struct HSTRING__ *>,struct Windows::Foundation::Collections::Internal::DefaultLifetimeTraits<struct HSTRING__ *>,struct Windows::Foundation::Collections::Internal::HashMapOptions<struct HSTRING__ *,struct HSTRING__ *,struct Windows::Foundation::Collections::Internal::DefaultLifetimeTraits<struct HSTRING__ *>,0,1,0> >::Remove(struct HSTRING__ *)	Unknown	Non-user code. Symbols loaded.
 	Windows.Web.Http.dll!HttpHeaderCollectionBase::Remove(struct HSTRING__ *)	Unknown	Non-user code. Symbols loaded.
 	Windows.Web.Http.dll!HttpHeaderCollectionBase::TryRemoveHeaderValueInfo(struct HSTRING__ *)	Unknown	Non-user code. Symbols loaded.
 	Windows.Web.Http.dll!HttpHeaderCollectionBase::SetParsedValue(unsigned short const *,struct IInspectable *)	Unknown	Non-user code. Symbols loaded.
 	[Managed to Native Transition]		Annotated Frame
 	System.Net.Http.dll!System.Net.Http.HttpHandlerToFilter.CreateRequestContentAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, Windows.Web.Http.Headers.HttpRequestHeaderCollection rtHeaderCollection = {Windows.Web.Http.Headers.HttpRequestHeaderCollection})	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Net.Http.HttpHandlerToFilter.<CreateRequestContentAsync>d__19>(ref System.Net.Http.HttpHandlerToFilter.<CreateRequestContentAsync>d__19 stateMachine)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpHandlerToFilter.CreateRequestContentAsync(System.Net.Http.HttpRequestMessage request, Windows.Web.Http.Headers.HttpRequestHeaderCollection rtHeaderCollection)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpHandlerToFilter.ConvertRequestAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Net.Http.HttpMethod httpMethod = {System.Net.Http.HttpMethod}, bool skipRequestContentIfPresent = false)	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Net.Http.HttpHandlerToFilter.<ConvertRequestAsync>d__18>(ref System.Net.Http.HttpHandlerToFilter.<ConvertRequestAsync>d__18 stateMachine)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpHandlerToFilter.ConvertRequestAsync(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpMethod httpMethod, bool skipRequestContentIfPresent)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpHandlerToFilter.SendAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Threading.CancellationToken cancel = IsCancellationRequested = false)	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Net.Http.HttpHandlerToFilter.<SendAsync>d__15>(ref System.Net.Http.HttpHandlerToFilter.<SendAsync>d__15 stateMachine)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpHandlerToFilter.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancel)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpClientHandler.SendAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Threading.CancellationToken cancellationToken = IsCancellationRequested = false)	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Net.Http.HttpClientHandler.<SendAsync>d__111>(ref System.Net.Http.HttpClientHandler.<SendAsync>d__111 stateMachine)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpClientHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Http.dll!System.Net.Http.HttpClient.SendAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Net.Http.HttpCompletionOption completionOption = ResponseHeadersRead, System.Threading.CancellationToken cancellationToken)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Requests.dll!System.Net.HttpWebRequest.SendRequest()	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Net.HttpWebRequest.<SendRequest>d__194>(ref System.Net.HttpWebRequest.<SendRequest>d__194 stateMachine)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Requests.dll!System.Net.HttpWebRequest.SendRequest()	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Requests.dll!System.Net.HttpWebRequest.BeginGetResponse(System.AsyncCallback callback = {System.AsyncCallback}, object state = {System.Net.HttpWebRequest})	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Threading.Tasks.TaskFactory<System.Net.WebResponse>.FromAsyncImpl(System.Func<System.AsyncCallback, object, System.IAsyncResult> beginMethod, System.Func<System.IAsyncResult, System.Net.WebResponse> endFunction, System.Action<System.IAsyncResult> endAction, object state, System.Threading.Tasks.TaskCreationOptions creationOptions)	Unknown	Non-user code. Skipped loading symbols.
 	System.Net.Requests.dll!System.Net.WebRequest.GetResponseAsync.AnonymousMethod__68_0()	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.Task<System.Net.WebResponse>>.InnerInvoke()	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot = Id = 3324, Status = Running, Method = Inspecting the state of an object in the debuggee of type System.Delegate is not supported in this context., Result = Cannot evaluate expression because a native frame is on the top of the call stack.)	Unknown	Non-user code. Skipped loading symbols.
 	System.Private.CoreLib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()	Unknown	Non-user code. Skipped loading symbols.

@mqudsi it depends the runtime(uwp,.net frm, .net core, xamarin, etc). Windows.Web.Http is windows specific. Using System.Net.Http you can target all the .net ecosystem.