From d9925a32fda53d8618f68d8110c213adc62869cd Mon Sep 17 00:00:00 2001 From: oliverpool Date: Mon, 1 Jun 2026 22:37:38 +0200 Subject: [PATCH] fix: throw an exception when an http request takes more than 5s When a server only listens on port 443, an http request on port 80 will hang forever, preventing the test from going further. --- src/OAuch/OAuch.Protocols/Http/HttpHelper.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OAuch/OAuch.Protocols/Http/HttpHelper.cs b/src/OAuch/OAuch.Protocols/Http/HttpHelper.cs index 988a732..8bbf065 100644 --- a/src/OAuch/OAuch.Protocols/Http/HttpHelper.cs +++ b/src/OAuch/OAuch.Protocols/Http/HttpHelper.cs @@ -170,8 +170,11 @@ async Task CreateRequest(string url, HttpMethods method, CookieC } private static async Task ReadResponse(WebRequest request, ParameterMule mule) { try { - using var response = await request.GetResponseAsync(); + using var response = await request.GetResponseAsync().WaitAsync(TimeSpan.FromSeconds(5)); return await ReadResponse(response as HttpWebResponse, mule); + } catch (TimeoutException) { + request.Abort(); + throw; } catch (WebException we) { if (we.Response is not HttpWebResponse er) throw;