Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/net/httpclient/ALPNProxyFailureTest.java
41149 views
1
/*
2
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
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
26
* @summary This test will timeout if the ALPN CF is not completed
27
* when a 'Connection reset by peer' exception is raised
28
* during the handshake.
29
* @bug 8217094
30
* @library /test/lib http2/server
31
* @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer
32
* ALPNFailureTest ALPNProxyFailureTest
33
* @modules java.net.http/jdk.internal.net.http.common
34
* java.net.http/jdk.internal.net.http.frame
35
* java.net.http/jdk.internal.net.http.hpack
36
* java.logging
37
* java.base/sun.net.www.http
38
* java.base/sun.net.www
39
* java.base/sun.net
40
* @build ALPNFailureTest
41
* @run main/othervm -Djdk.internal.httpclient.debug=true -Dtest.nolinger=true ALPNProxyFailureTest HTTP_1_1
42
* @run main/othervm -Dtest.nolinger=true ALPNProxyFailureTest HTTP_2
43
*/
44
import javax.net.ServerSocketFactory;
45
import javax.net.ssl.SSLContext;
46
import jdk.test.lib.net.SimpleSSLContext;
47
import java.net.InetAddress;
48
import java.net.ProxySelector;
49
import java.net.ServerSocket;
50
import java.net.http.HttpClient;
51
52
public class ALPNProxyFailureTest extends ALPNFailureTest {
53
54
static final SSLContext context;
55
static {
56
try {
57
context = new SimpleSSLContext().get();
58
SSLContext.setDefault(context);
59
} catch (Exception x) {
60
throw new ExceptionInInitializerError(x);
61
}
62
}
63
64
public static void main(String[] args) throws Exception{
65
if (args == null || args.length == 0) {
66
args = new String[] {HttpClient.Version.HTTP_1_1.name()};
67
}
68
ServerSocket socket = ServerSocketFactory.getDefault()
69
.createServerSocket(0, 10, InetAddress.getLoopbackAddress());
70
71
DigestEchoServer.TunnelingProxy proxy = DigestEchoServer.createHttpsProxyTunnel(
72
DigestEchoServer.HttpAuthSchemeType.NONE);
73
ProxySelector ps = ProxySelector.of(proxy.getProxyAddress());
74
75
try {
76
test(socket, context, ps, args);
77
} finally {
78
proxy.stop();
79
}
80
}
81
82
}
83
84