test/jdk/java/net/httpclient/ConcurrentResponses.java
author chegar
Wed, 07 Feb 2018 21:45:37 +0000
branchhttp-client-branch
changeset 56092 fd85b2bf2b0d
parent 56089 42208b2f224e
child 56167 96fa4f49a9ff
permissions -rw-r--r--
http-client-branch: move implementation to jdk.internal.net.http
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     1
/*
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     4
 *
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     8
 *
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    13
 * accompanied this code).
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    14
 *
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    18
 *
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    21
 * questions.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    22
 */
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    23
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    24
/*
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    25
 * @test
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    26
 * @bug 8195823
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    27
 * @summary Buffers given to response body subscribers should not contain
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    28
 *          unprocessed HTTP data
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    29
 * @modules java.base/sun.net.www.http
56092
fd85b2bf2b0d http-client-branch: move implementation to jdk.internal.net.http
chegar
parents: 56089
diff changeset
    30
 *          java.net.http/jdk.internal.net.http.common
fd85b2bf2b0d http-client-branch: move implementation to jdk.internal.net.http
chegar
parents: 56089
diff changeset
    31
 *          java.net.http/jdk.internal.net.http.frame
fd85b2bf2b0d http-client-branch: move implementation to jdk.internal.net.http
chegar
parents: 56089
diff changeset
    32
 *          java.net.http/jdk.internal.net.http.hpack
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    33
 *          java.logging
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    34
 *          jdk.httpserver
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    35
 * @library /lib/testlibrary http2/server
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    36
 * @build Http2TestServer
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    37
 * @build jdk.testlibrary.SimpleSSLContext
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    38
 * @run testng/othervm -Djdk.internal.httpclient.debug=true ConcurrentResponses
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    39
 */
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    40
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    41
import java.io.IOException;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    42
import java.io.InputStream;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    43
import java.io.OutputStream;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    44
import java.net.InetSocketAddress;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    45
import java.net.URI;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    46
import java.nio.ByteBuffer;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    47
import java.util.HashMap;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    48
import java.util.List;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    49
import java.util.Map;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    50
import java.util.concurrent.CompletableFuture;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    51
import java.util.concurrent.CompletionStage;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    52
import java.util.concurrent.Flow;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    53
import java.util.stream.IntStream;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    54
import javax.net.ssl.SSLContext;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    55
import com.sun.net.httpserver.HttpExchange;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    56
import com.sun.net.httpserver.HttpHandler;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    57
import com.sun.net.httpserver.HttpServer;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    58
import com.sun.net.httpserver.HttpsConfigurator;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    59
import com.sun.net.httpserver.HttpsServer;
56089
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    60
import java.net.http.HttpClient;
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    61
import java.net.http.HttpRequest;
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    62
import java.net.http.HttpResponse;
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    63
import java.net.http.HttpResponse.BodyHandler;
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    64
import java.net.http.HttpResponse.BodySubscriber;
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    65
import jdk.testlibrary.SimpleSSLContext;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    66
import org.testng.annotations.AfterTest;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    67
import org.testng.annotations.BeforeTest;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    68
import org.testng.annotations.DataProvider;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    69
import org.testng.annotations.Test;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    70
import static java.nio.charset.StandardCharsets.UTF_8;
56089
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    71
import static java.net.http.HttpResponse.BodyHandler.asString;
42208b2f224e http-client-branch: move to standard package and module name
chegar
parents: 56082
diff changeset
    72
import static java.net.http.HttpResponse.BodyHandler.discard;
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    73
import static org.testng.Assert.assertEquals;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    74
import static org.testng.Assert.assertFalse;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    75
import static org.testng.Assert.fail;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    76
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    77
public class ConcurrentResponses {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    78
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    79
    SSLContext sslContext;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    80
    HttpServer httpTestServer;         // HTTP/1.1    [ 4 servers ]
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    81
    HttpsServer httpsTestServer;       // HTTPS/1.1
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    82
    Http2TestServer http2TestServer;   // HTTP/2 ( h2c )
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    83
    Http2TestServer https2TestServer;  // HTTP/2 ( h2  )
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    84
    String httpFixedURI, httpsFixedURI, httpChunkedURI, httpsChunkedURI;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    85
    String http2FixedURI, https2FixedURI, http2VariableURI, https2VariableURI;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    86
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    87
    static final int CONCURRENT_REQUESTS = 13;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    88
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    89
    static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    90
    static final int ALPHABET_LENGTH = ALPHABET.length();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    91
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    92
    static final String stringOfLength(int requiredLength) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    93
        StringBuilder sb = new StringBuilder(requiredLength);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    94
        IntStream.range(0, requiredLength)
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    95
                 .mapToObj(i -> ALPHABET.charAt(i % ALPHABET_LENGTH))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    96
                 .forEach(c -> sb.append(c));
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    97
        return sb.toString();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    98
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
    99
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   100
    /** An array of different Strings, to be used as bodies. */
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   101
    static final String[] BODIES = bodies();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   102
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   103
    static String[] bodies() {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   104
        String[] bodies = new String[CONCURRENT_REQUESTS];
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   105
        for (int i=0;i<CONCURRENT_REQUESTS; i++) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   106
            // slightly, but still, different bodies
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   107
            bodies[i] = "Request-" + i + "-body-" + stringOfLength((1024) + i);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   108
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   109
        return bodies;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   110
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   111
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   112
    /**
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   113
     * Asserts the given response's status code is 200.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   114
     * Returns a CF that completes with the given response.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   115
     */
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   116
    static final <T> CompletionStage<HttpResponse<T>>
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   117
    assert200ResponseCode(HttpResponse<T> response) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   118
        assertEquals(response.statusCode(), 200);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   119
        return CompletableFuture.completedFuture(response);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   120
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   121
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   122
    /**
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   123
     * Asserts that the given response's body is equal to the given body.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   124
     * Returns a CF that completes with the given response.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   125
     */
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   126
    static final <T> CompletionStage<HttpResponse<T>>
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   127
    assertbody(HttpResponse<T> response, T body) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   128
        assertEquals(response.body(), body);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   129
        return CompletableFuture.completedFuture(response);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   130
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   131
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   132
    @DataProvider(name = "uris")
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   133
    public Object[][] variants() {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   134
        return new Object[][]{
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   135
                { httpFixedURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   136
                { httpsFixedURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   137
                { httpChunkedURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   138
                { httpsChunkedURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   139
                { http2FixedURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   140
                { https2FixedURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   141
                { http2VariableURI },
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   142
                { https2VariableURI }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   143
        };
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   144
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   145
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   146
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   147
    // The asString implementation accumulates data, below a certain threshold
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   148
    // into the byte buffers it is given.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   149
    @Test(dataProvider = "uris")
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   150
    void testAsString(String uri) throws Exception {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   151
        HttpClient client = HttpClient.newBuilder().sslContext(sslContext).build();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   152
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   153
        Map<HttpRequest, String> requests = new HashMap<>();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   154
        for (int i=0;i<CONCURRENT_REQUESTS; i++) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   155
            HttpRequest request = HttpRequest.newBuilder(URI.create(uri + "?" + i))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   156
                                             .build();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   157
            requests.put(request, BODIES[i]);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   158
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   159
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   160
        // initial connection to seed the cache so next parallel connections reuse it
56082
1da51fab3032 http-client-branch: added mapping subscriber, miscellaneous bug fixes and change to discard()/replace() subscribers
michaelm
parents: 56076
diff changeset
   161
        client.sendAsync(HttpRequest.newBuilder(URI.create(uri)).build(), discard()).join();
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   162
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   163
        // will reuse connection cached from the previous request ( when HTTP/2 )
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   164
        CompletableFuture.allOf(requests.keySet().parallelStream()
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   165
                .map(request -> client.sendAsync(request, asString()))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   166
                .map(cf -> cf.thenCompose(ConcurrentResponses::assert200ResponseCode))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   167
                .map(cf -> cf.thenCompose(response -> assertbody(response, requests.get(response.request()))))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   168
                .toArray(CompletableFuture<?>[]::new))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   169
                .join();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   170
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   171
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   172
    // The custom subscriber aggressively attacks any area, between the limit
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   173
    // and the capacity, in the byte buffers it is given, by writing 'X' into it.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   174
    @Test(dataProvider = "uris")
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   175
    void testWithCustomSubscriber(String uri) throws Exception {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   176
        HttpClient client = HttpClient.newBuilder().sslContext(sslContext).build();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   177
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   178
        Map<HttpRequest, String> requests = new HashMap<>();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   179
        for (int i=0;i<CONCURRENT_REQUESTS; i++) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   180
            HttpRequest request = HttpRequest.newBuilder(URI.create(uri + "?" + i))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   181
                    .build();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   182
            requests.put(request, BODIES[i]);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   183
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   184
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   185
        // initial connection to seed the cache so next parallel connections reuse it
56082
1da51fab3032 http-client-branch: added mapping subscriber, miscellaneous bug fixes and change to discard()/replace() subscribers
michaelm
parents: 56076
diff changeset
   186
        client.sendAsync(HttpRequest.newBuilder(URI.create(uri)).build(), discard()).join();
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   187
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   188
        // will reuse connection cached from the previous request ( when HTTP/2 )
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   189
        CompletableFuture.allOf(requests.keySet().parallelStream()
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   190
                .map(request -> client.sendAsync(request, CustomSubscriber.handler))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   191
                .map(cf -> cf.thenCompose(ConcurrentResponses::assert200ResponseCode))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   192
                .map(cf -> cf.thenCompose(response -> assertbody(response, requests.get(response.request()))))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   193
                .toArray(CompletableFuture<?>[]::new))
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   194
                .join();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   195
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   196
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   197
    /**
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   198
     * A subscriber that wraps asString, but mucks with any data between limit
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   199
     * and capacity, if the client mistakenly passes it any that is should not.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   200
     */
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   201
    static class CustomSubscriber implements BodySubscriber<String> {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   202
        static final BodyHandler<String> handler = (r,h) -> new CustomSubscriber();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   203
        private final BodySubscriber<String> asString = BodySubscriber.asString(UTF_8);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   204
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   205
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   206
        public CompletionStage<String> getBody() {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   207
            return asString.getBody();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   208
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   209
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   210
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   211
        public void onSubscribe(Flow.Subscription subscription) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   212
            asString.onSubscribe(subscription);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   213
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   214
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   215
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   216
        public void onNext(List<ByteBuffer> buffers) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   217
            // Muck any data beyond the give limit, since there shouldn't
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   218
            // be any of interest to the HTTP Client.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   219
            for (ByteBuffer buffer : buffers) {
56071
3353cb42b1b4 http-client-branch: immutable data Flow
chegar
parents: 56036
diff changeset
   220
                if (buffer.isReadOnly())
3353cb42b1b4 http-client-branch: immutable data Flow
chegar
parents: 56036
diff changeset
   221
                    continue;
3353cb42b1b4 http-client-branch: immutable data Flow
chegar
parents: 56036
diff changeset
   222
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   223
                if (buffer.limit() != buffer.capacity()) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   224
                    final int limit = buffer.limit();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   225
                    final int position = buffer.position();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   226
                    buffer.position(buffer.limit());
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   227
                    buffer.limit(buffer.capacity());
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   228
                    while (buffer.hasRemaining())
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   229
                        buffer.put((byte)'X');
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   230
                    buffer.position(position); // restore original position
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   231
                    buffer.limit(limit);       // restore original limit
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   232
                }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   233
            }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   234
            asString.onNext(buffers);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   235
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   236
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   237
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   238
        public void onError(Throwable throwable) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   239
            asString.onError(throwable);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   240
            throwable.printStackTrace();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   241
            fail("UNEXPECTED:" + throwable);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   242
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   243
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   244
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   245
        public void onComplete() {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   246
            asString.onComplete();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   247
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   248
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   249
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   250
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   251
    @BeforeTest
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   252
    public void setup() throws Exception {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   253
        sslContext = new SimpleSSLContext().get();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   254
        if (sslContext == null)
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   255
            throw new AssertionError("Unexpected null sslContext");
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   256
56076
9a2855e0a796 http-client-branch: more binding to 0.0.0.0 instead of localhost/127.0.0.1
dfuchs
parents: 56071
diff changeset
   257
        InetSocketAddress sa = new InetSocketAddress(0);
56036
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   258
        httpTestServer = HttpServer.create(sa, 0);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   259
        httpTestServer.createContext("/http1/fixed", new Http1FixedHandler());
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   260
        httpFixedURI = "http://127.0.0.1:" + httpTestServer.getAddress().getPort() + "/http1/fixed";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   261
        httpTestServer.createContext("/http1/chunked", new Http1ChunkedHandler());
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   262
        httpChunkedURI = "http://127.0.0.1:" + httpTestServer.getAddress().getPort() + "/http1/chunked";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   263
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   264
        httpsTestServer = HttpsServer.create(sa, 0);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   265
        httpsTestServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   266
        httpsTestServer.createContext("/https1/fixed", new Http1FixedHandler());
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   267
        httpsFixedURI = "https://127.0.0.1:" + httpsTestServer.getAddress().getPort() + "/https1/fixed";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   268
        httpsTestServer.createContext("/https1/chunked", new Http1ChunkedHandler());
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   269
        httpsChunkedURI = "https://127.0.0.1:" + httpsTestServer.getAddress().getPort() + "/https1/chunked";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   270
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   271
        http2TestServer = new Http2TestServer("127.0.0.1", false, 0);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   272
        http2TestServer.addHandler(new Http2FixedHandler(), "/http2/fixed");
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   273
        http2FixedURI = "http://127.0.0.1:" + http2TestServer.getAddress().getPort() + "/http2/fixed";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   274
        http2TestServer.addHandler(new Http2VariableHandler(), "/http2/variable");
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   275
        http2VariableURI = "http://127.0.0.1:" + http2TestServer.getAddress().getPort() + "/http2/variable";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   276
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   277
        https2TestServer = new Http2TestServer("127.0.0.1", true, 0);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   278
        https2TestServer.addHandler(new Http2FixedHandler(), "/https2/fixed");
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   279
        https2FixedURI = "https://127.0.0.1:" + https2TestServer.getAddress().getPort() + "/https2/fixed";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   280
        https2TestServer.addHandler(new Http2VariableHandler(), "/https2/variable");
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   281
        https2VariableURI = "https://127.0.0.1:" + https2TestServer.getAddress().getPort() + "/https2/variable";
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   282
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   283
        httpTestServer.start();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   284
        httpsTestServer.start();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   285
        http2TestServer.start();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   286
        https2TestServer.start();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   287
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   288
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   289
    @AfterTest
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   290
    public void teardown() throws Exception {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   291
        httpTestServer.stop(0);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   292
        httpsTestServer.stop(0);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   293
        http2TestServer.stop();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   294
        https2TestServer.stop();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   295
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   296
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   297
    interface SendResponseHeadersFunction {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   298
        void apply(int responseCode, long responseLength) throws IOException;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   299
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   300
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   301
    // A handler implementation that replies with 200 OK. If the exchange's uri
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   302
    // has a query, then it must be an integer, which is used as an index to
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   303
    // select the particular response body, e.g. /http2/x?5 -> BODIES[5]
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   304
    static void serverHandlerImpl(InputStream inputStream,
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   305
                                  OutputStream outputStream,
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   306
                                  URI uri,
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   307
                                  SendResponseHeadersFunction sendResponseHeadersFunction)
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   308
        throws IOException
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   309
    {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   310
        try (InputStream is = inputStream;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   311
             OutputStream os = outputStream) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   312
            is.readAllBytes();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   313
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   314
            String magicQuery = uri.getQuery();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   315
            if (magicQuery != null) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   316
                int bodyIndex = Integer.valueOf(magicQuery);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   317
                String body = BODIES[bodyIndex];
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   318
                byte[] bytes = body.getBytes(UTF_8);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   319
                sendResponseHeadersFunction.apply(200, bytes.length);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   320
                int offset = 0;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   321
                // Deliberately attempt to reply with several relatively
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   322
                // small data frames ( each write corresponds to its own
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   323
                // data frame ). Additionally, yield, to encourage other
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   324
                // handlers to execute, therefore increasing the likelihood
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   325
                // of multiple different-stream related frames in the
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   326
                // client's read buffer.
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   327
                while (offset < bytes.length) {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   328
                    int length = Math.min(bytes.length - offset, 64);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   329
                    os.write(bytes, offset, length);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   330
                    os.flush();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   331
                    offset += length;
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   332
                    Thread.yield();
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   333
                }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   334
            } else {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   335
                sendResponseHeadersFunction.apply(200, 1);
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   336
                os.write('A');
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   337
            }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   338
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   339
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   340
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   341
    static class Http1FixedHandler implements HttpHandler {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   342
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   343
        public void handle(HttpExchange t) throws IOException {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   344
            serverHandlerImpl(t.getRequestBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   345
                              t.getResponseBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   346
                              t.getRequestURI(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   347
                              (rcode, length) -> t.sendResponseHeaders(rcode, length));
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   348
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   349
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   350
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   351
    static class Http1ChunkedHandler implements HttpHandler {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   352
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   353
        public void handle(HttpExchange t) throws IOException {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   354
            serverHandlerImpl(t.getRequestBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   355
                              t.getResponseBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   356
                              t.getRequestURI(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   357
                              (rcode, ignored) -> t.sendResponseHeaders(rcode, 0 /*chunked*/));
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   358
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   359
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   360
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   361
    static class Http2FixedHandler implements Http2Handler {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   362
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   363
        public void handle(Http2TestExchange t) throws IOException {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   364
            serverHandlerImpl(t.getRequestBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   365
                              t.getResponseBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   366
                              t.getRequestURI(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   367
                              (rcode, length) -> t.sendResponseHeaders(rcode, length));
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   368
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   369
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   370
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   371
    static class Http2VariableHandler implements Http2Handler {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   372
        @Override
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   373
        public void handle(Http2TestExchange t) throws IOException {
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   374
            serverHandlerImpl(t.getRequestBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   375
                              t.getResponseBody(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   376
                              t.getRequestURI(),
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   377
                              (rcode, ignored) -> t.sendResponseHeaders(rcode, 0 /* no Content-Length */));
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   378
        }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   379
    }
89a688549f5d http-client-branch: Import of 8195823: Buffers given to response body subscribers should not contain unprocessed HTTP data
chegar
parents:
diff changeset
   380
}