public void Test() { var serverPort = UoeDatabaseOperator.GetNextAvailablePort(1050); var proxyPort = UoeDatabaseOperator.GetNextAvailablePort(serverPort + 1); // hostname to use // we need something different than 127.0.0.1 or localhost for the proxy! IPHostEntry hostEntry; try { hostEntry = Dns.GetHostEntry("mylocalhost"); } catch (Exception) { hostEntry = null; } var host = hostEntry == null ? "127.0.0.1" : "mylocalhost"; var archiver = Archiver.NewHttpFileServerArchiver(); Assert.IsNotNull(archiver); var baseDir = Path.Combine(TestFolder, "http"); archiver.SetProxy($"http://{host}:{proxyPort}/", "jucai69d", "julien caillon"); archiver.SetBasicAuthentication("admin", "admin123"); var listFiles = GetPackageTestFilesList(TestFolder, $"http://{host}:{serverPort}/server1"); listFiles.AddRange(GetPackageTestFilesList(TestFolder, $"http://{host}:{serverPort}/server2")); var fileServer = new SimpleHttpFileServer(baseDir, "admin", "admin123"); var proxyServer = new SimpleHttpProxyServer("jucai69d", "julien caillon"); var cts = new CancellationTokenSource(); var task1 = HttpServer.ListenAsync(serverPort, cts.Token, fileServer.OnHttpRequest, true); var task2 = HttpServer.ListenAsync(proxyPort, cts.Token, proxyServer.OnHttpRequest, true); PartialTestForHttpFileServer(archiver, listFiles); if (!host.Equals("127.0.0.1")) { Assert.AreEqual(61, proxyServer.NbRequestsHandledOk); } HttpServer.Stop(cts, task1, task2); }