/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
publicstaticvoid main(String[] args) { for (TestCase t : emptyNonProxiesHosts()) t.run(); for (TestCase t : nonEmptyNonProxiesHosts()) t.run(); for (TestCase t : misc()) t.run();
}
// Setting http.nonProxyHosts to an empty string has an effect of // not including default hosts to the list of exceptions // (i.e. if you want everything to be connected directly rather than // through proxy, you should set this property to an empty string) privatestatic Collection<TestCase> emptyNonProxiesHosts() {
List<TestCase> tests = new LinkedList<>();
String[] loopbacks = {"localhost", "[::1]", "[::0]", "0.0.0.0", "127.0.0.0", "127.0.0.1", "127.0.1.0", "127.0.1.1", "127.1.0.0", "127.1.0.1", "127.1.1.0", "127.1.1.1"};
Map<String, String> properties = new HashMap<>();
properties.put("http.proxyHost", "http://proxy.example.com");
properties.put("http.nonProxyHosts", ""); for (String s : loopbacks) {
tests.add(new TestCase(properties, "http://" + s, true));
} return tests;
}
// No matter what is set into the http.nonProxyHosts (as far as it is not // an empty string) loopback address aliases must be always connected // directly privatestatic Collection<TestCase> nonEmptyNonProxiesHosts() {
List<TestCase> tests = new LinkedList<>();
String[] nonProxyHosts = { "google.com", "localhost", "[::1]", "[::0]", "0.0.0.0", "127.0.0.0", "127.0.0.1", "127.0.1.0", "127.0.1.1", "127.1.0.0", "127.1.0.1", "127.1.1.0", "127.1.1.1"};
String[] loopbacks = {"localhost", "[::1]", "[::0]", "0.0.0.0", "127.0.0.0", "127.0.0.1", "127.0.1.0", "127.0.1.1", "127.1.0.0", "127.1.0.1", "127.1.1.0", "127.1.1.1"}; for (String h : nonProxyHosts) { for (String s : loopbacks) {
Map<String, String> properties = new HashMap<>();
properties.put("http.proxyHost", "http://proxy.example.com");
properties.put("http.nonProxyHosts", h);
tests.add(new TestCase(properties, "http://" + s, false));
}
} return tests;
}
// unsorted tests privatestatic Collection<TestCase> misc() {
List<TestCase> t = new LinkedList<>();
t.add(new TestCase("oracle.com", "http://137.254.16.101", true));
t.add(new TestCase("google.com", "http://74.125.200.101", true));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.