author | jboes |
Fri, 08 Nov 2019 11:15:16 +0000 | |
changeset 59029 | 3786a0962570 |
parent 58968 | 7f1daafda27b |
permissions | -rw-r--r-- |
50681 | 1 |
/* |
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
50681 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
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. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
26 |
* @bug 8216498 |
50681 | 27 |
* @summary Tests Exception detail message when too few response bytes are |
28 |
* received before a socket exception or eof. |
|
52121
934969c63223
8211978: Move testlibrary/jdk/testlibrary/SimpleSSLContext.java and testkeys to network testlibrary
jjiang
parents:
50985
diff
changeset
|
29 |
* @library /test/lib |
934969c63223
8211978: Move testlibrary/jdk/testlibrary/SimpleSSLContext.java and testkeys to network testlibrary
jjiang
parents:
50985
diff
changeset
|
30 |
* @build jdk.test.lib.net.SimpleSSLContext |
50681 | 31 |
* @run testng/othervm |
32 |
* -Djdk.httpclient.HttpClient.log=headers,errors,channel |
|
33 |
* ShortResponseBody |
|
34 |
*/ |
|
35 |
||
36 |
import java.io.IOException; |
|
37 |
import java.io.InputStream; |
|
38 |
import java.io.OutputStream; |
|
39 |
import java.io.UncheckedIOException; |
|
40 |
import java.net.InetAddress; |
|
41 |
import java.net.InetSocketAddress; |
|
42 |
import java.net.ServerSocket; |
|
43 |
import java.net.Socket; |
|
44 |
import java.net.URI; |
|
45 |
import java.net.http.HttpClient; |
|
46 |
import java.net.http.HttpRequest; |
|
47 |
import java.net.http.HttpRequest.BodyPublishers; |
|
48 |
import java.net.http.HttpResponse; |
|
49 |
import java.util.ArrayList; |
|
50 |
import java.util.Arrays; |
|
51 |
import java.util.List; |
|
52 |
import java.util.concurrent.ExecutionException; |
|
53 |
import java.util.concurrent.Executor; |
|
54 |
import java.util.concurrent.ExecutorService; |
|
55 |
import java.util.concurrent.Executors; |
|
56 |
import java.util.concurrent.ThreadFactory; |
|
57 |
import java.util.concurrent.atomic.AtomicLong; |
|
58 |
import java.util.stream.Stream; |
|
52121
934969c63223
8211978: Move testlibrary/jdk/testlibrary/SimpleSSLContext.java and testkeys to network testlibrary
jjiang
parents:
50985
diff
changeset
|
59 |
import jdk.test.lib.net.SimpleSSLContext; |
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
60 |
import org.testng.ITestContext; |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
61 |
import org.testng.annotations.BeforeMethod; |
50681 | 62 |
import org.testng.annotations.AfterTest; |
63 |
import org.testng.annotations.BeforeTest; |
|
64 |
import org.testng.annotations.DataProvider; |
|
65 |
import org.testng.annotations.Test; |
|
66 |
import javax.net.ssl.SSLContext; |
|
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
67 |
import javax.net.ssl.SSLHandshakeException; |
50681 | 68 |
import javax.net.ssl.SSLServerSocketFactory; |
69 |
import javax.net.ssl.SSLParameters; |
|
70 |
import javax.net.ssl.SSLSocket; |
|
71 |
import static java.lang.System.out; |
|
72 |
import static java.net.http.HttpClient.Builder.NO_PROXY; |
|
73 |
import static java.net.http.HttpResponse.BodyHandlers.ofString; |
|
74 |
import static java.nio.charset.StandardCharsets.US_ASCII; |
|
75 |
import static java.util.stream.Collectors.toList; |
|
76 |
import static org.testng.Assert.assertTrue; |
|
77 |
import static org.testng.Assert.assertEquals; |
|
78 |
import static org.testng.Assert.fail; |
|
79 |
||
80 |
public class ShortResponseBody { |
|
81 |
||
82 |
Server closeImmediatelyServer; |
|
83 |
Server closeImmediatelyHttpsServer; |
|
84 |
Server variableLengthServer; |
|
85 |
Server variableLengthHttpsServer; |
|
86 |
Server fixedLengthServer; |
|
87 |
||
88 |
String httpURIClsImed; |
|
89 |
String httpsURIClsImed; |
|
90 |
String httpURIVarLen; |
|
91 |
String httpsURIVarLen; |
|
92 |
String httpURIFixLen; |
|
93 |
||
94 |
SSLContext sslContext; |
|
95 |
SSLParameters sslParameters; |
|
96 |
||
97 |
static final String EXPECTED_RESPONSE_BODY = |
|
98 |
"<html><body><h1>Heading</h1><p>Some Text</p></body></html>"; |
|
99 |
||
100 |
final static AtomicLong ids = new AtomicLong(); |
|
101 |
final ThreadFactory factory = new ThreadFactory() { |
|
102 |
@Override |
|
103 |
public Thread newThread(Runnable r) { |
|
104 |
Thread thread = new Thread(r, "HttpClient-Worker-" + ids.incrementAndGet()); |
|
105 |
thread.setDaemon(true); |
|
106 |
return thread; |
|
107 |
} |
|
108 |
}; |
|
109 |
final ExecutorService service = Executors.newCachedThreadPool(factory); |
|
110 |
||
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
111 |
@BeforeMethod |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
112 |
void beforeMethod(ITestContext context) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
113 |
if (context.getFailedTests().size() > 0) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
114 |
throw new RuntimeException("some tests failed"); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
115 |
} |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
116 |
} |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
117 |
|
50681 | 118 |
@DataProvider(name = "sanity") |
119 |
public Object[][] sanity() { |
|
120 |
return new Object[][]{ |
|
121 |
{ httpURIVarLen + "?length=all" }, |
|
122 |
{ httpsURIVarLen + "?length=all" }, |
|
123 |
{ httpURIFixLen + "?length=all" }, |
|
124 |
}; |
|
125 |
} |
|
126 |
||
127 |
@Test(dataProvider = "sanity") |
|
128 |
void sanity(String url) throws Exception { |
|
129 |
HttpClient client = newHttpClient(); |
|
130 |
HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); |
|
131 |
HttpResponse<String> response = client.send(request, ofString()); |
|
132 |
String body = response.body(); |
|
133 |
assertEquals(body, EXPECTED_RESPONSE_BODY); |
|
134 |
client.sendAsync(request, ofString()) |
|
135 |
.thenApply(resp -> resp.body()) |
|
136 |
.thenAccept(b -> assertEquals(b, EXPECTED_RESPONSE_BODY)) |
|
137 |
.join(); |
|
138 |
} |
|
139 |
||
140 |
@DataProvider(name = "uris") |
|
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
141 |
public Object[][] variants(ITestContext context) { |
50681 | 142 |
String[][] cases = new String[][] { |
143 |
// The length query string is the total number of bytes in the reply, |
|
144 |
// including headers, before the server closes the connection. The |
|
145 |
// second arg is a partial-expected-detail message in the exception. |
|
146 |
{ httpURIVarLen + "?length=0", "no bytes" }, // EOF without receiving anything |
|
147 |
{ httpURIVarLen + "?length=1", "status line" }, // EOF during status-line |
|
148 |
{ httpURIVarLen + "?length=2", "status line" }, |
|
149 |
{ httpURIVarLen + "?length=10", "status line" }, |
|
150 |
{ httpURIVarLen + "?length=19", "header" }, // EOF during Content-Type header |
|
151 |
{ httpURIVarLen + "?length=30", "header" }, |
|
152 |
{ httpURIVarLen + "?length=45", "header" }, |
|
153 |
{ httpURIVarLen + "?length=48", "header" }, |
|
154 |
{ httpURIVarLen + "?length=51", "header" }, |
|
155 |
{ httpURIVarLen + "?length=98", "header" }, // EOF during Connection header |
|
156 |
{ httpURIVarLen + "?length=100", "header" }, |
|
157 |
{ httpURIVarLen + "?length=101", "header" }, |
|
158 |
{ httpURIVarLen + "?length=104", "header" }, |
|
159 |
{ httpURIVarLen + "?length=106", "chunked transfer encoding" }, // EOF during chunk header ( length ) |
|
160 |
{ httpURIVarLen + "?length=110", "chunked transfer encoding" }, // EOF during chunk response body data |
|
161 |
||
162 |
{ httpsURIVarLen + "?length=0", "no bytes" }, |
|
163 |
{ httpsURIVarLen + "?length=1", "status line" }, |
|
164 |
{ httpsURIVarLen + "?length=2", "status line" }, |
|
165 |
{ httpsURIVarLen + "?length=10", "status line" }, |
|
166 |
{ httpsURIVarLen + "?length=19", "header" }, |
|
167 |
{ httpsURIVarLen + "?length=30", "header" }, |
|
168 |
{ httpsURIVarLen + "?length=45", "header" }, |
|
169 |
{ httpsURIVarLen + "?length=48", "header" }, |
|
170 |
{ httpsURIVarLen + "?length=51", "header" }, |
|
171 |
{ httpsURIVarLen + "?length=98", "header" }, |
|
172 |
{ httpsURIVarLen + "?length=100", "header" }, |
|
173 |
{ httpsURIVarLen + "?length=101", "header" }, |
|
174 |
{ httpsURIVarLen + "?length=104", "header" }, |
|
175 |
{ httpsURIVarLen + "?length=106", "chunked transfer encoding" }, |
|
176 |
{ httpsURIVarLen + "?length=110", "chunked transfer encoding" }, |
|
177 |
||
178 |
{ httpURIFixLen + "?length=0", "no bytes" }, // EOF without receiving anything |
|
179 |
{ httpURIFixLen + "?length=1", "status line" }, // EOF during status-line |
|
180 |
{ httpURIFixLen + "?length=2", "status line" }, |
|
181 |
{ httpURIFixLen + "?length=10", "status line" }, |
|
182 |
{ httpURIFixLen + "?length=19", "header" }, // EOF during Content-Type header |
|
183 |
{ httpURIFixLen + "?length=30", "header" }, |
|
184 |
{ httpURIFixLen + "?length=45", "header" }, |
|
185 |
{ httpURIFixLen + "?length=48", "header" }, |
|
186 |
{ httpURIFixLen + "?length=51", "header" }, |
|
187 |
{ httpURIFixLen + "?length=78", "header" }, // EOF during Connection header |
|
188 |
{ httpURIFixLen + "?length=79", "header" }, |
|
189 |
{ httpURIFixLen + "?length=86", "header" }, |
|
190 |
{ httpURIFixLen + "?length=104", "fixed content-length" }, // EOF during body |
|
191 |
{ httpURIFixLen + "?length=106", "fixed content-length" }, |
|
192 |
{ httpURIFixLen + "?length=110", "fixed content-length" }, |
|
193 |
||
194 |
// ## ADD https fixed |
|
195 |
||
196 |
{ httpURIClsImed, "no bytes"}, |
|
197 |
{ httpsURIClsImed, "no bytes"}, |
|
198 |
}; |
|
199 |
||
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
200 |
if (context.getFailedTests().size() > 0) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
201 |
// Shorten the log output by preventing useless |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
202 |
// skip traces to be printed for subsequent methods |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
203 |
// if one of the previous @Test method has failed. |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
204 |
return new Object[0][]; |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
205 |
} |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
206 |
|
50681 | 207 |
List<Object[]> list = new ArrayList<>(); |
208 |
Arrays.asList(cases).stream() |
|
209 |
.map(e -> new Object[] {e[0], e[1], true}) // reuse client |
|
210 |
.forEach(list::add); |
|
211 |
Arrays.asList(cases).stream() |
|
212 |
.map(e -> new Object[] {e[0], e[1], false}) // do not reuse client |
|
213 |
.forEach(list::add); |
|
214 |
return list.stream().toArray(Object[][]::new); |
|
215 |
} |
|
216 |
||
217 |
static final int ITERATION_COUNT = 3; |
|
218 |
||
219 |
HttpClient newHttpClient() { |
|
220 |
return HttpClient.newBuilder() |
|
221 |
.proxy(NO_PROXY) |
|
222 |
.sslContext(sslContext) |
|
223 |
.sslParameters(sslParameters) |
|
224 |
.executor(service) |
|
225 |
.build(); |
|
226 |
} |
|
227 |
||
228 |
@Test(dataProvider = "uris") |
|
229 |
void testSynchronousGET(String url, String expectedMsg, boolean sameClient) |
|
230 |
throws Exception |
|
231 |
{ |
|
232 |
out.print("---\n"); |
|
233 |
HttpClient client = null; |
|
234 |
for (int i=0; i< ITERATION_COUNT; i++) { |
|
235 |
if (!sameClient || client == null) |
|
236 |
client = newHttpClient(); |
|
237 |
HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); |
|
238 |
try { |
|
239 |
HttpResponse<String> response = client.send(request, ofString()); |
|
240 |
String body = response.body(); |
|
241 |
out.println(response + ": " + body); |
|
242 |
fail("UNEXPECTED RESPONSE: " + response); |
|
243 |
} catch (IOException ioe) { |
|
244 |
out.println("Caught expected exception:" + ioe); |
|
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
245 |
assertExpectedMessage(request, ioe, expectedMsg); |
50681 | 246 |
// synchronous API must have the send method on the stack |
247 |
assertSendMethodOnStack(ioe); |
|
248 |
assertNoConnectionExpiredException(ioe); |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
||
253 |
@Test(dataProvider = "uris") |
|
254 |
void testAsynchronousGET(String url, String expectedMsg, boolean sameClient) |
|
255 |
throws Exception |
|
256 |
{ |
|
257 |
out.print("---\n"); |
|
258 |
HttpClient client = null; |
|
259 |
for (int i=0; i< ITERATION_COUNT; i++) { |
|
260 |
if (!sameClient || client == null) |
|
261 |
client = newHttpClient(); |
|
262 |
HttpRequest request = HttpRequest.newBuilder(URI.create(url)).build(); |
|
263 |
try { |
|
264 |
HttpResponse<String> response = client.sendAsync(request, ofString()).get(); |
|
265 |
String body = response.body(); |
|
266 |
out.println(response + ": " + body); |
|
267 |
fail("UNEXPECTED RESPONSE: " + response); |
|
268 |
} catch (ExecutionException ee) { |
|
269 |
if (ee.getCause() instanceof IOException) { |
|
270 |
IOException ioe = (IOException) ee.getCause(); |
|
271 |
out.println("Caught expected exception:" + ioe); |
|
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
272 |
assertExpectedMessage(request, ioe, expectedMsg); |
50681 | 273 |
assertNoConnectionExpiredException(ioe); |
274 |
} else { |
|
275 |
throw ee; |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
||
281 |
// can be used to prolong request body publication |
|
282 |
static final class InfiniteInputStream extends InputStream { |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
283 |
int count = 0; |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
284 |
int k16 = 0; |
50681 | 285 |
@Override |
286 |
public int read() throws IOException { |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
287 |
if (++count == 1) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
288 |
System.out.println("Start sending 1 byte"); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
289 |
} |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
290 |
if (count > 16 * 1024) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
291 |
k16++; |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
292 |
System.out.println("... 16K sent."); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
293 |
count = count % (16 * 1024); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
294 |
} |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
295 |
if (k16 > 128) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
296 |
System.out.println("WARNING: InfiniteInputStream: " + |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
297 |
"more than 128 16k buffers generated: returning EOF"); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
298 |
return -1; |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
299 |
} |
50681 | 300 |
return 1; |
301 |
} |
|
302 |
||
303 |
@Override |
|
304 |
public int read(byte[] buf, int offset, int length) { |
|
305 |
//int count = offset; |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
306 |
length = Math.max(0, Math.min(buf.length - offset, length)); |
50681 | 307 |
//for (; count < length; count++) |
308 |
// buf[offset++] = 0x01; |
|
309 |
//return count; |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
310 |
if (count == 0) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
311 |
System.out.println("Start sending " + length); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
312 |
} else if (count > 16 * 1024) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
313 |
k16++; |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
314 |
System.out.println("... 16K sent."); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
315 |
count = count % (16 * 1024); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
316 |
} |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
317 |
if (k16 > 128) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
318 |
System.out.println("WARNING: InfiniteInputStream: " + |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
319 |
"more than 128 16k buffers generated: returning EOF"); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
320 |
return -1; |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
321 |
} |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
322 |
count += length; |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
323 |
return length; |
50681 | 324 |
} |
325 |
} |
|
326 |
||
327 |
// POST tests are racy in what may be received before writing may cause a |
|
328 |
// broken pipe or reset exception, before all the received data can be read. |
|
329 |
// Any message up to, and including, the "expected" error message can occur. |
|
330 |
// Strictly ordered list, in order of possible occurrence. |
|
331 |
static final List<String> MSGS_ORDER = |
|
332 |
List.of("no bytes", "status line", "header"); |
|
333 |
||
334 |
||
335 |
@Test(dataProvider = "uris") |
|
336 |
void testSynchronousPOST(String url, String expectedMsg, boolean sameClient) |
|
337 |
throws Exception |
|
338 |
{ |
|
339 |
out.print("---\n"); |
|
340 |
HttpClient client = null; |
|
341 |
for (int i=0; i< ITERATION_COUNT; i++) { |
|
342 |
if (!sameClient || client == null) |
|
343 |
client = newHttpClient(); |
|
344 |
HttpRequest request = HttpRequest.newBuilder(URI.create(url)) |
|
345 |
.POST(BodyPublishers.ofInputStream(() -> new InfiniteInputStream())) |
|
346 |
.build(); |
|
347 |
try { |
|
348 |
HttpResponse<String> response = client.send(request, ofString()); |
|
349 |
String body = response.body(); |
|
350 |
out.println(response + ": " + body); |
|
351 |
fail("UNEXPECTED RESPONSE: " + response); |
|
352 |
} catch (IOException ioe) { |
|
353 |
out.println("Caught expected exception:" + ioe); |
|
354 |
||
355 |
List<String> expectedMessages = new ArrayList<>(); |
|
356 |
expectedMessages.add(expectedMsg); |
|
357 |
MSGS_ORDER.stream().takeWhile(s -> !s.equals(expectedMsg)) |
|
358 |
.forEach(expectedMessages::add); |
|
359 |
||
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
360 |
assertExpectedMessage(request, ioe, expectedMessages); |
50681 | 361 |
// synchronous API must have the send method on the stack |
362 |
assertSendMethodOnStack(ioe); |
|
363 |
assertNoConnectionExpiredException(ioe); |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
@Test(dataProvider = "uris") |
|
369 |
void testAsynchronousPOST(String url, String expectedMsg, boolean sameClient) |
|
370 |
throws Exception |
|
371 |
{ |
|
372 |
out.print("---\n"); |
|
373 |
HttpClient client = null; |
|
374 |
for (int i=0; i< ITERATION_COUNT; i++) { |
|
375 |
if (!sameClient || client == null) |
|
376 |
client = newHttpClient(); |
|
377 |
HttpRequest request = HttpRequest.newBuilder(URI.create(url)) |
|
378 |
.POST(BodyPublishers.ofInputStream(() -> new InfiniteInputStream())) |
|
379 |
.build(); |
|
380 |
try { |
|
381 |
HttpResponse<String> response = client.sendAsync(request, ofString()).get(); |
|
382 |
String body = response.body(); |
|
383 |
out.println(response + ": " + body); |
|
384 |
fail("UNEXPECTED RESPONSE: " + response); |
|
385 |
} catch (ExecutionException ee) { |
|
386 |
if (ee.getCause() instanceof IOException) { |
|
387 |
IOException ioe = (IOException) ee.getCause(); |
|
388 |
out.println("Caught expected exception:" + ioe); |
|
389 |
String msg = ioe.getMessage(); |
|
390 |
||
391 |
List<String> expectedMessages = new ArrayList<>(); |
|
392 |
expectedMessages.add(expectedMsg); |
|
393 |
MSGS_ORDER.stream().takeWhile(s -> !s.equals(expectedMsg)) |
|
394 |
.forEach(expectedMessages::add); |
|
395 |
||
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
396 |
assertExpectedMessage(request, ioe, expectedMessages); |
50681 | 397 |
assertNoConnectionExpiredException(ioe); |
398 |
} else { |
|
399 |
throw ee; |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
} |
|
404 |
||
53256
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
405 |
|
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
406 |
void assertExpectedMessage(HttpRequest request, Throwable t, String expected) { |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
407 |
if (request.uri().getScheme().equalsIgnoreCase("https") |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
408 |
&& (t instanceof SSLHandshakeException)) { |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
409 |
// OK |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
410 |
out.println("Skipping expected " + t); |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
411 |
} else { |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
412 |
String msg = t.getMessage(); |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
413 |
assertTrue(msg.contains(expected), |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
414 |
"exception msg:[" + msg + "]"); |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
415 |
} |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
416 |
} |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
417 |
|
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
418 |
void assertExpectedMessage(HttpRequest request, Throwable t, List<String> expected) { |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
419 |
if (request.uri().getScheme().equalsIgnoreCase("https") |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
420 |
&& (t instanceof SSLHandshakeException)) { |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
421 |
// OK |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
422 |
out.println("Skipping expected " + t); |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
423 |
} else { |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
424 |
String msg = t.getMessage(); |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
425 |
assertTrue(expected.stream().anyMatch(msg::contains), |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
426 |
"exception msg:[" + msg + "] not in " + Arrays.asList(expected)); |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
427 |
} |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
428 |
} |
bd8df96decba
8216498: Confusing and unneeded wrapping of SSLHandshakeException
dfuchs
parents:
52121
diff
changeset
|
429 |
|
50681 | 430 |
// Asserts that the "send" method appears in the stack of the given |
431 |
// exception. The synchronous API must contain the send method on the stack. |
|
432 |
static void assertSendMethodOnStack(IOException ioe) { |
|
433 |
final String cn = "jdk.internal.net.http.HttpClientImpl"; |
|
434 |
List<StackTraceElement> list = Stream.of(ioe.getStackTrace()) |
|
435 |
.filter(ste -> ste.getClassName().equals(cn) |
|
436 |
&& ste.getMethodName().equals("send")) |
|
437 |
.collect(toList()); |
|
438 |
if (list.size() != 1) { |
|
439 |
ioe.printStackTrace(out); |
|
440 |
fail(cn + ".send method not found in stack."); |
|
441 |
} |
|
442 |
} |
|
443 |
||
444 |
// Asserts that the implementation-specific ConnectionExpiredException does |
|
445 |
// NOT appear anywhere in the exception or its causal chain. |
|
446 |
static void assertNoConnectionExpiredException(IOException ioe) { |
|
447 |
Throwable throwable = ioe; |
|
448 |
do { |
|
449 |
String cn = throwable.getClass().getSimpleName(); |
|
450 |
if (cn.equals("ConnectionExpiredException")) { |
|
451 |
ioe.printStackTrace(out); |
|
452 |
fail("UNEXPECTED ConnectionExpiredException in:[" + ioe + "]"); |
|
453 |
} |
|
454 |
} while ((throwable = throwable.getCause()) != null); |
|
455 |
} |
|
456 |
||
457 |
// -- infra |
|
458 |
||
459 |
/** |
|
460 |
* A server that, listens on a port, accepts new connections, and can be |
|
461 |
* closed. |
|
462 |
*/ |
|
463 |
static abstract class Server extends Thread implements AutoCloseable { |
|
464 |
protected final ServerSocket ss; |
|
465 |
protected volatile boolean closed; |
|
466 |
||
467 |
Server(String name) throws IOException { |
|
468 |
super(name); |
|
469 |
ss = newServerSocket(); |
|
470 |
ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); |
|
471 |
this.start(); |
|
472 |
} |
|
473 |
||
474 |
protected ServerSocket newServerSocket() throws IOException { |
|
475 |
return new ServerSocket(); |
|
476 |
} |
|
477 |
||
478 |
public int getPort() { return ss.getLocalPort(); } |
|
479 |
||
480 |
@Override |
|
481 |
public void close() { |
|
482 |
if (closed) |
|
483 |
return; |
|
484 |
closed = true; |
|
485 |
try { |
|
486 |
ss.close(); |
|
487 |
} catch (IOException e) { |
|
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
488 |
out.println("Unexpected exception while closing server: " + e); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
489 |
e.printStackTrace(out); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
490 |
throw new UncheckedIOException("Unexpected: ", e); |
50681 | 491 |
} |
492 |
} |
|
493 |
} |
|
494 |
||
495 |
/** |
|
496 |
* A server that closes the connection immediately, without reading or writing. |
|
497 |
*/ |
|
498 |
static class PlainCloseImmediatelyServer extends Server { |
|
499 |
PlainCloseImmediatelyServer() throws IOException { |
|
500 |
super("PlainCloseImmediatelyServer"); |
|
501 |
} |
|
502 |
||
503 |
protected PlainCloseImmediatelyServer(String name) throws IOException { |
|
504 |
super(name); |
|
505 |
} |
|
506 |
||
507 |
@Override |
|
508 |
public void run() { |
|
509 |
while (!closed) { |
|
510 |
try (Socket s = ss.accept()) { |
|
511 |
if (s instanceof SSLSocket) { |
|
512 |
((SSLSocket)s).startHandshake(); |
|
513 |
} |
|
514 |
out.println("Server: got connection, closing immediately "); |
|
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
515 |
} catch (Throwable e) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
516 |
if (!closed) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
517 |
out.println("Unexpected exception in server: " + e); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
518 |
e.printStackTrace(out); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
519 |
throw new RuntimeException("Unexpected: ", e); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
520 |
} |
50681 | 521 |
} |
522 |
} |
|
523 |
} |
|
524 |
} |
|
525 |
||
526 |
/** |
|
527 |
* A server that closes the connection immediately, without reading or writing, |
|
528 |
* after completing the SSL handshake. |
|
529 |
*/ |
|
530 |
static final class SSLCloseImmediatelyServer extends PlainCloseImmediatelyServer { |
|
531 |
SSLCloseImmediatelyServer() throws IOException { |
|
532 |
super("SSLCloseImmediatelyServer"); |
|
533 |
} |
|
534 |
@Override |
|
535 |
public ServerSocket newServerSocket() throws IOException { |
|
536 |
return SSLServerSocketFactory.getDefault().createServerSocket(); |
|
537 |
} |
|
538 |
} |
|
539 |
||
540 |
/** |
|
541 |
* A server that replies with headers and a, possibly partial, reply, before |
|
542 |
* closing the connection. The number of bytes of written ( header + body), |
|
543 |
* is controllable through the "length" query string param in the requested |
|
544 |
* URI. |
|
545 |
*/ |
|
546 |
static abstract class ReplyingServer extends Server { |
|
547 |
||
548 |
private final String name; |
|
549 |
||
550 |
ReplyingServer(String name) throws IOException { |
|
551 |
super(name); |
|
552 |
this.name = name; |
|
553 |
} |
|
554 |
||
555 |
abstract String response(); |
|
556 |
||
557 |
@Override |
|
558 |
public void run() { |
|
559 |
while (!closed) { |
|
560 |
try (Socket s = ss.accept()) { |
|
561 |
out.print(name + ": got connection "); |
|
562 |
InputStream is = s.getInputStream(); |
|
563 |
URI requestMethod = readRequestMethod(is); |
|
564 |
out.print(requestMethod + " "); |
|
565 |
URI uriPath = readRequestPath(is); |
|
566 |
out.println(uriPath); |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
567 |
String headers = readRequestHeaders(is); |
50681 | 568 |
|
569 |
String query = uriPath.getRawQuery(); |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
570 |
if (query == null) { |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
571 |
out.println("Request headers: [" + headers + "]"); |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
572 |
} |
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
573 |
assert query != null : "null query for uriPath: " + uriPath; |
50681 | 574 |
String qv = query.split("=")[1]; |
575 |
int len; |
|
576 |
if (qv.equals("all")) { |
|
577 |
len = response().getBytes(US_ASCII).length; |
|
578 |
} else { |
|
579 |
len = Integer.parseInt(query.split("=")[1]); |
|
580 |
} |
|
581 |
||
582 |
OutputStream os = s.getOutputStream(); |
|
583 |
out.println(name + ": writing " + len + " bytes"); |
|
584 |
byte[] responseBytes = response().getBytes(US_ASCII); |
|
585 |
for (int i = 0; i< len; i++) { |
|
586 |
os.write(responseBytes[i]); |
|
587 |
os.flush(); |
|
588 |
} |
|
58968
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
589 |
} catch (Throwable e) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
590 |
if (!closed) { |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
591 |
out.println("Unexpected exception in server: " + e); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
592 |
e.printStackTrace(out); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
593 |
throw new RuntimeException("Unexpected: " + e, e); |
7f1daafda27b
8233403: Improve verbosity of some httpclient tests
dfuchs
parents:
53256
diff
changeset
|
594 |
} |
50681 | 595 |
} |
596 |
} |
|
597 |
} |
|
598 |
||
599 |
static final byte[] requestEnd = new byte[] { '\r', '\n', '\r', '\n' }; |
|
600 |
||
601 |
// Read the request method |
|
602 |
static URI readRequestMethod(InputStream is) throws IOException { |
|
603 |
StringBuilder sb = new StringBuilder(); |
|
604 |
int r; |
|
605 |
while ((r = is.read()) != -1 && r != 0x20) { |
|
606 |
sb.append((char)r); |
|
607 |
} |
|
608 |
return URI.create(sb.toString()); |
|
609 |
} |
|
610 |
||
611 |
// Read the request URI path |
|
612 |
static URI readRequestPath(InputStream is) throws IOException { |
|
613 |
StringBuilder sb = new StringBuilder(); |
|
614 |
int r; |
|
615 |
while ((r = is.read()) != -1 && r != 0x20) { |
|
616 |
sb.append((char)r); |
|
617 |
} |
|
618 |
return URI.create(sb.toString()); |
|
619 |
} |
|
620 |
||
621 |
// Read until the end of a HTTP request headers |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
622 |
static String readRequestHeaders(InputStream is) throws IOException { |
50681 | 623 |
int requestEndCount = 0, r; |
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
624 |
StringBuilder sb = new StringBuilder(); |
50681 | 625 |
while ((r = is.read()) != -1) { |
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
626 |
sb.append((char) r); |
50681 | 627 |
if (r == requestEnd[requestEndCount]) { |
628 |
requestEndCount++; |
|
629 |
if (requestEndCount == 4) { |
|
630 |
break; |
|
631 |
} |
|
632 |
} else { |
|
633 |
requestEndCount = 0; |
|
634 |
} |
|
635 |
} |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
636 |
return sb.toString(); |
50681 | 637 |
} |
638 |
} |
|
639 |
||
640 |
/** A server that issues a, possibly-partial, chunked reply. */ |
|
641 |
static class PlainVariableLengthServer extends ReplyingServer { |
|
642 |
||
643 |
static final String CHUNKED_RESPONSE_BODY = |
|
644 |
"6\r\n"+ "<html>\r\n" + |
|
645 |
"6\r\n"+ "<body>\r\n" + |
|
646 |
"10\r\n"+ "<h1>Heading</h1>\r\n" + |
|
647 |
"10\r\n"+ "<p>Some Text</p>\r\n" + |
|
648 |
"7\r\n"+ "</body>\r\n" + |
|
649 |
"7\r\n"+ "</html>\r\n" + |
|
650 |
"0\r\n"+ "\r\n"; |
|
651 |
||
652 |
static final String RESPONSE_HEADERS = |
|
653 |
"HTTP/1.1 200 OK\r\n" + |
|
654 |
"Content-Type: text/html; charset=utf-8\r\n" + |
|
655 |
"Transfer-Encoding: chunked\r\n" + |
|
656 |
"Connection: close\r\n\r\n"; |
|
657 |
||
658 |
static final String RESPONSE = RESPONSE_HEADERS + CHUNKED_RESPONSE_BODY; |
|
659 |
||
660 |
PlainVariableLengthServer() throws IOException { |
|
661 |
super("PlainVariableLengthServer"); |
|
662 |
} |
|
663 |
||
664 |
protected PlainVariableLengthServer(String name) throws IOException { |
|
665 |
super(name); |
|
666 |
} |
|
667 |
||
668 |
@Override |
|
669 |
String response( ) { return RESPONSE; } |
|
670 |
} |
|
671 |
||
672 |
/** A server that issues a, possibly-partial, chunked reply over SSL. */ |
|
673 |
static final class SSLVariableLengthServer extends PlainVariableLengthServer { |
|
674 |
SSLVariableLengthServer() throws IOException { |
|
675 |
super("SSLVariableLengthServer"); |
|
676 |
} |
|
677 |
@Override |
|
678 |
public ServerSocket newServerSocket() throws IOException { |
|
679 |
return SSLServerSocketFactory.getDefault().createServerSocket(); |
|
680 |
} |
|
681 |
} |
|
682 |
||
683 |
/** A server that issues a fixed-length reply. */ |
|
684 |
static final class FixedLengthServer extends ReplyingServer { |
|
685 |
||
686 |
static final String RESPONSE_BODY = EXPECTED_RESPONSE_BODY; |
|
687 |
||
688 |
static final String RESPONSE_HEADERS = |
|
689 |
"HTTP/1.1 200 OK\r\n" + |
|
690 |
"Content-Type: text/html; charset=utf-8\r\n" + |
|
691 |
"Content-Length: " + RESPONSE_BODY.length() + "\r\n" + |
|
692 |
"Connection: close\r\n\r\n"; |
|
693 |
||
694 |
static final String RESPONSE = RESPONSE_HEADERS + RESPONSE_BODY; |
|
695 |
||
696 |
FixedLengthServer() throws IOException { |
|
697 |
super("FixedLengthServer"); |
|
698 |
} |
|
699 |
||
700 |
@Override |
|
701 |
String response( ) { return RESPONSE; } |
|
702 |
} |
|
703 |
||
704 |
static String serverAuthority(Server server) { |
|
705 |
return InetAddress.getLoopbackAddress().getHostName() + ":" |
|
706 |
+ server.getPort(); |
|
707 |
} |
|
708 |
||
709 |
@BeforeTest |
|
710 |
public void setup() throws Exception { |
|
711 |
sslContext = new SimpleSSLContext().get(); |
|
712 |
if (sslContext == null) |
|
713 |
throw new AssertionError("Unexpected null sslContext"); |
|
714 |
SSLContext.setDefault(sslContext); |
|
715 |
||
716 |
sslParameters = new SSLParameters(); |
|
717 |
sslParameters.setProtocols(new String[] {"TLSv1.2"}); |
|
718 |
||
719 |
closeImmediatelyServer = new PlainCloseImmediatelyServer(); |
|
720 |
httpURIClsImed = "http://" + serverAuthority(closeImmediatelyServer) |
|
721 |
+ "/http1/closeImmediately/foo"; |
|
722 |
||
723 |
closeImmediatelyHttpsServer = new SSLCloseImmediatelyServer(); |
|
724 |
httpsURIClsImed = "https://" + serverAuthority(closeImmediatelyHttpsServer) |
|
725 |
+ "/https1/closeImmediately/foo"; |
|
726 |
||
727 |
variableLengthServer = new PlainVariableLengthServer(); |
|
728 |
httpURIVarLen = "http://" + serverAuthority(variableLengthServer) |
|
729 |
+ "/http1/variable/bar"; |
|
730 |
||
731 |
variableLengthHttpsServer = new SSLVariableLengthServer(); |
|
732 |
httpsURIVarLen = "https://" + serverAuthority(variableLengthHttpsServer) |
|
733 |
+ "/https1/variable/bar"; |
|
734 |
||
735 |
fixedLengthServer = new FixedLengthServer(); |
|
736 |
httpURIFixLen = "http://" + serverAuthority(fixedLengthServer) |
|
737 |
+ "/http1/fixed/baz"; |
|
738 |
} |
|
739 |
||
740 |
@AfterTest |
|
741 |
public void teardown() throws Exception { |
|
742 |
closeImmediatelyServer.close(); |
|
743 |
closeImmediatelyHttpsServer.close(); |
|
744 |
variableLengthServer.close(); |
|
745 |
variableLengthHttpsServer.close(); |
|
746 |
fixedLengthServer.close(); |
|
747 |
} |
|
748 |
} |