From a51ffdb15d023f772f2e51a461781a02191ca65a Mon Sep 17 00:00:00 2001 From: Pavlacky Tomas Date: Wed, 13 Apr 2022 16:46:52 +0200 Subject: [PATCH] Added ConfigureAwait(false) to all await calls to prevent deadlock in case when this would be called from e.g. UI thread in synchronous way (e.g. via .Result) --- src/DigestAuthenticator/DigestAuthenticator.cs | 2 +- src/DigestAuthenticator/DigestAuthenticatorManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DigestAuthenticator/DigestAuthenticator.cs b/src/DigestAuthenticator/DigestAuthenticator.cs index 3329fdb..3c3a287 100644 --- a/src/DigestAuthenticator/DigestAuthenticator.cs +++ b/src/DigestAuthenticator/DigestAuthenticator.cs @@ -34,7 +34,7 @@ public async ValueTask Authenticate(RestClient client, RestRequest request) { var uri = client.BuildUri(request); var manager = new DigestAuthenticatorManager(client.BuildUri(new RestRequest()), _username, _password, Timeout); - await manager.GetDigestAuthHeader(uri.PathAndQuery, request.Method); + await manager.GetDigestAuthHeader(uri.PathAndQuery, request.Method).ConfigureAwait(false); var digestHeader = manager.GetDigestHeader(uri.PathAndQuery, request.Method); request.AddOrUpdateHeader("Connection", "Keep-Alive"); request.AddOrUpdateHeader(KnownHeaders.Authorization, digestHeader); diff --git a/src/DigestAuthenticator/DigestAuthenticatorManager.cs b/src/DigestAuthenticator/DigestAuthenticatorManager.cs index b2218b4..d1b6b87 100644 --- a/src/DigestAuthenticator/DigestAuthenticatorManager.cs +++ b/src/DigestAuthenticator/DigestAuthenticatorManager.cs @@ -79,7 +79,7 @@ public async Task GetDigestAuthHeader(string path, Method method) request.AddOrUpdateHeader("Accept-Encoding", "gzip, deflate, br"); request.Timeout = _timeout; using var client = new RestClient(); - var response = await client.ExecuteAsync(request); + var response = await client.ExecuteAsync(request).ConfigureAwait(false); GetDigestDataFromFailResponse(response); }