mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-17 06:29:57 +02:00
Remove an approximate two second delay in response to the first request from a new socket connection, only occuring on some Windows 10 machines. (#597)
A side-effect of this fix is that is also allows connections to IPv6 addresses.
This commit is contained in:
@@ -24,7 +24,7 @@ namespace WireMock.Owin
|
|||||||
{
|
{
|
||||||
if (urlDetail.IsHttps)
|
if (urlDetail.IsHttps)
|
||||||
{
|
{
|
||||||
kestrelOptions.Listen(System.Net.IPAddress.Any, urlDetail.Port, listenOptions =>
|
kestrelOptions.ListenAnyIP(urlDetail.Port, listenOptions =>
|
||||||
{
|
{
|
||||||
if (wireMockMiddlewareOptions.CustomCertificateDefined)
|
if (wireMockMiddlewareOptions.CustomCertificateDefined)
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace WireMock.Owin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kestrelOptions.Listen(System.Net.IPAddress.Any, urlDetail.Port);
|
kestrelOptions.ListenAnyIP(urlDetail.Port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace WireMock.Owin
|
|||||||
|
|
||||||
foreach (string address in addresses)
|
foreach (string address in addresses)
|
||||||
{
|
{
|
||||||
Urls.Add(address.Replace("0.0.0.0", "localhost"));
|
Urls.Add(address.Replace("0.0.0.0", "localhost").Replace("[::]", "localhost"));
|
||||||
|
|
||||||
PortUtils.TryExtract(address, out bool isHttps, out string protocol, out string host, out int port);
|
PortUtils.TryExtract(address, out bool isHttps, out string protocol, out string host, out int port);
|
||||||
Ports.Add(port);
|
Ports.Add(port);
|
||||||
|
|||||||
@@ -305,5 +305,51 @@ namespace WireMock.Net.Tests
|
|||||||
|
|
||||||
server.Stop();
|
server.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !NET452
|
||||||
|
[Fact]
|
||||||
|
public async Task WireMockServer_Should_respond_to_ipv4_loopback()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var server = WireMockServer.Start();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
.WithPath("/*"))
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithStatusCode(200)
|
||||||
|
.WithBody("from ipv4 loopback"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response = await new HttpClient().GetStringAsync($"http://127.0.0.1:{server.Ports[0]}/foo");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(response).IsEqualTo("from ipv4 loopback");
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WireMockServer_Should_respond_to_ipv6_loopback()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var server = WireMockServer.Start();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create()
|
||||||
|
.WithPath("/*"))
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithStatusCode(200)
|
||||||
|
.WithBody("from ipv6 loopback"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response = await new HttpClient().GetStringAsync($"http://[::1]:{server.Ports[0]}/foo");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(response).IsEqualTo("from ipv6 loopback");
|
||||||
|
|
||||||
|
server.Stop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user