mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-22 00:37:50 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b09a0ae00 | ||
|
|
ad040fb63c |
@@ -967,4 +967,44 @@ public class WireMockServerProxyTests
|
|||||||
|
|
||||||
server.Dispose();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user