The HttpClient.GetAsync method throws an OperationCanceledException when
the timeout is exceeded. In order to provide a more informative
exception, we will detect this case and throw a TimeoutException
instead.
This is related to issue #3772.
The HttpClient.SendAsync method throws an OperationCanceledException
when the timeout is exceeded. In order to provide a more informative
exception, we will detect this case and throw a TimeoutException
instead. This will also allow the BackendUploader to differentiate
between cancellations requested by the user and those generated by
an HTTP timeout.
Previously, a ThreadAbortException or OperationCanceledException would
be rethrown in the BackendUploader.DoWithRetry method. However, the
modifications made in revision 61f511c087
from pull request #3684 appear to have let this case slip through.
See the following links for more information:
https://stackoverflow.com/questions/10547895/how-can-i-tell-when-httpclient-has-timed-outhttps://thomaslevesque.com/2018/02/25/better-timeout-handling-with-httpclient
This addresses issue #3772.
When the code following the await can be executed on any thread, it's
recommended to use ConfigureAwait(false) to avoid unnecessary context
switching and potential deadlocks.
This class extends HttpClient and uses an OAuthHttpMessageHandler under the covers to automatically authenticate requests.
Additionally, it automatically respects the global HttpContextSettings for overall timeout, read/write timeout, and SSL certificate validation.
(BufferRequests isn't currently handled, as HttpClient doesn't seem to easily expose that flag, and as of .NET 4.5, seems to not buffer by default.)