author | mbaesken |
Thu, 28 Nov 2019 13:02:39 +0100 | |
changeset 59323 | ae2eb76c486d |
parent 53387 | c9622e15ba29 |
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; |
48083 | 29 |
import java.lang.System.Logger.Level; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
30 |
import java.net.InetSocketAddress; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
31 |
import java.net.ProxySelector; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
32 |
import java.net.URI; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
33 |
import java.net.URISyntaxException; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
34 |
import java.net.URLPermission; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
35 |
import java.security.AccessControlContext; |
53387
c9622e15ba29
8216561: HttpClient: The logic of retry on connect exception is inverted
dfuchs
parents:
53300
diff
changeset
|
36 |
import java.time.Duration; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
37 |
import java.util.List; |
48083 | 38 |
import java.util.Map; |
53387
c9622e15ba29
8216561: HttpClient: The logic of retry on connect exception is inverted
dfuchs
parents:
53300
diff
changeset
|
39 |
import java.util.Optional; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
40 |
import java.util.concurrent.CompletableFuture; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
41 |
import java.util.concurrent.Executor; |
49765 | 42 |
import java.util.function.Function; |
43 |
import java.net.http.HttpClient; |
|
44 |
import java.net.http.HttpHeaders; |
|
45 |
import java.net.http.HttpResponse; |
|
46 |
import java.net.http.HttpTimeoutException; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
47 |
|
49765 | 48 |
import jdk.internal.net.http.common.Logger; |
49 |
import jdk.internal.net.http.common.MinimalFuture; |
|
50 |
import jdk.internal.net.http.common.Utils; |
|
51 |
import jdk.internal.net.http.common.Log; |
|
52 |
||
53 |
import static jdk.internal.net.http.common.Utils.permissionForProxy; |
|
48083 | 54 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
55 |
/** |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
56 |
* One request/response exchange (handles 100/101 intermediate response also). |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
57 |
* depth field used to track number of times a new request is being sent |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
58 |
* for a given API request. If limit exceeded exception is thrown. |
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 |
* Security check is performed here: |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
61 |
* - uses AccessControlContext captured at API level |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
62 |
* - checks for appropriate URLPermission for request |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
63 |
* - if permission allowed, grants equivalent SocketPermission to call |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
64 |
* - in case of direct HTTP proxy, checks additionally for access to proxy |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
65 |
* (CONNECT proxying uses its own Exchange, so check done there) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
66 |
* |
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 |
final class Exchange<T> { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
69 |
|
49765 | 70 |
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG); |
48083 | 71 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
72 |
final HttpRequestImpl request; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
73 |
final HttpClientImpl client; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
74 |
volatile ExchangeImpl<T> exchImpl; |
48083 | 75 |
volatile CompletableFuture<? extends ExchangeImpl<T>> exchangeCF; |
49765 | 76 |
volatile CompletableFuture<Void> bodyIgnored; |
77 |
||
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
78 |
// used to record possible cancellation raised before the exchImpl |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
79 |
// has been established. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
80 |
private volatile IOException failed; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
81 |
final AccessControlContext acc; |
49765 | 82 |
final MultiExchange<T> multi; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
83 |
final Executor parentExecutor; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
84 |
boolean upgrading; // to HTTP/2 |
49765 | 85 |
final PushGroup<T> pushGroup; |
48083 | 86 |
final String dbgTag; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
87 |
|
51364
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
88 |
// Keeps track of the underlying connection when establishing an HTTP/2 |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
89 |
// exchange so that it can be aborted/timed out mid setup. |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
90 |
final ConnectionAborter connectionAborter = new ConnectionAborter(); |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
91 |
|
49765 | 92 |
Exchange(HttpRequestImpl request, MultiExchange<T> multi) { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
93 |
this.request = request; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
94 |
this.upgrading = false; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
95 |
this.client = multi.client(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
96 |
this.multi = multi; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
97 |
this.acc = multi.acc; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
98 |
this.parentExecutor = multi.executor; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
99 |
this.pushGroup = multi.pushGroup; |
48083 | 100 |
this.dbgTag = "Exchange"; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
101 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
102 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
103 |
/* If different AccessControlContext to be used */ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
104 |
Exchange(HttpRequestImpl request, |
49765 | 105 |
MultiExchange<T> multi, |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
106 |
AccessControlContext acc) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
107 |
{ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
108 |
this.request = request; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
109 |
this.acc = acc; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
110 |
this.upgrading = false; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
111 |
this.client = multi.client(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
112 |
this.multi = multi; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
113 |
this.parentExecutor = multi.executor; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
114 |
this.pushGroup = multi.pushGroup; |
48083 | 115 |
this.dbgTag = "Exchange"; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
116 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
117 |
|
49765 | 118 |
PushGroup<T> getPushGroup() { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
119 |
return pushGroup; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
120 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
121 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
122 |
Executor executor() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
123 |
return parentExecutor; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
124 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
125 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
126 |
public HttpRequestImpl request() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
127 |
return request; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
128 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
129 |
|
53387
c9622e15ba29
8216561: HttpClient: The logic of retry on connect exception is inverted
dfuchs
parents:
53300
diff
changeset
|
130 |
public Optional<Duration> remainingConnectTimeout() { |
c9622e15ba29
8216561: HttpClient: The logic of retry on connect exception is inverted
dfuchs
parents:
53300
diff
changeset
|
131 |
return multi.remainingConnectTimeout(); |
c9622e15ba29
8216561: HttpClient: The logic of retry on connect exception is inverted
dfuchs
parents:
53300
diff
changeset
|
132 |
} |
c9622e15ba29
8216561: HttpClient: The logic of retry on connect exception is inverted
dfuchs
parents:
53300
diff
changeset
|
133 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
134 |
HttpClientImpl client() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
135 |
return client; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
136 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
137 |
|
51364
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
138 |
// Keeps track of the underlying connection when establishing an HTTP/2 |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
139 |
// exchange so that it can be aborted/timed out mid setup. |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
140 |
static final class ConnectionAborter { |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
141 |
private volatile HttpConnection connection; |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
142 |
|
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
143 |
void connection(HttpConnection connection) { |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
144 |
this.connection = connection; |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
145 |
} |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
146 |
|
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
147 |
void closeConnection() { |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
148 |
HttpConnection connection = this.connection; |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
149 |
this.connection = null; |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
150 |
if (connection != null) { |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
151 |
try { |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
152 |
connection.close(); |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
153 |
} catch (Throwable t) { |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
154 |
// ignore |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
155 |
} |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
156 |
} |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
157 |
} |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
158 |
} |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
159 |
|
53300
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
160 |
// 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
|
161 |
// This is actually only needed for HTTP/1.1 in order |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
162 |
// to return the connection to the pool (or close it) |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
163 |
void nullBody(HttpResponse<T> resp, Throwable t) { |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
164 |
exchImpl.nullBody(resp, t); |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
165 |
} |
54aa3ea04fe8
8216974: HttpConnection not returned to the pool after 204 response
dfuchs
parents:
52554
diff
changeset
|
166 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
167 |
public CompletableFuture<T> readBodyAsync(HttpResponse.BodyHandler<T> handler) { |
49765 | 168 |
// If we received a 407 while establishing the exchange |
169 |
// there will be no body to read: bodyIgnored will be true, |
|
170 |
// and exchImpl will be null (if we were trying to establish |
|
171 |
// an HTTP/2 tunnel through an HTTP/1.1 proxy) |
|
172 |
if (bodyIgnored != null) return MinimalFuture.completedFuture(null); |
|
173 |
||
43999
4cc44dd9f14f
8164625: Pooled HttpConnection should be removed during close
prappo
parents:
43984
diff
changeset
|
174 |
// The connection will not be returned to the pool in the case of WebSocket |
48083 | 175 |
return exchImpl.readBodyAsync(handler, !request.isWebSocket(), parentExecutor) |
176 |
.whenComplete((r,t) -> exchImpl.completed()); |
|
177 |
} |
|
178 |
||
179 |
/** |
|
180 |
* Called after a redirect or similar kind of retry where a body might |
|
181 |
* be sent but we don't want it. Should send a RESET in h2. For http/1.1 |
|
182 |
* we can consume small quantity of data, or close the connection in |
|
183 |
* other cases. |
|
184 |
*/ |
|
185 |
public CompletableFuture<Void> ignoreBody() { |
|
49765 | 186 |
if (bodyIgnored != null) return bodyIgnored; |
48083 | 187 |
return exchImpl.ignoreBody(); |
188 |
} |
|
189 |
||
190 |
/** |
|
191 |
* Called when a new exchange is created to replace this exchange. |
|
192 |
* At this point it is guaranteed that readBody/readBodyAsync will |
|
193 |
* not be called. |
|
194 |
*/ |
|
195 |
public void released() { |
|
196 |
ExchangeImpl<?> impl = exchImpl; |
|
197 |
if (impl != null) impl.released(); |
|
198 |
// Don't set exchImpl to null here. We need to keep |
|
199 |
// it alive until it's replaced by a Stream in wrapForUpgrade. |
|
200 |
// Setting it to null here might get it GC'ed too early, because |
|
201 |
// the Http1Response is now only weakly referenced by the Selector. |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
202 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
203 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
204 |
public void cancel() { |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
205 |
// cancel can be called concurrently before or at the same time |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
206 |
// that the exchange impl is being established. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
207 |
// In that case we won't be able to propagate the cancellation |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
208 |
// right away |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
209 |
if (exchImpl != null) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
210 |
exchImpl.cancel(); |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
211 |
} else { |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
212 |
// no impl - can't cancel impl yet. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
213 |
// call cancel(IOException) instead which takes care |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
214 |
// of race conditions between impl/cancel. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
215 |
cancel(new IOException("Request cancelled")); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
216 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
217 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
218 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
219 |
public void cancel(IOException cause) { |
51364
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
220 |
if (debug.on()) debug.log("cancel exchImpl: %s, with \"%s\"", exchImpl, cause); |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
221 |
// If the impl is non null, propagate the exception right away. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
222 |
// Otherwise record it so that it can be propagated once the |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
223 |
// exchange impl has been established. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
224 |
ExchangeImpl<?> impl = exchImpl; |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
225 |
if (impl != null) { |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
226 |
// propagate the exception to the impl |
49765 | 227 |
if (debug.on()) debug.log("Cancelling exchImpl: %s", exchImpl); |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
228 |
impl.cancel(cause); |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
229 |
} else { |
48083 | 230 |
// no impl yet. record the exception |
231 |
failed = cause; |
|
51364
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
232 |
|
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
233 |
// abort/close the connection if setting up the exchange. This can |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
234 |
// be important when setting up HTTP/2 |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
235 |
connectionAborter.closeConnection(); |
31d9e82b2e64
8208391: Differentiate response and connect timeouts in HTTP Client API
chegar
parents:
50985
diff
changeset
|
236 |
|
48083 | 237 |
// now call checkCancelled to recheck the impl. |
238 |
// if the failed state is set and the impl is not null, reset |
|
239 |
// the failed state and propagate the exception to the impl. |
|
240 |
checkCancelled(); |
|
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
241 |
} |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
242 |
} |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
243 |
|
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
244 |
// This method will raise an exception if one was reported and if |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
245 |
// it is possible to do so. If the exception can be raised, then |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
246 |
// the failed state will be reset. Otherwise, the failed state |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
247 |
// will persist until the exception can be raised and the failed state |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
248 |
// can be cleared. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
249 |
// Takes care of possible race conditions. |
48083 | 250 |
private void checkCancelled() { |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
251 |
ExchangeImpl<?> impl = null; |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
252 |
IOException cause = null; |
48083 | 253 |
CompletableFuture<? extends ExchangeImpl<T>> cf = null; |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
254 |
if (failed != null) { |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
255 |
synchronized(this) { |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
256 |
cause = failed; |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
257 |
impl = exchImpl; |
48083 | 258 |
cf = exchangeCF; |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
259 |
} |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
260 |
} |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
261 |
if (cause == null) return; |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
262 |
if (impl != null) { |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
263 |
// The exception is raised by propagating it to the impl. |
49765 | 264 |
if (debug.on()) debug.log("Cancelling exchImpl: %s", impl); |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
265 |
impl.cancel(cause); |
48083 | 266 |
failed = null; |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
267 |
} else { |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
268 |
Log.logTrace("Exchange: request [{0}/timeout={1}ms] no impl is set." |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
269 |
+ "\n\tCan''t cancel yet with {2}", |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
270 |
request.uri(), |
48083 | 271 |
request.timeout().isPresent() ? |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
272 |
// calling duration.toMillis() can throw an exception. |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
273 |
// this is just debugging, we don't care if it overflows. |
48083 | 274 |
(request.timeout().get().getSeconds() * 1000 |
275 |
+ request.timeout().get().getNano() / 1000000) : -1, |
|
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
276 |
cause); |
48083 | 277 |
if (cf != null) cf.completeExceptionally(cause); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
278 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
279 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
280 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
281 |
public void h2Upgrade() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
282 |
upgrading = true; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
283 |
request.setH2Upgrade(client.client2()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
284 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
285 |
|
48083 | 286 |
synchronized IOException getCancelCause() { |
287 |
return failed; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
288 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
289 |
|
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
290 |
// get/set the exchange impl, solving race condition issues with |
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
291 |
// potential concurrent calls to cancel() or cancel(IOException) |
48083 | 292 |
private CompletableFuture<? extends ExchangeImpl<T>> |
293 |
establishExchange(HttpConnection connection) { |
|
49765 | 294 |
if (debug.on()) { |
295 |
debug.log("establishing exchange for %s,%n\t proxy=%s", |
|
296 |
request, request.proxy()); |
|
48083 | 297 |
} |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
43999
diff
changeset
|
298 |
// check if we have been cancelled first. |
48083 | 299 |
Throwable t = getCancelCause(); |
300 |
checkCancelled(); |
|
301 |
if (t != null) { |
|
302 |
return MinimalFuture.failedFuture(t); |
|
303 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
304 |
|
48083 | 305 |
CompletableFuture<? extends ExchangeImpl<T>> cf, res; |
306 |
cf = ExchangeImpl.get(this, connection); |
|
307 |
// We should probably use a VarHandle to get/set exchangeCF |
|
308 |
// instead - as we need CAS semantics. |
|
309 |
synchronized (this) { exchangeCF = cf; }; |
|
310 |
res = cf.whenComplete((r,x) -> { |
|
311 |
synchronized(Exchange.this) { |
|
312 |
if (exchangeCF == cf) exchangeCF = null; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
313 |
} |
48083 | 314 |
}); |
315 |
checkCancelled(); |
|
316 |
return res.thenCompose((eimpl) -> { |
|
317 |
// recheck for cancelled, in case of race conditions |
|
318 |
exchImpl = eimpl; |
|
319 |
IOException tt = getCancelCause(); |
|
320 |
checkCancelled(); |
|
321 |
if (tt != null) { |
|
322 |
return MinimalFuture.failedFuture(tt); |
|
323 |
} else { |
|
324 |
// Now we're good to go. Because exchImpl is no longer |
|
325 |
// null cancel() will be able to propagate directly to |
|
326 |
// the impl after this point ( if needed ). |
|
327 |
return MinimalFuture.completedFuture(eimpl); |
|
328 |
} }); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
329 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
330 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
331 |
// Completed HttpResponse will be null if response succeeded |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
332 |
// will be a non null responseAsync if expect continue returns an error |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
333 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
334 |
public CompletableFuture<Response> responseAsync() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
335 |
return responseAsyncImpl(null); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
336 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
337 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
338 |
CompletableFuture<Response> responseAsyncImpl(HttpConnection connection) { |
48083 | 339 |
SecurityException e = checkPermissions(); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
340 |
if (e != null) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
341 |
return MinimalFuture.failedFuture(e); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
342 |
} else { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
343 |
return responseAsyncImpl0(connection); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
344 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
345 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
346 |
|
49765 | 347 |
// check whether the headersSentCF was completed exceptionally with |
348 |
// ProxyAuthorizationRequired. If so the Response embedded in the |
|
349 |
// exception is returned. Otherwise we proceed. |
|
350 |
private CompletableFuture<Response> checkFor407(ExchangeImpl<T> ex, Throwable t, |
|
351 |
Function<ExchangeImpl<T>,CompletableFuture<Response>> andThen) { |
|
352 |
t = Utils.getCompletionCause(t); |
|
353 |
if (t instanceof ProxyAuthenticationRequired) { |
|
50681 | 354 |
if (debug.on()) debug.log("checkFor407: ProxyAuthenticationRequired: building synthetic response"); |
49765 | 355 |
bodyIgnored = MinimalFuture.completedFuture(null); |
356 |
Response proxyResponse = ((ProxyAuthenticationRequired)t).proxyResponse; |
|
357 |
HttpConnection c = ex == null ? null : ex.connection(); |
|
358 |
Response syntheticResponse = new Response(request, this, |
|
359 |
proxyResponse.headers, c, proxyResponse.statusCode, |
|
360 |
proxyResponse.version, true); |
|
361 |
return MinimalFuture.completedFuture(syntheticResponse); |
|
362 |
} else if (t != null) { |
|
50985
cd41f34e548c
8206001: Enable TLS1.3 by default in Http Client
michaelm
parents:
50681
diff
changeset
|
363 |
if (debug.on()) debug.log("checkFor407: no response - %s", (Object)t); |
49765 | 364 |
return MinimalFuture.failedFuture(t); |
365 |
} else { |
|
50681 | 366 |
if (debug.on()) debug.log("checkFor407: all clear"); |
49765 | 367 |
return andThen.apply(ex); |
368 |
} |
|
369 |
} |
|
370 |
||
371 |
// After sending the request headers, if no ProxyAuthorizationRequired |
|
372 |
// was raised and the expectContinue flag is on, we need to wait |
|
373 |
// for the 100-Continue response |
|
374 |
private CompletableFuture<Response> expectContinue(ExchangeImpl<T> ex) { |
|
375 |
assert request.expectContinue(); |
|
376 |
return ex.getResponseAsync(parentExecutor) |
|
377 |
.thenCompose((Response r1) -> { |
|
378 |
Log.logResponse(r1::toString); |
|
379 |
int rcode = r1.statusCode(); |
|
380 |
if (rcode == 100) { |
|
381 |
Log.logTrace("Received 100-Continue: sending body"); |
|
50681 | 382 |
if (debug.on()) debug.log("Received 100-Continue for %s", r1); |
49765 | 383 |
CompletableFuture<Response> cf = |
384 |
exchImpl.sendBodyAsync() |
|
385 |
.thenCompose(exIm -> exIm.getResponseAsync(parentExecutor)); |
|
386 |
cf = wrapForUpgrade(cf); |
|
387 |
cf = wrapForLog(cf); |
|
388 |
return cf; |
|
389 |
} else { |
|
390 |
Log.logTrace("Expectation failed: Received {0}", |
|
391 |
rcode); |
|
50681 | 392 |
if (debug.on()) debug.log("Expect-Continue failed (%d) for: %s", rcode, r1); |
49765 | 393 |
if (upgrading && rcode == 101) { |
394 |
IOException failed = new IOException( |
|
395 |
"Unable to handle 101 while waiting for 100"); |
|
396 |
return MinimalFuture.failedFuture(failed); |
|
397 |
} |
|
398 |
return exchImpl.readBodyAsync(this::ignoreBody, false, parentExecutor) |
|
399 |
.thenApply(v -> r1); |
|
400 |
} |
|
401 |
}); |
|
402 |
} |
|
403 |
||
404 |
// After sending the request headers, if no ProxyAuthorizationRequired |
|
405 |
// was raised and the expectContinue flag is off, we can immediately |
|
406 |
// send the request body and proceed. |
|
407 |
private CompletableFuture<Response> sendRequestBody(ExchangeImpl<T> ex) { |
|
408 |
assert !request.expectContinue(); |
|
50681 | 409 |
if (debug.on()) debug.log("sendRequestBody"); |
49765 | 410 |
CompletableFuture<Response> cf = ex.sendBodyAsync() |
411 |
.thenCompose(exIm -> exIm.getResponseAsync(parentExecutor)); |
|
412 |
cf = wrapForUpgrade(cf); |
|
413 |
cf = wrapForLog(cf); |
|
414 |
return cf; |
|
415 |
} |
|
416 |
||
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
417 |
CompletableFuture<Response> responseAsyncImpl0(HttpConnection connection) { |
49765 | 418 |
Function<ExchangeImpl<T>, CompletableFuture<Response>> after407Check; |
419 |
bodyIgnored = null; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
420 |
if (request.expectContinue()) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
421 |
request.addSystemHeader("Expect", "100-Continue"); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
422 |
Log.logTrace("Sending Expect: 100-Continue"); |
49765 | 423 |
// wait for 100-Continue before sending body |
424 |
after407Check = this::expectContinue; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
425 |
} else { |
49765 | 426 |
// send request body and proceed. |
427 |
after407Check = this::sendRequestBody; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
428 |
} |
49765 | 429 |
// The ProxyAuthorizationRequired can be triggered either by |
430 |
// establishExchange (case of HTTP/2 SSL tunneling through HTTP/1.1 proxy |
|
431 |
// or by sendHeaderAsync (case of HTTP/1.1 SSL tunneling through HTTP/1.1 proxy |
|
432 |
// Therefore we handle it with a call to this checkFor407(...) after these |
|
433 |
// two places. |
|
434 |
Function<ExchangeImpl<T>, CompletableFuture<Response>> afterExch407Check = |
|
435 |
(ex) -> ex.sendHeadersAsync() |
|
436 |
.handle((r,t) -> this.checkFor407(r, t, after407Check)) |
|
437 |
.thenCompose(Function.identity()); |
|
438 |
return establishExchange(connection) |
|
439 |
.handle((r,t) -> this.checkFor407(r,t, afterExch407Check)) |
|
440 |
.thenCompose(Function.identity()); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
441 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
442 |
|
43984 | 443 |
private CompletableFuture<Response> wrapForUpgrade(CompletableFuture<Response> cf) { |
444 |
if (upgrading) { |
|
445 |
return cf.thenCompose(r -> checkForUpgradeAsync(r, exchImpl)); |
|
446 |
} |
|
447 |
return cf; |
|
448 |
} |
|
449 |
||
450 |
private CompletableFuture<Response> wrapForLog(CompletableFuture<Response> cf) { |
|
451 |
if (Log.requests()) { |
|
452 |
return cf.thenApply(response -> { |
|
48083 | 453 |
Log.logResponse(response::toString); |
43984 | 454 |
return response; |
455 |
}); |
|
456 |
} |
|
457 |
return cf; |
|
458 |
} |
|
459 |
||
49765 | 460 |
HttpResponse.BodySubscriber<T> ignoreBody(HttpResponse.ResponseInfo hdrs) { |
461 |
return HttpResponse.BodySubscribers.replacing(null); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
462 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
463 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
464 |
// if this response was received in reply to an upgrade |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
465 |
// then create the Http2Connection from the HttpConnection |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
466 |
// initialize it and wait for the real response on a newly created Stream |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
467 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
468 |
private CompletableFuture<Response> |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
469 |
checkForUpgradeAsync(Response resp, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
470 |
ExchangeImpl<T> ex) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
471 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
472 |
int rcode = resp.statusCode(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
473 |
if (upgrading && (rcode == 101)) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
474 |
Http1Exchange<T> e = (Http1Exchange<T>)ex; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
475 |
// check for 101 switching protocols |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
476 |
// 101 responses are not supposed to contain a body. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
477 |
// => should we fail if there is one? |
49765 | 478 |
if (debug.on()) debug.log("Upgrading async %s", e.connection()); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
479 |
return e.readBodyAsync(this::ignoreBody, false, parentExecutor) |
48083 | 480 |
.thenCompose((T v) -> {// v is null |
49765 | 481 |
debug.log("Ignored body"); |
48083 | 482 |
// we pass e::getBuffer to allow the ByteBuffers to accumulate |
483 |
// while we build the Http2Connection |
|
484 |
return Http2Connection.createAsync(e.connection(), |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
485 |
client.client2(), |
48083 | 486 |
this, e::drainLeftOverBytes) |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
487 |
.thenCompose((Http2Connection c) -> { |
48376
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
488 |
boolean cached = c.offerConnection(); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
489 |
Stream<T> s = c.getStream(1); |
48376
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
490 |
|
48083 | 491 |
if (s == null) { |
492 |
// s can be null if an exception occurred |
|
493 |
// asynchronously while sending the preface. |
|
494 |
Throwable t = c.getRecordedCause(); |
|
49765 | 495 |
IOException ioe; |
48083 | 496 |
if (t != null) { |
48376
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
497 |
if (!cached) |
41ae5c69b09c
8192966: HttpClient should reuse TCP connection for h2c connections
michaelm
parents:
48083
diff
changeset
|
498 |
c.close(); |
49765 | 499 |
ioe = new IOException("Can't get stream 1: " + t, t); |
500 |
} else { |
|
501 |
ioe = new IOException("Can't get stream 1"); |
|
48083 | 502 |
} |
49765 | 503 |
return MinimalFuture.failedFuture(ioe); |
48083 | 504 |
} |
505 |
exchImpl.released(); |
|
506 |
Throwable t; |
|
507 |
// There's a race condition window where an external |
|
508 |
// thread (SelectorManager) might complete the |
|
509 |
// exchange in timeout at the same time where we're |
|
510 |
// trying to switch the exchange impl. |
|
511 |
// 'failed' will be reset to null after |
|
512 |
// exchImpl.cancel() has completed, so either we |
|
513 |
// will observe failed != null here, or we will |
|
514 |
// observe e.getCancelCause() != null, or the |
|
515 |
// timeout exception will be routed to 's'. |
|
516 |
// Either way, we need to relay it to s. |
|
517 |
synchronized (this) { |
|
518 |
exchImpl = s; |
|
519 |
t = failed; |
|
520 |
} |
|
521 |
// Check whether the HTTP/1.1 was cancelled. |
|
522 |
if (t == null) t = e.getCancelCause(); |
|
523 |
// if HTTP/1.1 exchange was timed out, don't |
|
524 |
// try to go further. |
|
525 |
if (t instanceof HttpTimeoutException) { |
|
526 |
s.cancelImpl(t); |
|
527 |
return MinimalFuture.failedFuture(t); |
|
528 |
} |
|
49765 | 529 |
if (debug.on()) |
530 |
debug.log("Getting response async %s", s); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
531 |
return s.getResponseAsync(null); |
48083 | 532 |
});} |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
533 |
); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
534 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
535 |
return MinimalFuture.completedFuture(resp); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
536 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
537 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
538 |
private URI getURIForSecurityCheck() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
539 |
URI u; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
540 |
String method = request.method(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
541 |
InetSocketAddress authority = request.authority(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
542 |
URI uri = request.uri(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
543 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
544 |
// CONNECT should be restricted at API level |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
545 |
if (method.equalsIgnoreCase("CONNECT")) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
546 |
try { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
547 |
u = new URI("socket", |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
548 |
null, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
549 |
authority.getHostString(), |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
550 |
authority.getPort(), |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
551 |
null, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
552 |
null, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
553 |
null); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
554 |
} catch (URISyntaxException e) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
555 |
throw new InternalError(e); // shouldn't happen |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
556 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
557 |
} else { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
558 |
u = uri; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
559 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
560 |
return u; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
561 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
562 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
563 |
/** |
48083 | 564 |
* Returns the security permission required for the given details. |
565 |
* If method is CONNECT, then uri must be of form "scheme://host:port" |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
566 |
*/ |
48083 | 567 |
private static URLPermission permissionForServer(URI uri, |
568 |
String method, |
|
569 |
Map<String, List<String>> headers) { |
|
570 |
if (method.equals("CONNECT")) { |
|
571 |
return new URLPermission(uri.toString(), "CONNECT"); |
|
572 |
} else { |
|
573 |
return Utils.permissionForServer(uri, method, headers.keySet().stream()); |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
/** |
|
578 |
* Performs the necessary security permission checks required to retrieve |
|
579 |
* the response. Returns a security exception representing the denied |
|
580 |
* permission, or null if all checks pass or there is no security manager. |
|
581 |
*/ |
|
582 |
private SecurityException checkPermissions() { |
|
583 |
String method = request.method(); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
584 |
SecurityManager sm = System.getSecurityManager(); |
48083 | 585 |
if (sm == null || method.equals("CONNECT")) { |
586 |
// tunneling will have a null acc, which is fine. The proxy |
|
587 |
// permission check will have already been preformed. |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
588 |
return null; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
589 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
590 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
591 |
HttpHeaders userHeaders = request.getUserHeaders(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
592 |
URI u = getURIForSecurityCheck(); |
48083 | 593 |
URLPermission p = permissionForServer(u, method, userHeaders.map()); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
594 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
595 |
try { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
596 |
assert acc != null; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
597 |
sm.checkPermission(p, acc); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
598 |
} catch (SecurityException e) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
599 |
return e; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
600 |
} |
52554
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
601 |
String hostHeader = userHeaders.firstValue("Host").orElse(null); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
602 |
if (hostHeader != null && !hostHeader.equalsIgnoreCase(u.getHost())) { |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
603 |
// user has set a Host header different to request URI |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
604 |
// must check that for URLPermission also |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
605 |
URI u1 = replaceHostInURI(u, hostHeader); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
606 |
URLPermission p1 = permissionForServer(u1, method, userHeaders.map()); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
607 |
try { |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
608 |
assert acc != null; |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
609 |
sm.checkPermission(p1, acc); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
610 |
} catch (SecurityException e) { |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
611 |
return e; |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
612 |
} |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
613 |
} |
48083 | 614 |
ProxySelector ps = client.proxySelector(); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
615 |
if (ps != null) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
616 |
if (!method.equals("CONNECT")) { |
48083 | 617 |
// a non-tunneling HTTP proxy. Need to check access |
618 |
URLPermission proxyPerm = permissionForProxy(request.proxy()); |
|
619 |
if (proxyPerm != null) { |
|
620 |
try { |
|
621 |
sm.checkPermission(proxyPerm, acc); |
|
622 |
} catch (SecurityException e) { |
|
623 |
return e; |
|
624 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
625 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
626 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
627 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
628 |
return null; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
629 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
630 |
|
52554
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
631 |
private static URI replaceHostInURI(URI u, String hostPort) { |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
632 |
StringBuilder sb = new StringBuilder(); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
633 |
sb.append(u.getScheme()) |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
634 |
.append("://") |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
635 |
.append(hostPort) |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
636 |
.append(u.getRawPath()); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
637 |
return URI.create(sb.toString()); |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
638 |
} |
5f1ca46703f9
8213189: Make restricted headers in HTTP Client configurable and remove Date by default
michaelm
parents:
51364
diff
changeset
|
639 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
640 |
HttpClient.Version version() { |
44854
5a486e0acd29
8175814: Update default HttpClient protocol version and optional request version
michaelm
parents:
44639
diff
changeset
|
641 |
return multi.version(); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
642 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
643 |
|
48083 | 644 |
String dbgString() { |
645 |
return dbgTag; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
646 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
647 |
} |