/* * Copyright (c) 2018, 2019, 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.
*/
/** * @test * @summary This test verifies that if an h2 connection going through a * proxy P is downgraded to HTTP/1.1, then a new h2 request * going to a different host through the same proxy will not * be preemptively downgraded. That, is the stack should attempt * a new h2 connection to the new host. It also verifies that * the stack sends the appropriate "host" header to the proxy. * @bug 8196967 8222527 * @library /test/lib http2/server * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer HttpsTunnelTest * @modules java.net.http/jdk.internal.net.http.common * java.net.http/jdk.internal.net.http.frame * java.net.http/jdk.internal.net.http.hpack * java.logging * java.base/sun.net.www.http * java.base/sun.net.www * java.base/sun.net * @run main/othervm -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.debug=true HttpsTunnelTest * @run main/othervm -Dtest.requiresHost=true * -Djdk.httpclient.allowRestrictedHeaders=host * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.debug=true HttpsTunnelTest *
*/
staticfinal String data[] = { "Lorem ipsum", "dolor sit amet", "consectetur adipiscing elit, sed do eiusmod tempor", "quis nostrud exercitation ullamco", "laboris nisi", "ut", "aliquip ex ea commodo consequat." + "Duis aute irure dolor in reprehenderit in voluptate velit esse" + "cillum dolore eu fugiat nulla pariatur.", "Excepteur sint occaecat cupidatat non proident."
};
try {
URI uri1 = new URI("https://" + http1Server.serverAuthority() + "/foo/https1");
URI uri2 = new URI("https://" + http2Server.serverAuthority() + "/foo/https2");
/** * Builds a custom host string that is different to what is in the URI * authority, that is textually different than what the stack would * send. For CONNECT we should ignore any custom host settings. * The tunnelling proxy will fail with badRequest 400 if it receives * the custom host instead of the expected URI authority string. * @param server The target server. * @param uri The URI to the target server * @return a host value for the custom host header.
*/ staticfinal String makeCustomHostString(HttpTestServer server, URI uri) {
String customHttpHost; if (server.serverAuthority().contains("localhost")) {
customHttpHost = InetAddress.getLoopbackAddress().getHostAddress();
} else {
customHttpHost = InetAddress.getLoopbackAddress().getHostName();
} if (customHttpHost.contains(":")) customHttpHost = "[" + customHttpHost + "]"; if (uri.getPort() != -1) customHttpHost = customHttpHost + ":" + uri.getPort(); return customHttpHost;
}
}
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet)
¤
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.