test/jdk/java/net/httpclient/UnknownBodyLengthTest.java
author michaelm
Thu, 16 Aug 2018 10:22:48 +0100
changeset 51462 9d7d74c6f2cb
child 52121 934969c63223
permissions -rw-r--r--
8207966: HttpClient response without content-length does not return body Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51462
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     1
/*
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     4
 *
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     8
 *
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    13
 * accompanied this code).
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    14
 *
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    18
 *
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    21
 * questions.
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    22
 */
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    23
import java.io.InputStream;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    24
import java.io.OutputStream;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    25
import java.net.InetSocketAddress;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    26
import java.net.ServerSocket;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    27
import java.net.Socket;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    28
import java.net.URI;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    29
import java.net.SocketTimeoutException;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    30
import java.time.Duration;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    31
import javax.net.ssl.SSLServerSocketFactory;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    32
import javax.net.ServerSocketFactory;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    33
import javax.net.ssl.SSLContext;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    34
import javax.net.ssl.SSLParameters;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    35
import java.net.http.HttpClient;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    36
import java.net.http.HttpRequest;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    37
import java.net.http.HttpResponse;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    38
import jdk.testlibrary.SimpleSSLContext;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    39
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    40
/**
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    41
 * @test
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    42
 * @bug 8207966
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    43
 * @library /lib/testlibrary
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    44
 * @build jdk.testlibrary.SimpleSSLContext
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    45
 * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain false
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    46
 * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL false
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    47
 * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain true
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    48
 * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL true
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    49
 */
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    50
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    51
public class UnknownBodyLengthTest {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    52
    static final byte[] BUF = new byte[32 * 10234 + 2];
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    53
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    54
    volatile SSLContext ctx;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    55
    volatile ServerSocketFactory factory;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    56
    volatile String clientURL;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    57
    volatile int port;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    58
    final ServerSocket ss;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    59
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    60
    UnknownBodyLengthTest(boolean useSSL) throws Exception {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    61
        ctx = new SimpleSSLContext().get();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    62
        SSLContext.setDefault(ctx);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    63
        factory = useSSL ? SSLServerSocketFactory.getDefault()
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    64
                         : ServerSocketFactory.getDefault();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    65
        ss = factory.createServerSocket();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    66
        ss.setReuseAddress(true);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    67
        ss.bind(new InetSocketAddress("127.0.0.1", 0));
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    68
        System.out.println("ServerSocket = " + ss.getClass() + " " + ss);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    69
        port = ss.getLocalPort();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    70
        clientURL = (useSSL ? "https" : "http") + "://localhost:"
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    71
            + Integer.toString(port) + "/test";
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    72
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    73
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    74
    static void fillBuf(byte[] buf) {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    75
        for (int i=0; i<buf.length; i++)
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    76
            buf[i] = (byte)i;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    77
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    78
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    79
    static void checkBuf(byte[] buf) {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    80
        if (buf.length != BUF.length)
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    81
            throw new RuntimeException("buffer lengths not the same");
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    82
        for (int i=0; i<buf.length; i++)
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    83
            if (buf[i] != BUF[i])
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    84
                throw new RuntimeException("error at position " + i);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    85
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    86
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    87
    void server(final boolean withContentLength) {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    88
        fillBuf(BUF);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    89
        try {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    90
            Socket s = ss.accept();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    91
            s.setTcpNoDelay(true);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    92
            s.setSoLinger(true, 1);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    93
            System.out.println("Accepted: "+s.getRemoteSocketAddress());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    94
            System.out.println("Accepted: "+s);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    95
            OutputStream os = s.getOutputStream();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    96
            InputStream is = s.getInputStream();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    97
            boolean done = false;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    98
            byte[] buf = new byte[1024];
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
    99
            String rsp = "";
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   100
            while (!done) {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   101
                int c = is.read(buf);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   102
                if (c < 0) break;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   103
                String s1 = new String(buf, 0, c, "ISO-8859-1");
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   104
                rsp += s1;
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   105
                done = rsp.endsWith("!#!#");
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   106
            }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   107
            String r = "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type:" +
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   108
                       " text/xml; charset=UTF-8\r\n";
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   109
            os.write(r.getBytes());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   110
            String chdr = "Content-Length: " + Integer.toString(BUF.length) +
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   111
                     "\r\n";
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   112
            System.out.println(chdr);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   113
            if(withContentLength)
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   114
                os.write(chdr.getBytes());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   115
            os.write("\r\n".getBytes());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   116
            os.write(BUF);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   117
            if (is.available() > 0)
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   118
                is.read(buf);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   119
            os.flush();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   120
            os.close();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   121
            s.shutdownOutput();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   122
            s.close();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   123
        } catch(final Throwable t) {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   124
          t.printStackTrace();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   125
        } finally {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   126
            try {ss.close(); } catch (Exception e) {}
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   127
        }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   128
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   129
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   130
    void client(boolean useSSL) throws Exception {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   131
        SSLContext ctx = SSLContext.getDefault();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   132
        HttpClient.Builder clientB = HttpClient.newBuilder()
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   133
            .version(HttpClient.Version.HTTP_2);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   134
        if (useSSL) {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   135
            clientB = clientB.sslContext(ctx)
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   136
                .sslParameters(ctx.getSupportedSSLParameters());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   137
        }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   138
        final HttpClient client = clientB.build();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   139
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   140
        System.out.println("URL: " + clientURL);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   141
        final HttpResponse<byte[]> response = client
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   142
            .send(HttpRequest
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   143
                .newBuilder(new URI(clientURL))
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   144
                .timeout(Duration.ofMillis(120_000))
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   145
                .POST(HttpRequest.BodyPublishers.ofString("body!#!#"))
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   146
                .build(), HttpResponse.BodyHandlers.ofByteArray());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   147
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   148
        System.out.println("Received reply: " + response.statusCode());
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   149
        byte[] bb = response.body();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   150
        checkBuf(bb);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   151
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   152
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   153
    public static void main(final String[] args) throws Exception {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   154
        boolean ssl = args[0].equals("SSL");
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   155
        boolean fixedlen = args[1].equals("true");
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   156
        UnknownBodyLengthTest test = new UnknownBodyLengthTest(ssl);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   157
        test.run(ssl, fixedlen);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   158
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   159
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   160
    public void run(boolean ssl, boolean fixedlen) throws Exception {
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   161
        new Thread(()->server(fixedlen)).start();
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   162
        client(ssl);
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   163
    }
9d7d74c6f2cb 8207966: HttpClient response without content-length does not return body
michaelm
parents:
diff changeset
   164
}