From a612fc199cab2c2b5e83c07c70560d5ba4273a9e Mon Sep 17 00:00:00 2001 From: Richard Szalay Date: Tue, 3 Oct 2023 21:17:16 +1100 Subject: [PATCH] Fix matching of encoded URL paths --- .../Issues/Issue116Tests.cs | 24 +++++++++++++++++++ RichardSzalay.MockHttp/Matchers/UrlMatcher.cs | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 RichardSzalay.MockHttp.Tests/Issues/Issue116Tests.cs diff --git a/RichardSzalay.MockHttp.Tests/Issues/Issue116Tests.cs b/RichardSzalay.MockHttp.Tests/Issues/Issue116Tests.cs new file mode 100644 index 0000000..1914e37 --- /dev/null +++ b/RichardSzalay.MockHttp.Tests/Issues/Issue116Tests.cs @@ -0,0 +1,24 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using Xunit; + +namespace RichardSzalay.MockHttp.Tests.Issues; + +public class Issue116Tests +{ + // https://github.com/richardszalay/mockhttp/issues/116 + [Fact] + public async Task Can_simulate_timeout() + { + var handler = new MockHttpMessageHandler(); + + handler.When("/topics/$aws%2Fthings%2Ftest-host%2Fshadow%2Fname%2Ftest-shadow%2Fupdate") + .Respond(HttpStatusCode.OK); + + var client = new HttpClient(handler); + + var result = await client.GetAsync("http://localhost/topics/$aws%2Fthings%2Ftest-host%2Fshadow%2Fname%2Ftest-shadow%2Fupdate"); + } +} diff --git a/RichardSzalay.MockHttp/Matchers/UrlMatcher.cs b/RichardSzalay.MockHttp/Matchers/UrlMatcher.cs index c7edb2a..405add3 100644 --- a/RichardSzalay.MockHttp/Matchers/UrlMatcher.cs +++ b/RichardSzalay.MockHttp/Matchers/UrlMatcher.cs @@ -79,7 +79,7 @@ private string GetUrlToMatch(Uri input) string source = matchingFullUrl ? new UriBuilder(input) { Query = "" }.Uri.AbsoluteUri - : input.LocalPath; + : input.AbsolutePath; return source; }