author | michaelm |
Fri, 16 Feb 2018 10:34:17 +0000 | |
branch | http-client-branch |
changeset 56137 | dd867826d55b |
parent 56092 | fd85b2bf2b0d |
child 56423 | ba64c30666cc |
permissions | -rw-r--r-- |
48083 | 1 |
/* |
56079
d23b02f37fce
http-client-branch: more remaining impl types to internal
chegar
parents:
56010
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
48083 | 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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
56092
fd85b2bf2b0d
http-client-branch: move implementation to jdk.internal.net.http
chegar
parents:
56089
diff
changeset
|
26 |
package jdk.internal.net.http; |
48083 | 27 |
|
28 |
import java.io.IOException; |
|
29 |
import java.lang.ref.Reference; |
|
30 |
import java.net.Authenticator; |
|
31 |
import java.net.CookieHandler; |
|
32 |
import java.net.ProxySelector; |
|
33 |
import java.util.Optional; |
|
34 |
import java.util.concurrent.CompletableFuture; |
|
35 |
import java.util.concurrent.Executor; |
|
36 |
import javax.net.ssl.SSLContext; |
|
37 |
import javax.net.ssl.SSLParameters; |
|
56089
42208b2f224e
http-client-branch: move to standard package and module name
chegar
parents:
56079
diff
changeset
|
38 |
import java.net.http.HttpClient; |
42208b2f224e
http-client-branch: move to standard package and module name
chegar
parents:
56079
diff
changeset
|
39 |
import java.net.http.HttpRequest; |
42208b2f224e
http-client-branch: move to standard package and module name
chegar
parents:
56079
diff
changeset
|
40 |
import java.net.http.HttpResponse; |
42208b2f224e
http-client-branch: move to standard package and module name
chegar
parents:
56079
diff
changeset
|
41 |
import java.net.http.HttpResponse.BodyHandler; |
42208b2f224e
http-client-branch: move to standard package and module name
chegar
parents:
56079
diff
changeset
|
42 |
import java.net.http.HttpResponse.PushPromiseHandler; |
42208b2f224e
http-client-branch: move to standard package and module name
chegar
parents:
56079
diff
changeset
|
43 |
import java.net.http.WebSocket; |
48083 | 44 |
|
45 |
/** |
|
46 |
* An HttpClientFacade is a simple class that wraps an HttpClient implementation |
|
47 |
* and delegates everything to its implementation delegate. |
|
48 |
*/ |
|
49 |
final class HttpClientFacade extends HttpClient { |
|
50 |
||
51 |
final HttpClientImpl impl; |
|
52 |
||
53 |
/** |
|
54 |
* Creates an HttpClientFacade. |
|
55 |
*/ |
|
56 |
HttpClientFacade(HttpClientImpl impl) { |
|
57 |
this.impl = impl; |
|
58 |
} |
|
59 |
||
60 |
@Override |
|
61 |
public Optional<CookieHandler> cookieHandler() { |
|
62 |
return impl.cookieHandler(); |
|
63 |
} |
|
64 |
||
65 |
@Override |
|
66 |
public Redirect followRedirects() { |
|
67 |
return impl.followRedirects(); |
|
68 |
} |
|
69 |
||
70 |
@Override |
|
71 |
public Optional<ProxySelector> proxy() { |
|
72 |
return impl.proxy(); |
|
73 |
} |
|
74 |
||
75 |
@Override |
|
76 |
public SSLContext sslContext() { |
|
77 |
return impl.sslContext(); |
|
78 |
} |
|
79 |
||
80 |
@Override |
|
81 |
public SSLParameters sslParameters() { |
|
82 |
return impl.sslParameters(); |
|
83 |
} |
|
84 |
||
85 |
@Override |
|
86 |
public Optional<Authenticator> authenticator() { |
|
87 |
return impl.authenticator(); |
|
88 |
} |
|
89 |
||
90 |
@Override |
|
91 |
public HttpClient.Version version() { |
|
92 |
return impl.version(); |
|
93 |
} |
|
94 |
||
95 |
@Override |
|
96 |
public Optional<Executor> executor() { |
|
97 |
return impl.executor(); |
|
98 |
} |
|
99 |
||
100 |
@Override |
|
101 |
public <T> HttpResponse<T> |
|
102 |
send(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler) |
|
103 |
throws IOException, InterruptedException |
|
104 |
{ |
|
105 |
try { |
|
106 |
return impl.send(req, responseBodyHandler); |
|
107 |
} finally { |
|
108 |
Reference.reachabilityFence(this); |
|
109 |
} |
|
110 |
} |
|
111 |
||
112 |
@Override |
|
113 |
public <T> CompletableFuture<HttpResponse<T>> |
|
114 |
sendAsync(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler) { |
|
115 |
try { |
|
116 |
return impl.sendAsync(req, responseBodyHandler); |
|
117 |
} finally { |
|
118 |
Reference.reachabilityFence(this); |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
@Override |
|
56010 | 123 |
public <T> CompletableFuture<HttpResponse<T>> |
124 |
sendAsync(HttpRequest req, |
|
125 |
BodyHandler<T> responseBodyHandler, |
|
126 |
PushPromiseHandler<T> pushPromiseHandler){ |
|
48083 | 127 |
try { |
56010 | 128 |
return impl.sendAsync(req, responseBodyHandler, pushPromiseHandler); |
48083 | 129 |
} finally { |
130 |
Reference.reachabilityFence(this); |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
@Override |
|
135 |
public WebSocket.Builder newWebSocketBuilder() { |
|
136 |
try { |
|
137 |
return impl.newWebSocketBuilder(); |
|
138 |
} finally { |
|
139 |
Reference.reachabilityFence(this); |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
@Override |
|
144 |
public String toString() { |
|
145 |
// Used by tests to get the client's id. |
|
146 |
return impl.toString(); |
|
147 |
} |
|
148 |
} |