+ [Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+ public void HttpRequestIsLocal ()
+ {
+ var port = NetworkHelpers.FindFreePort ();
+ var ips = new List<IPAddress> ();
+ ips.Add (IPAddress.Loopback);
+ foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces ()) {
+ foreach (var ip in adapter.GetIPProperties ().UnicastAddresses) {
+ ips.Add (ip.Address);
+ }
+ }
+
+ foreach (var ip in ips) {
+ if (ip.AddressFamily != AddressFamily.InterNetwork)
+ continue;
+
+ HttpListener listener = HttpListener2Test.CreateAndStartListener (
+ "http://" + ip + ":" + port + "/HttpRequestIsLocal/");
+ NetworkStream ns = HttpListener2Test.CreateNS (ip, port);
+ HttpListener2Test.Send (ns, "GET /HttpRequestIsLocal/ HTTP/1.0\r\n\r\n");
+ HttpListenerContext ctx = listener.GetContext ();
+ HttpListenerRequest request = ctx.Request;
+ Assert.AreEqual (true, request.IsLocal, "IP " + ip + " is not local");
+ listener.Close ();
+ }
+ }
+