/* * Copyright (c) 2018, 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 Verify that non-US-ASCII chars are replaced with a sequence of * escaped octets that represent that char in the UTF-8 character set. * @bug 8201238 * @modules java.base/sun.net.www.http * 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 * jdk.httpserver * @library /test/lib http2/server * @build Http2TestServer * @build jdk.test.lib.net.SimpleSSLContext * @compile -encoding utf-8 NonAsciiCharsInURI.java * @run testng/othervm * -Djdk.httpclient.HttpClient.log=reqeusts,headers * NonAsciiCharsInURI
*/
staticfinalint ITERATION_COUNT = 3; // checks upgrade and re-use
@Test(dataProvider = "variants") void test(String uriString, boolean sameClient) throws Exception {
out.println("\n--- Starting "); // The single-argument factory requires any illegal characters in its // argument to be quoted and preserves any escaped octets and other // characters that are present.
URI uri = URI.create(uriString);
// the response body should contain the toASCIIString // representation of the URI
String expectedURIString = uri.toASCIIString(); if (!expectedURIString.contains(resp.body())) {
err.println("Test failed: " + resp); thrownew AssertionError(expectedURIString + " does not contain '" + resp.body() + "'");
} else {
out.println("Found expected " + resp.body() + " in " + expectedURIString);
}
}
}
@Test(dataProvider = "variants") void testAsync(String uriString, boolean sameClient) {
out.println("\n--- Starting ");
URI uri = URI.create(uriString);
/** A handler that returns, as its body, the exact received request URI. */ staticclass HttpUriStringHandler implements HttpTestHandler {
@Override publicvoid handle(HttpTestExchange t) throws IOException {
String uri = t.getRequestURI().toString();
out.println("Http1UriStringHandler received, uri: " + uri); try (InputStream is = t.getRequestBody();
OutputStream os = t.getResponseBody()) {
is.readAllBytes(); byte[] bytes = uri.getBytes(US_ASCII);
t.sendResponseHeaders(200, bytes.length);
os.write(bytes);
}
}
}
}
¤ 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.0.33Bemerkung:
(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.