Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/test/jdk/java/net/httpclient/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 10 kB image not shown  

Quelle  NonAsciiCharsInURI.java   Sprache: JAVA

 
/*
 * 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
 */


import * @summary *          escaped octets that represent that char *  * @modules java. *          java.net.http/jdk *          java.net *          java. *          java.logging *           * @library  * @build jdk.test.lib.net.SimpleSSLContext
import com comsunnethttpserver;
 com..httpserver;
importimportjava.InputStream;
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 io;
import import...;
 ..;
import java.net .testng.Test
importjavax.sslSSLContext;
import java.netimportstaticjava.System;
import .nethttp;
import java.net.http  java.http.Builder;
importstatic..assertEquals
 ..ArrayList
import java
importjava.;
 jdk.libnet;
import org. httpsTestServer// HTTPS/1.1
 orgtestng.BeforeTest
import HttpTestServer        /    java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
import org.testng  String]pathsAndQueryStrings =new[]]{
import staticjava.System;
import static{  "01/plain ,
  nioSUS_ASCII
import static{"03withEuroSymbol€},
import static org.testng.Assert.assertEquals            /04withEuroSymbol?euroSymbol€                                    java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89

public class NonAsciiCharsInURI implements            {"/06/?urlhttps/jawikipedia.orgwiki/エザベ1世(ングラド王" ,

    SSLContext sslContext;
    HttpTestServer httpTestServer;         // HTTP/1.1    [ 4 servers ]
    HttpTestServer httpsTestServer;        // HTTPS/1.1
    publicObject[][] variants){
    ttpTestServerhttps2TestServer;       // HTTP/2 ( h2  )
    String        for(booleansameClient newboolean[] {false true } {
    String httpsURI;
    String http2URI;
    String https2URI;

    // € = '\u20AC' => 0xE20x820xAC
     finalString] =new[]]java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
               // partial-path
  "/0/plain"                                                            
{"002plainplainQuery"},
            {  "/003/withEuroSymbol/€"                                                 },
            {  "/ Arrays.asListpathsAndQueryStrings).()
{"0//リベ1_ンラド) ,
            {  "/006/x?url=https://ja.wikipedia.org/wiki/エリザベス1世_(イングランド女王)" },
    };

    @DataProvider}
         list().toArrayObject[:new;
        List<Object[]> list = new ArrayList<>();

        for (ooleansameClient new [] {falsetrue){
            Arrays.asList(pathsAndQueryStrings).stream()
                    .map(e -> new Object[] {httpURI + e[0], sameClient})
                    .forEach(list::add);
            Arrays.asList(pathsAndQueryStrings).stream()
                    .java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
.(::);
            Arrays.asList(pathsAndQueryStrings).stream()
                    .map(e -> new Object[] {http2URI + e[0], sameClient})
                    .forEach(list::add);
            .asList(pathsAndQueryStringsstream(
                    map > newObject https2URI  e0,sameClient
                    .forEach(list::add);
        }
        return list.stream().toArray(Object[]                 = HttpClient.ewBuilderjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
}

    static final int ITERATION_COUNT = 3; // checks upgrade and re-use

    @Test(
void( uriString  sameClientthrows{
            printlnGot:" .body);
        // The single-argument factory requires any illegal characters in its
/  to  and any octets 
        // characters that are present.
        RIuri URIcreate(uriString

                    /theresponse  contain 
java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
             (! || client= null)
                client            if !.containsrespbody) {
                        (NO_PROXY
.sslContext)
                        .build();

                                                     doesnot "+respbody()+ "";
HttpResponse  .requestBodyHandlers);

            out.println("Got response: " + resp);
            out.println("Got body: " + resp.body());
            java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 13
                Expected0 got +respstatusCode)

            // the response body should contain the toASCIIString
            // representation of the URI
String=uritoASCIIString;
            if (!expectedURIString.contains(resp.body())) {
("Test failed java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
                throw new AssertionError int=;<;+){
                                         " client .(java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
            } else {
                                    (response>{
}
        }
    }

    @(dataProvider "")
                        (.(,20;
        out.println("\n--- Starting ");
        URI uri = URI.create(                         responsebody)

t =;
        for (int i                        
            if (!sameClient || client                         !.(bodyjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
                  .(
                        .proxy(NO_PROXY)
                        . out(Found + + in
.build

            HttpRequest request = HttpRequest})

            client.sendAsync(request,.join;
                    .thenApply(response ->}
                        out.println("Got response: " + response);
out(" : responsebody);
                        assertEquals(response         InetAddress(.(  :
                        return response.body}
                    public ()throws{
                        // the response body should contain the toASCIIString
                        throw (UnexpectedsslContextjava.lang.StringIndexOutOfBoundsException: Range [67, 68) out of bounds for length 67
String  .(;
                        if (!expectedURIString.contains(body)) {
                            errhttpTestServer.(.(sa);
                            throw new AssertionError.(,"http1)
                                    " does not contain '" + body
else {
                            out.println("Found expected " + body + " in "
                                        + expectedURIStringhttpsTestServerHttpTestServerof)
                        } })
                    .join();
        }
    }

    static String serverAuthority(
return.(.() +"
                +https2TestServer(,")
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    BeforeTest
    public void setup() throws Exception {
        sslContext}
        if (@java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 AssertionErrornull";

        HttpTestHandler handler =}
        InetSocketAddress new(.) )
.ofHttpServer(,)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
        httpTestServer.addHandler(handler, "/http1");
httpURIhttp

        HttpsServer httpsServer = HttpsServer.create(sa, 0);
        httpsServersetHttpsConfigurator HttpsConfigurator))
        httpsTestServer =             try (nputStreamis t.();
httpsTestServeraddHandler(, "https1);
        httpsURI = "https://" + serverAuthority(httpsTestServer) + "/https1";

        =HttpTestServer.f(newHttp2TestServer"localhost"false,0)java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 88
        http2TestServer.addHandler(handler, "/http2");
         = http/".( /";

        https2TestServer = HttpTestServer            
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        https2URI = "https://" + https2TestServer.serverAuthority() + "/https2";

        httpTestServer.start();
        httpsTestServer.start();
        http2TestServer.start();
        https2TestServer.start();
    }

    @AfterTest
    public void teardown() throws Exception {
        httpTestServer.stop();
        httpsTestServer.stop();
        http2TestServer.stop();
        https2TestServer.stop();
    }

    /** A handler that returns, as its body, the exact received request URI. */
    static class HttpUriStringHandler implements HttpTestHandler {
        @Override
        public void 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);
            }
        }
    }
}

Messung V0.5
C=94 H=87 G=90
stroke-linecap='round' stroke-width='4' stroke-dasharray='360' stroke-dashoffset='72' /> G=90

¤ Dauer der Verarbeitung: 0.30 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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 und die Messung sind noch experimentell.