author | mbaesken |
Thu, 28 Nov 2019 13:02:39 +0100 | |
changeset 59323 | ae2eb76c486d |
parent 55022 | 9785b9fb328e |
permissions | -rw-r--r-- |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
1 |
/* |
53300
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
4 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
10 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
15 |
* accompanied this code). |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
16 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
20 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
23 |
* questions. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
24 |
*/ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
25 |
|
49765 | 26 |
package jdk.internal.net.http; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
27 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
28 |
import java.io.IOException; |
55022
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
29 |
import java.net.http.HttpClient; |
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
30 |
import java.net.http.HttpResponse; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
31 |
import java.util.concurrent.CompletableFuture; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
32 |
import java.util.concurrent.Executor; |
55022
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
33 |
|
49765 | 34 |
import jdk.internal.net.http.common.Logger; |
35 |
import jdk.internal.net.http.common.MinimalFuture; |
|
50681 | 36 |
import jdk.internal.net.http.common.Utils; |
55022
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
37 |
|
49765 | 38 |
import static java.net.http.HttpClient.Version.HTTP_1_1; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
39 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
40 |
/** |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
41 |
* Splits request so that headers and body can be sent separately with optional |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
42 |
* (multiple) responses in between (e.g. 100 Continue). Also request and |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
43 |
* response always sent/received in different calls. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
44 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
45 |
* Synchronous and asynchronous versions of each method are provided. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
46 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
47 |
* Separate implementations of this class exist for HTTP/1.1 and HTTP/2 |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
48 |
* Http1Exchange (HTTP/1.1) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
49 |
* Stream (HTTP/2) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
50 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
51 |
* These implementation classes are where work is allocated to threads. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
52 |
*/ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
53 |
abstract class ExchangeImpl<T> { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
54 |
|
49765 | 55 |
private static final Logger debug = |
56 |
Utils.getDebugLogger("ExchangeImpl"::toString, Utils.DEBUG); |
|
48083 | 57 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
58 |
final Exchange<T> exchange; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
59 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
60 |
ExchangeImpl(Exchange<T> e) { |
45708
3512073b446f
8178699: Fail to send async requests if server doesn't response the first one
xiaofeya
parents:
44854
diff
changeset
|
61 |
// e == null means a http/2 pushed stream |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
62 |
this.exchange = e; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
63 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
64 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
65 |
final Exchange<T> getExchange() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
66 |
return exchange; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
67 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
68 |
|
52554
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
69 |
HttpClient client() { |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
70 |
return exchange.client(); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
71 |
} |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
72 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
73 |
/** |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
74 |
* Returns the {@link HttpConnection} instance to which this exchange is |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
75 |
* assigned. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
76 |
*/ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
77 |
abstract HttpConnection connection(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
78 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
79 |
/** |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
80 |
* Initiates a new exchange and assigns it to a connection if one exists |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
81 |
* already. connection usually null. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
82 |
*/ |
48083 | 83 |
static <U> CompletableFuture<? extends ExchangeImpl<U>> |
84 |
get(Exchange<U> exchange, HttpConnection connection) |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
85 |
{ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
86 |
if (exchange.version() == HTTP_1_1) { |
49765 | 87 |
if (debug.on()) |
88 |
debug.log("get: HTTP/1.1: new Http1Exchange"); |
|
48083 | 89 |
return createHttp1Exchange(exchange, connection); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
90 |
} else { |
49765 | 91 |
Http2ClientImpl c2 = exchange.client().client2(); // #### improve |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
92 |
HttpRequestImpl request = exchange.request(); |
51364
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50681
diff
changeset
|
93 |
CompletableFuture<Http2Connection> c2f = c2.getConnectionFor(request, exchange); |
49765 | 94 |
if (debug.on()) |
95 |
debug.log("get: Trying to get HTTP/2 connection"); |
|
55022
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
96 |
// local variable required here; see JDK-8223553 |
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
97 |
CompletableFuture<CompletableFuture<? extends ExchangeImpl<U>>> fxi = |
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
98 |
c2f.handle((h2c, t) -> createExchangeImpl(h2c, t, exchange, connection)); |
9785b9fb328e
8223553: Fix code constructs that do not compile with the Eclipse Java Compiler
clanger
parents:
53300
diff
changeset
|
99 |
return fxi.thenCompose(x->x); |
48083 | 100 |
} |
101 |
} |
|
102 |
||
103 |
private static <U> CompletableFuture<? extends ExchangeImpl<U>> |
|
104 |
createExchangeImpl(Http2Connection c, |
|
105 |
Throwable t, |
|
106 |
Exchange<U> exchange, |
|
107 |
HttpConnection connection) |
|
108 |
{ |
|
49765 | 109 |
if (debug.on()) |
110 |
debug.log("handling HTTP/2 connection creation result"); |
|
48376
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
111 |
boolean secure = exchange.request().secure(); |
48083 | 112 |
if (t != null) { |
49765 | 113 |
if (debug.on()) |
114 |
debug.log("handling HTTP/2 connection creation failed: %s", |
|
115 |
(Object)t); |
|
48083 | 116 |
t = Utils.getCompletionCause(t); |
117 |
if (t instanceof Http2Connection.ALPNException) { |
|
118 |
Http2Connection.ALPNException ee = (Http2Connection.ALPNException)t; |
|
119 |
AbstractAsyncSSLConnection as = ee.getConnection(); |
|
49765 | 120 |
if (debug.on()) |
121 |
debug.log("downgrading to HTTP/1.1 with: %s", as); |
|
48083 | 122 |
CompletableFuture<? extends ExchangeImpl<U>> ex = |
123 |
createHttp1Exchange(exchange, as); |
|
44854
5a486e0acd29
8175814: Update default HttpClient protocol version and optional request version
michaelm
parents:
43999
diff
changeset
|
124 |
return ex; |
48083 | 125 |
} else { |
49765 | 126 |
if (debug.on()) |
127 |
debug.log("HTTP/2 connection creation failed " |
|
128 |
+ "with unexpected exception: %s", (Object)t); |
|
129 |
return MinimalFuture.failedFuture(t); |
|
44854
5a486e0acd29
8175814: Update default HttpClient protocol version and optional request version
michaelm
parents:
43999
diff
changeset
|
130 |
} |
48083 | 131 |
} |
48376
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
132 |
if (secure && c== null) { |
49765 | 133 |
if (debug.on()) |
134 |
debug.log("downgrading to HTTP/1.1 "); |
|
48376
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
135 |
CompletableFuture<? extends ExchangeImpl<U>> ex = |
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
136 |
createHttp1Exchange(exchange, null); |
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
137 |
return ex; |
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
138 |
} |
48083 | 139 |
if (c == null) { |
140 |
// no existing connection. Send request with HTTP 1 and then |
|
141 |
// upgrade if successful |
|
49765 | 142 |
if (debug.on()) |
143 |
debug.log("new Http1Exchange, try to upgrade"); |
|
48083 | 144 |
return createHttp1Exchange(exchange, connection) |
145 |
.thenApply((e) -> { |
|
146 |
exchange.h2Upgrade(); |
|
147 |
return e; |
|
148 |
}); |
|
149 |
} else { |
|
49765 | 150 |
if (debug.on()) debug.log("creating HTTP/2 streams"); |
48083 | 151 |
Stream<U> s = c.createStream(exchange); |
152 |
CompletableFuture<? extends ExchangeImpl<U>> ex = MinimalFuture.completedFuture(s); |
|
153 |
return ex; |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
private static <T> CompletableFuture<Http1Exchange<T>> |
|
158 |
createHttp1Exchange(Exchange<T> ex, HttpConnection as) |
|
159 |
{ |
|
160 |
try { |
|
161 |
return MinimalFuture.completedFuture(new Http1Exchange<>(ex, as)); |
|
162 |
} catch (Throwable e) { |
|
163 |
return MinimalFuture.failedFuture(e); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
164 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
165 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
166 |
|
53300
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
167 |
// Called for 204 response - when no body is permitted |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
168 |
void nullBody(HttpResponse<T> resp, Throwable t) { |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
169 |
// only needed for HTTP/1.1 to close the connection |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
170 |
// or return it to the pool |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
171 |
} |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
172 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
173 |
/* The following methods have separate HTTP/1.1 and HTTP/2 implementations */ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
174 |
|
48083 | 175 |
abstract CompletableFuture<ExchangeImpl<T>> sendHeadersAsync(); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
176 |
|
48083 | 177 |
/** Sends a request body, after request headers have been sent. */ |
178 |
abstract CompletableFuture<ExchangeImpl<T>> sendBodyAsync(); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
179 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
180 |
abstract CompletableFuture<T> readBodyAsync(HttpResponse.BodyHandler<T> handler, |
43999
4cc44dd9f14f
8164625: Pooled HttpConnection should be removed during close
prappo
parents:
43984
diff
changeset
|
181 |
boolean returnConnectionToPool, |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
182 |
Executor executor); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
183 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
184 |
/** |
48083 | 185 |
* Ignore/consume the body. |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
186 |
*/ |
48083 | 187 |
abstract CompletableFuture<Void> ignoreBody(); |
188 |
||
53300
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
189 |
|
48083 | 190 |
/** Gets the response headers. Completes before body is read. */ |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
191 |
abstract CompletableFuture<Response> getResponseAsync(Executor executor); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
192 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
193 |
|
48083 | 194 |
/** Cancels a request. Not currently exposed through API. */ |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
195 |
abstract void cancel(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
196 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
197 |
/** |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
198 |
* Cancels a request with a cause. Not currently exposed through API. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
199 |
*/ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
200 |
abstract void cancel(IOException cause); |
48083 | 201 |
|
202 |
/** |
|
203 |
* Called when the exchange is released, so that cleanup actions may be |
|
204 |
* performed - such as deregistering callbacks. |
|
205 |
* Typically released is called during upgrade, when an HTTP/2 stream |
|
206 |
* takes over from an Http1Exchange, or when a new exchange is created |
|
207 |
* during a multi exchange before the final response body was received. |
|
208 |
*/ |
|
209 |
abstract void released(); |
|
210 |
||
211 |
/** |
|
212 |
* Called when the exchange is completed, so that cleanup actions may be |
|
213 |
* performed - such as deregistering callbacks. |
|
214 |
* Typically, completed is called at the end of the exchange, when the |
|
215 |
* final response body has been received (or an error has caused the |
|
216 |
* completion of the exchange). |
|
217 |
*/ |
|
218 |
abstract void completed(); |
|
219 |
||
220 |
/** |
|
221 |
* Returns true if this exchange was canceled. |
|
222 |
* @return true if this exchange was canceled. |
|
223 |
*/ |
|
224 |
abstract boolean isCanceled(); |
|
225 |
||
226 |
/** |
|
227 |
* Returns the cause for which this exchange was canceled, if available. |
|
228 |
* @return the cause for which this exchange was canceled, if available. |
|
229 |
*/ |
|
230 |
abstract Throwable getCancelCause(); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
231 |
} |