diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseCachingTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseCachingTests.cs index f731bbdd63b2..1505fd1dba5c 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseCachingTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseCachingTests.cs @@ -560,13 +560,28 @@ public async Task Caching_SetTtlAndStatusCode_Cached() context.Response.CacheTtl = TimeSpan.FromSeconds(10); context.Dispose(); - var response = await responseTask; + HttpResponseMessage response; + try + { + response = await responseTask; + } + catch (Exception ex) + { + throw new Exception($"Failed to get first response for {status}", ex); + } Assert.Equal(status, (int)response.StatusCode); Assert.Equal(status.ToString(), response.Headers.GetValues("x-request-count").FirstOrDefault()); Assert.Equal(new byte[0], await response.Content.ReadAsByteArrayAsync()); // Send a second request and make sure we get the same response (without listening for one on the server). - response = await SendRequestAsync(address + status); + try + { + response = await SendRequestAsync(address + status); + } + catch (Exception ex) + { + throw new Exception($"Failed to get second response for {status}", ex); + } Assert.Equal(status, (int)response.StatusCode); Assert.Equal(status.ToString(), response.Headers.GetValues("x-request-count").FirstOrDefault()); Assert.Equal(new byte[0], await response.Content.ReadAsByteArrayAsync()); @@ -1137,7 +1152,7 @@ private async Task SendRequestAsync(string uri, string meth { using (var handler = new HttpClientHandler() { AllowAutoRedirect = false }) { - using (var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(5) }) + using (var client = new HttpClient(handler) { Timeout = Utilities.DefaultTimeout }) { var request = new HttpRequestMessage(new HttpMethod(method), uri); if (!string.IsNullOrEmpty(extraHeader))