test/jdk/com/sun/net/httpserver/bugs/FixedLengthInputStream.java
author dholmes
Wed, 06 Nov 2019 21:18:42 -0500
changeset 58956 9a0a5e70eeb2
parent 55330 1fef7d9309a9
permissions -rw-r--r--
8233454: Test fails with assert(!is_init_completed(), "should only happen during init") after JDK-8229516 Reviewed-by: jiefu, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     1
/*
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
     2
 * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     4
 *
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     8
 *
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    13
 * accompanied this code).
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    14
 *
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1576
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1576
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1576
diff changeset
    21
 * questions.
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    22
 */
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    23
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    24
/**
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    25
 * @test
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 1511
diff changeset
    26
 * @bug 6756771 6755625
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    27
 * @summary  com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    28
 * @library /test/lib
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    29
 * @run main FixedLengthInputStream
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    30
 * @run main/othervm -Djava.net.preferIPv6Addresses=true FixedLengthInputStream
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    31
 */
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    32
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    33
import java.io.InputStream;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    34
import java.io.IOException;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    35
import java.io.OutputStream;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    36
import java.io.PrintStream;
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    37
import java.net.InetAddress;
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    38
import java.net.InetSocketAddress;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    39
import java.net.HttpURLConnection;
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    40
import java.net.Proxy;
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    41
import java.net.URL;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    42
import java.net.Socket;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    43
import java.util.logging.*;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    44
import com.sun.net.httpserver.HttpExchange;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    45
import com.sun.net.httpserver.HttpHandler;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    46
import com.sun.net.httpserver.HttpServer;
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    47
import jdk.test.lib.net.URIBuilder;
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    48
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    49
public class FixedLengthInputStream
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    50
{
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    51
    static final long POST_SIZE = 4L * 1024L * 1024L * 1024L; // 4Gig
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    52
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    53
    void test(String[] args) throws IOException {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    54
        HttpServer httpServer = startHttpServer();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    55
        int port = httpServer.getAddress().getPort();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    56
        try {
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    57
            URL url = URIBuilder.newBuilder()
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    58
                .scheme("http")
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    59
                .loopback()
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    60
                .port(port)
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    61
                .path("/flis/")
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    62
                .toURLUnchecked();
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
    63
            HttpURLConnection uc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    64
            uc.setDoOutput(true);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    65
            uc.setRequestMethod("POST");
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    66
            uc.setFixedLengthStreamingMode(POST_SIZE);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    67
            OutputStream os = uc.getOutputStream();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    68
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    69
            /* create a 32K byte array with data to POST */
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    70
            int thirtyTwoK = 32 * 1024;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    71
            byte[] ba = new byte[thirtyTwoK];
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    72
            for (int i =0; i<thirtyTwoK; i++)
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    73
                ba[i] = (byte)i;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    74
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    75
            long times = POST_SIZE / thirtyTwoK;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    76
            for (int i=0; i<times; i++) {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    77
                os.write(ba);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    78
            }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    79
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    80
            os.close();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    81
            InputStream is = uc.getInputStream();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    82
            while(is.read(ba) != -1);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    83
            is.close();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    84
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 1511
diff changeset
    85
            pass();
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    86
        } finally {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    87
            httpServer.stop(0);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    88
        }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    89
    }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    90
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    91
    /**
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    92
     * Http Server
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    93
     */
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    94
    HttpServer startHttpServer() throws IOException {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    95
        if (debug) {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    96
            Logger logger =
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    97
            Logger.getLogger("com.sun.net.httpserver");
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    98
            Handler outHandler = new StreamHandler(System.out,
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
    99
                                     new SimpleFormatter());
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   100
            outHandler.setLevel(Level.FINEST);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   101
            logger.setLevel(Level.FINEST);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   102
            logger.addHandler(outHandler);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   103
        }
55330
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
   104
        InetAddress loopback = InetAddress.getLoopbackAddress();
1fef7d9309a9 8225512: Replace wildcard address with loopback or local host in tests - part 15
dfuchs
parents: 47216
diff changeset
   105
        HttpServer httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
1511
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   106
        httpServer.createContext("/flis/", new MyHandler(POST_SIZE));
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   107
        httpServer.start();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   108
        return httpServer;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   109
    }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   110
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   111
    class MyHandler implements HttpHandler {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   112
        static final int BUFFER_SIZE = 32 * 1024;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   113
        long expected;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   114
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   115
        MyHandler(long expected){
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   116
            this.expected = expected;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   117
        }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   118
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   119
        @Override
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   120
        public void handle(HttpExchange t) throws IOException {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   121
            InputStream is = t.getRequestBody();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   122
            byte[] ba = new byte[BUFFER_SIZE];
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   123
            int read;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   124
            long count = 0L;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   125
            while((read = is.read(ba)) != -1) {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   126
                count += read;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   127
            }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   128
            is.close();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   129
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   130
            check(count == expected, "Expected: " + expected + ", received "
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   131
                    + count);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   132
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   133
            debug("Received " + count + " bytes");
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   134
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   135
            t.sendResponseHeaders(200, -1);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   136
            t.close();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   137
        }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   138
    }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   139
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   140
         //--------------------- Infrastructure ---------------------------
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   141
    boolean debug = true;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   142
    volatile int passed = 0, failed = 0;
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   143
    void pass() {passed++;}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   144
    void fail() {failed++; Thread.dumpStack();}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   145
    void fail(String msg) {System.err.println(msg); fail();}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   146
    void unexpected(Throwable t) {failed++; t.printStackTrace();}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   147
    void check(boolean cond) {if (cond) pass(); else fail();}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   148
    void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   149
    void debug(String message) {if(debug) { System.out.println(message); }  }
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   150
    public static void main(String[] args) throws Throwable {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   151
        Class<?> k = new Object(){}.getClass().getEnclosingClass();
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   152
        try {k.getMethod("instanceMain",String[].class)
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   153
                .invoke( k.newInstance(), (Object) args);}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   154
        catch (Throwable e) {throw e.getCause();}}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   155
    public void instanceMain(String[] args) throws Throwable {
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   156
        try {test(args);} catch (Throwable t) {unexpected(t);}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   157
        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   158
        if (failed > 0) throw new AssertionError("Some tests failed");}
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   159
65ddd8f149f3 6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff changeset
   160
}