Compare commits

...

2 Commits

Author SHA1 Message Date
Stef Heyenrath
9b09a0ae00 . 2024-05-05 09:45:18 +02:00
Stef Heyenrath
ad040fb63c Proxying should keep url encoding 2024-05-05 09:44:56 +02:00

View File

@@ -967,4 +967,44 @@ public class WireMockServerProxyTests
server.Dispose();
}
// #1097
// https://stackoverflow.com/questions/52106567/how-to-stop-httprequestmessage-from-unencoding-3a-to-a-colon-in-the-request-uri
[Fact]
public async Task WireMockServer_Proxy_Should_Keep_UrlEncoding()
{
// Assign
string path = $"/prx_{Guid.NewGuid()}";
var serverForProxyForwarding = WireMockServer.Start();
serverForProxyForwarding
.Given(Request.Create().WithPath(path))
.RespondWith(Response.Create());
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
Url = serverForProxyForwarding.Urls[0],
SaveMapping = true,
SaveMappingToFile = false
}
};
var server = WireMockServer.Start(settings);
// Act
var requestUri = $"{server.Urls[0]}{path}with%20space_and_%3A_colon";
var requestMessage = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri(requestUri)
};
await new HttpClient().SendAsync(requestMessage).ConfigureAwait(false);
// Assert
var receivedRequest = serverForProxyForwarding.LogEntries.First().RequestMessage;
receivedRequest.AbsolutePath.Should().EndWith("with space_and_:_colon");
// check that new proxied mapping is added
server.Mappings.Should().HaveCount(2);
}
}