author | never |
Mon, 12 Jul 2010 22:27:18 -0700 | |
changeset 5926 | a36f90d986b6 |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
1511
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, 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 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
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 |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
28 |
*/ |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
29 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
30 |
import java.io.InputStream; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
31 |
import java.io.IOException; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
32 |
import java.io.OutputStream; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
33 |
import java.io.PrintStream; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
34 |
import java.net.InetSocketAddress; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
35 |
import java.net.HttpURLConnection; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
36 |
import java.net.URL; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
37 |
import java.net.Socket; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
38 |
import java.util.logging.*; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
39 |
import com.sun.net.httpserver.HttpExchange; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
40 |
import com.sun.net.httpserver.HttpHandler; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
41 |
import com.sun.net.httpserver.HttpServer; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
42 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
43 |
public class FixedLengthInputStream |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
44 |
{ |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
45 |
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
|
46 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
47 |
void test(String[] args) throws IOException { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
48 |
HttpServer httpServer = startHttpServer(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
49 |
int port = httpServer.getAddress().getPort(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
50 |
try { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
51 |
URL url = new URL("http://localhost:" + port + "/flis/"); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
52 |
HttpURLConnection uc = (HttpURLConnection)url.openConnection(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
53 |
uc.setDoOutput(true); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
54 |
uc.setRequestMethod("POST"); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
55 |
uc.setFixedLengthStreamingMode(POST_SIZE); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
56 |
OutputStream os = uc.getOutputStream(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
57 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
58 |
/* 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
|
59 |
int thirtyTwoK = 32 * 1024; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
60 |
byte[] ba = new byte[thirtyTwoK]; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
61 |
for (int i =0; i<thirtyTwoK; i++) |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
62 |
ba[i] = (byte)i; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
63 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
64 |
long times = POST_SIZE / thirtyTwoK; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
65 |
for (int i=0; i<times; i++) { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
66 |
os.write(ba); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
67 |
} |
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 |
os.close(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
70 |
InputStream is = uc.getInputStream(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
71 |
while(is.read(ba) != -1); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
72 |
is.close(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
73 |
|
1576
b697b141012d
6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents:
1511
diff
changeset
|
74 |
pass(); |
1511
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
75 |
} finally { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
76 |
httpServer.stop(0); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
77 |
} |
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 |
/** |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
81 |
* Http Server |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
82 |
*/ |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
83 |
HttpServer startHttpServer() throws IOException { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
84 |
if (debug) { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
85 |
Logger logger = |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
86 |
Logger.getLogger("com.sun.net.httpserver"); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
87 |
Handler outHandler = new StreamHandler(System.out, |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
88 |
new SimpleFormatter()); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
89 |
outHandler.setLevel(Level.FINEST); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
90 |
logger.setLevel(Level.FINEST); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
91 |
logger.addHandler(outHandler); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
92 |
} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
93 |
HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
94 |
httpServer.createContext("/flis/", new MyHandler(POST_SIZE)); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
95 |
httpServer.start(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
96 |
return httpServer; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
97 |
} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
98 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
99 |
class MyHandler implements HttpHandler { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
100 |
static final int BUFFER_SIZE = 32 * 1024; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
101 |
long expected; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
102 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
103 |
MyHandler(long expected){ |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
104 |
this.expected = expected; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
105 |
} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
106 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
107 |
@Override |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
108 |
public void handle(HttpExchange t) throws IOException { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
109 |
InputStream is = t.getRequestBody(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
110 |
byte[] ba = new byte[BUFFER_SIZE]; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
111 |
int read; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
112 |
long count = 0L; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
113 |
while((read = is.read(ba)) != -1) { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
114 |
count += read; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
115 |
} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
116 |
is.close(); |
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 |
check(count == expected, "Expected: " + expected + ", received " |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
119 |
+ count); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
120 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
121 |
debug("Received " + count + " bytes"); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
122 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
123 |
t.sendResponseHeaders(200, -1); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
124 |
t.close(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
125 |
} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
126 |
} |
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 |
//--------------------- Infrastructure --------------------------- |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
129 |
boolean debug = true; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
130 |
volatile int passed = 0, failed = 0; |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
131 |
void pass() {passed++;} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
132 |
void fail() {failed++; Thread.dumpStack();} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
133 |
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
|
134 |
void unexpected(Throwable t) {failed++; t.printStackTrace();} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
Class<?> k = new Object(){}.getClass().getEnclosingClass(); |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
140 |
try {k.getMethod("instanceMain",String[].class) |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
141 |
.invoke( k.newInstance(), (Object) args);} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
142 |
catch (Throwable e) {throw e.getCause();}} |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
143 |
public void instanceMain(String[] args) throws Throwable { |
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
|
65ddd8f149f3
6756771: com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
chegar
parents:
diff
changeset
|
148 |
} |