React to Uri scope break

This commit is contained in:
Chris Ross (ASP.NET) 2018-06-04 11:08:32 -07:00 committed by Chris Ross
parent 40d1b75272
commit bac99ad086
1 changed files with 11 additions and 3 deletions

View File

@ -169,9 +169,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
{
var response = await HttpClientSlim.GetStringAsync(testUrl, validateCertificate: false);
// Compare the response with Uri.ToString(), rather than testUrl directly.
// Required to handle IPv6 addresses with zone index, like "fe80::3%1"
Assert.Equal(new Uri(testUrl).ToString(), response);
// Filter out the scope id for IPv6, that's not sent over the wire. "fe80::3%1"
// See https://github.com/aspnet/Common/pull/369
var uri = new Uri(testUrl);
if (uri.HostNameType == UriHostNameType.IPv6)
{
var builder = new UriBuilder(uri);
var ip = IPAddress.Parse(builder.Host);
builder.Host = new IPAddress(ip.GetAddressBytes()).ToString(); // Without the scope id.
uri = builder.Uri;
}
Assert.Equal(uri.ToString(), response);
}
}
}