author | chegar |
Wed, 06 Jun 2018 15:01:02 +0100 | |
branch | http-client-branch |
changeset 56682 | 9822bbe48b9b |
parent 56631 | 30b27fe75b0a |
child 56730 | b08918259eed |
permissions | -rw-r--r-- |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
1 |
/* |
49765 | 2 |
* Copyright (c) 2015, 2018, 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 |
|
48083 | 28 |
import java.io.EOFException; |
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.nio.ByteBuffer; |
49765 | 31 |
import java.util.List; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
32 |
import java.util.concurrent.CompletableFuture; |
48083 | 33 |
import java.util.concurrent.CompletionStage; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
34 |
import java.util.concurrent.Executor; |
49765 | 35 |
import java.util.concurrent.Flow; |
36 |
import java.util.concurrent.atomic.AtomicBoolean; |
|
37 |
import java.util.concurrent.atomic.AtomicLong; |
|
48083 | 38 |
import java.util.function.Consumer; |
39 |
import java.util.function.Function; |
|
49765 | 40 |
import java.net.http.HttpHeaders; |
41 |
import java.net.http.HttpResponse; |
|
42 |
import jdk.internal.net.http.ResponseContent.BodyParser; |
|
43 |
import jdk.internal.net.http.common.Log; |
|
44 |
import jdk.internal.net.http.common.Logger; |
|
45 |
import jdk.internal.net.http.common.MinimalFuture; |
|
46 |
import jdk.internal.net.http.common.Utils; |
|
47 |
import static java.net.http.HttpClient.Version.HTTP_1_1; |
|
48 |
import static java.net.http.HttpResponse.BodySubscribers.discarding; |
|
56682
9822bbe48b9b
http-client-branch: more descriptive HTTP/1.1 exception detail messages
chegar
parents:
56631
diff
changeset
|
49 |
import static jdk.internal.net.http.common.Utils.wrapWithExtraDetail; |
56631
30b27fe75b0a
http-client-branch: 8203433 (httpclient) Add tests for HEAD and 304 responses.
michaelm
parents:
56507
diff
changeset
|
50 |
import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
51 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
52 |
/** |
48083 | 53 |
* Handles a HTTP/1.1 response (headers + body). |
54 |
* There can be more than one of these per Http exchange. |
|
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 |
class Http1Response<T> { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
57 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
58 |
private volatile ResponseContent content; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
59 |
private final HttpRequestImpl request; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
60 |
private Response response; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
61 |
private final HttpConnection connection; |
48083 | 62 |
private HttpHeaders headers; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
63 |
private int responseCode; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
64 |
private final Http1Exchange<T> exchange; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
65 |
private boolean return2Cache; // return connection to cache when finished |
48083 | 66 |
private final HeadersReader headersReader; // used to read the headers |
67 |
private final BodyReader bodyReader; // used to read the body |
|
68 |
private final Http1AsyncReceiver asyncReceiver; |
|
69 |
private volatile EOFException eof; |
|
70 |
// max number of bytes of (fixed length) body to ignore on redirect |
|
71 |
private final static int MAX_IGNORE = 1024; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
72 |
|
48083 | 73 |
// Revisit: can we get rid of this? |
74 |
static enum State {INITIAL, READING_HEADERS, READING_BODY, DONE} |
|
75 |
private volatile State readProgress = State.INITIAL; |
|
76 |
||
49765 | 77 |
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG); |
78 |
final static AtomicLong responseCount = new AtomicLong(); |
|
79 |
final long id = responseCount.incrementAndGet(); |
|
48083 | 80 |
|
81 |
Http1Response(HttpConnection conn, |
|
82 |
Http1Exchange<T> exchange, |
|
83 |
Http1AsyncReceiver asyncReceiver) { |
|
84 |
this.readProgress = State.INITIAL; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
85 |
this.request = exchange.request(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
86 |
this.exchange = exchange; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
87 |
this.connection = conn; |
48083 | 88 |
this.asyncReceiver = asyncReceiver; |
89 |
headersReader = new HeadersReader(this::advance); |
|
90 |
bodyReader = new BodyReader(this::advance); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
91 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
92 |
|
49765 | 93 |
String dbgTag; |
94 |
private String dbgString() { |
|
95 |
String dbg = dbgTag; |
|
96 |
if (dbg == null) { |
|
97 |
String cdbg = connection.dbgTag; |
|
98 |
if (cdbg != null) { |
|
99 |
dbgTag = dbg = "Http1Response(id=" + id + ", " + cdbg + ")"; |
|
100 |
} else { |
|
101 |
dbg = "Http1Response(id=" + id + ")"; |
|
102 |
} |
|
103 |
} |
|
104 |
return dbg; |
|
105 |
} |
|
106 |
||
107 |
// The ClientRefCountTracker is used to track the state |
|
108 |
// of a pending operation. Altough there usually is a single |
|
109 |
// point where the operation starts, it may terminate at |
|
110 |
// different places. |
|
111 |
private final class ClientRefCountTracker { |
|
112 |
final HttpClientImpl client = connection.client(); |
|
113 |
// state & 0x01 != 0 => acquire called |
|
114 |
// state & 0x02 != 0 => tryRelease called |
|
115 |
byte state; |
|
116 |
||
117 |
public synchronized void acquire() { |
|
118 |
if (state == 0) { |
|
119 |
// increment the reference count on the HttpClientImpl |
|
120 |
// to prevent the SelectorManager thread from exiting |
|
121 |
// until our operation is complete. |
|
122 |
if (debug.on()) |
|
123 |
debug.log("Operation started: incrementing ref count for %s", client); |
|
124 |
client.reference(); |
|
125 |
state = 0x01; |
|
126 |
} else { |
|
127 |
if (debug.on()) |
|
128 |
debug.log("Operation ref count for %s is already %s", |
|
129 |
client, ((state & 0x2) == 0x2) ? "released." : "incremented!" ); |
|
130 |
assert (state & 0x01) == 0 : "reference count already incremented"; |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
public synchronized void tryRelease() { |
|
135 |
if (state == 0x01) { |
|
136 |
// decrement the reference count on the HttpClientImpl |
|
137 |
// to allow the SelectorManager thread to exit if no |
|
138 |
// other operation is pending and the facade is no |
|
139 |
// longer referenced. |
|
140 |
if (debug.on()) |
|
141 |
debug.log("Operation finished: decrementing ref count for %s", client); |
|
142 |
client.unreference(); |
|
143 |
} else if (state == 0) { |
|
144 |
if (debug.on()) |
|
145 |
debug.log("Operation finished: releasing ref count for %s", client); |
|
146 |
} else if ((state & 0x02) == 0x02) { |
|
147 |
if (debug.on()) |
|
148 |
debug.log("ref count for %s already released", client); |
|
149 |
} |
|
150 |
state |= 0x02; |
|
151 |
} |
|
152 |
} |
|
153 |
||
154 |
public CompletableFuture<Response> readHeadersAsync(Executor executor) { |
|
155 |
if (debug.on()) |
|
156 |
debug.log("Reading Headers: (remaining: " |
|
157 |
+ asyncReceiver.remaining() +") " + readProgress); |
|
48083 | 158 |
// with expect continue we will resume reading headers + body. |
159 |
asyncReceiver.unsubscribe(bodyReader); |
|
160 |
bodyReader.reset(); |
|
161 |
Http1HeaderParser hd = new Http1HeaderParser(); |
|
162 |
readProgress = State.READING_HEADERS; |
|
163 |
headersReader.start(hd); |
|
164 |
asyncReceiver.subscribe(headersReader); |
|
165 |
CompletableFuture<State> cf = headersReader.completion(); |
|
166 |
assert cf != null : "parsing not started"; |
|
167 |
||
168 |
Function<State, Response> lambda = (State completed) -> { |
|
169 |
assert completed == State.READING_HEADERS; |
|
49765 | 170 |
if (debug.on()) |
171 |
debug.log("Reading Headers: creating Response object;" |
|
172 |
+ " state is now " + readProgress); |
|
48083 | 173 |
asyncReceiver.unsubscribe(headersReader); |
174 |
responseCode = hd.responseCode(); |
|
175 |
headers = hd.headers(); |
|
176 |
||
177 |
response = new Response(request, |
|
178 |
exchange.getExchange(), |
|
179 |
headers, |
|
49765 | 180 |
connection, |
48083 | 181 |
responseCode, |
182 |
HTTP_1_1); |
|
49765 | 183 |
|
184 |
if (Log.headers()) { |
|
185 |
StringBuilder sb = new StringBuilder("RESPONSE HEADERS:\n"); |
|
186 |
Log.dumpHeaders(sb, " ", headers); |
|
187 |
Log.logHeaders(sb.toString()); |
|
188 |
} |
|
189 |
||
48083 | 190 |
return response; |
191 |
}; |
|
192 |
||
193 |
if (executor != null) { |
|
194 |
return cf.thenApplyAsync(lambda, executor); |
|
195 |
} else { |
|
196 |
return cf.thenApply(lambda); |
|
42460
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 |
} |
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 |
private boolean finished; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
201 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
202 |
synchronized void completed() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
203 |
finished = true; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
204 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
205 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
206 |
synchronized boolean finished() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
207 |
return finished; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
208 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
209 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
210 |
int fixupContentLen(int clen) { |
56631
30b27fe75b0a
http-client-branch: 8203433 (httpclient) Add tests for HEAD and 304 responses.
michaelm
parents:
56507
diff
changeset
|
211 |
if (request.method().equalsIgnoreCase("HEAD") || responseCode == HTTP_NOT_MODIFIED) { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
212 |
return 0; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
213 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
214 |
if (clen == -1) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
215 |
if (headers.firstValue("Transfer-encoding").orElse("") |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
216 |
.equalsIgnoreCase("chunked")) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
217 |
return -1; |
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 |
return 0; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
220 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
221 |
return clen; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
222 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
223 |
|
48083 | 224 |
/** |
225 |
* Read up to MAX_IGNORE bytes discarding |
|
226 |
*/ |
|
227 |
public CompletableFuture<Void> ignoreBody(Executor executor) { |
|
228 |
int clen = (int)headers.firstValueAsLong("Content-Length").orElse(-1); |
|
229 |
if (clen == -1 || clen > MAX_IGNORE) { |
|
230 |
connection.close(); |
|
231 |
return MinimalFuture.completedFuture(null); // not treating as error |
|
232 |
} else { |
|
49765 | 233 |
return readBody(discarding(), true, executor); |
234 |
} |
|
235 |
} |
|
236 |
||
237 |
static final Flow.Subscription NOP = new Flow.Subscription() { |
|
238 |
@Override |
|
239 |
public void request(long n) { } |
|
240 |
public void cancel() { } |
|
241 |
}; |
|
242 |
||
243 |
/** |
|
244 |
* The Http1AsyncReceiver ensures that all calls to |
|
245 |
* the subscriber, including onSubscribe, occur sequentially. |
|
246 |
* There could however be some race conditions that could happen |
|
247 |
* in case of unexpected errors thrown at unexpected places, which |
|
248 |
* may cause onError to be called multiple times. |
|
249 |
* The Http1BodySubscriber will ensure that the user subscriber |
|
250 |
* is actually completed only once - and only after it is |
|
251 |
* subscribed. |
|
252 |
* @param <U> The type of response. |
|
253 |
*/ |
|
254 |
final static class Http1BodySubscriber<U> implements HttpResponse.BodySubscriber<U> { |
|
255 |
final HttpResponse.BodySubscriber<U> userSubscriber; |
|
256 |
final AtomicBoolean completed = new AtomicBoolean(); |
|
257 |
volatile Throwable withError; |
|
258 |
volatile boolean subscribed; |
|
259 |
Http1BodySubscriber(HttpResponse.BodySubscriber<U> userSubscriber) { |
|
260 |
this.userSubscriber = userSubscriber; |
|
261 |
} |
|
262 |
||
263 |
// propagate the error to the user subscriber, even if not |
|
264 |
// subscribed yet. |
|
265 |
private void propagateError(Throwable t) { |
|
266 |
assert t != null; |
|
267 |
try { |
|
268 |
// if unsubscribed at this point, it will not |
|
269 |
// get subscribed later - so do it now and |
|
270 |
// propagate the error |
|
271 |
if (subscribed == false) { |
|
272 |
subscribed = true; |
|
273 |
userSubscriber.onSubscribe(NOP); |
|
274 |
} |
|
275 |
} finally { |
|
276 |
// if onError throws then there is nothing to do |
|
277 |
// here: let the caller deal with it by logging |
|
278 |
// and closing the connection. |
|
279 |
userSubscriber.onError(t); |
|
280 |
} |
|
281 |
} |
|
282 |
||
283 |
// complete the subscriber, either normally or exceptionally |
|
284 |
// ensure that the subscriber is completed only once. |
|
285 |
private void complete(Throwable t) { |
|
286 |
if (completed.compareAndSet(false, true)) { |
|
287 |
t = withError = Utils.getCompletionCause(t); |
|
288 |
if (t == null) { |
|
289 |
assert subscribed; |
|
290 |
try { |
|
291 |
userSubscriber.onComplete(); |
|
292 |
} catch (Throwable x) { |
|
293 |
propagateError(t = withError = Utils.getCompletionCause(x)); |
|
294 |
// rethrow and let the caller deal with it. |
|
295 |
// (i.e: log and close the connection) |
|
296 |
// arguably we could decide to not throw and let the |
|
297 |
// connection be reused since we should have received and |
|
298 |
// parsed all the bytes when we reach here. |
|
299 |
throw x; |
|
300 |
} |
|
301 |
} else { |
|
302 |
propagateError(t); |
|
303 |
} |
|
304 |
} |
|
305 |
} |
|
306 |
||
307 |
@Override |
|
308 |
public CompletionStage<U> getBody() { |
|
309 |
return userSubscriber.getBody(); |
|
310 |
} |
|
311 |
@Override |
|
312 |
public void onSubscribe(Flow.Subscription subscription) { |
|
313 |
if (!subscribed) { |
|
314 |
subscribed = true; |
|
315 |
userSubscriber.onSubscribe(subscription); |
|
316 |
} else { |
|
317 |
// could be already subscribed and completed |
|
318 |
// if an unexpected error occurred before the actual |
|
319 |
// subscription - though that's not supposed |
|
320 |
// happen. |
|
321 |
assert completed.get(); |
|
322 |
} |
|
323 |
} |
|
324 |
@Override |
|
325 |
public void onNext(List<ByteBuffer> item) { |
|
326 |
assert !completed.get(); |
|
327 |
userSubscriber.onNext(item); |
|
328 |
} |
|
329 |
@Override |
|
330 |
public void onError(Throwable throwable) { |
|
331 |
complete(throwable); |
|
332 |
} |
|
333 |
@Override |
|
334 |
public void onComplete() { |
|
335 |
complete(null); |
|
48083 | 336 |
} |
42460
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 |
|
48083 | 339 |
public <U> CompletableFuture<U> readBody(HttpResponse.BodySubscriber<U> p, |
340 |
boolean return2Cache, |
|
341 |
Executor executor) { |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
342 |
this.return2Cache = return2Cache; |
49765 | 343 |
final Http1BodySubscriber<U> subscriber = new Http1BodySubscriber<>(p); |
344 |
||
345 |
final CompletableFuture<U> cf = new MinimalFuture<>(); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
346 |
|
48083 | 347 |
int clen0 = (int)headers.firstValueAsLong("Content-Length").orElse(-1); |
348 |
||
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
349 |
final int clen = fixupContentLen(clen0); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
350 |
|
48083 | 351 |
// expect-continue reads headers and body twice. |
352 |
// if we reach here, we must reset the headersReader state. |
|
353 |
asyncReceiver.unsubscribe(headersReader); |
|
354 |
headersReader.reset(); |
|
49765 | 355 |
ClientRefCountTracker refCountTracker = new ClientRefCountTracker(); |
48083 | 356 |
|
49765 | 357 |
// We need to keep hold on the client facade until the |
358 |
// tracker has been incremented. |
|
359 |
connection.client().reference(); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
360 |
executor.execute(() -> { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
361 |
try { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
362 |
content = new ResponseContent( |
49765 | 363 |
connection, clen, headers, subscriber, |
48083 | 364 |
this::onFinished |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
365 |
); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
366 |
if (cf.isCompletedExceptionally()) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
367 |
// if an error occurs during subscription |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
368 |
connection.close(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
369 |
return; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
370 |
} |
48083 | 371 |
// increment the reference count on the HttpClientImpl |
372 |
// to prevent the SelectorManager thread from exiting until |
|
373 |
// the body is fully read. |
|
49765 | 374 |
refCountTracker.acquire(); |
48083 | 375 |
bodyReader.start(content.getBodyParser( |
376 |
(t) -> { |
|
377 |
try { |
|
378 |
if (t != null) { |
|
49944 | 379 |
try { |
380 |
subscriber.onError(t); |
|
381 |
} finally { |
|
382 |
cf.completeExceptionally(t); |
|
383 |
} |
|
48083 | 384 |
} |
385 |
} finally { |
|
386 |
bodyReader.onComplete(t); |
|
49944 | 387 |
if (t != null) { |
388 |
connection.close(); |
|
389 |
} |
|
48083 | 390 |
} |
391 |
})); |
|
392 |
CompletableFuture<State> bodyReaderCF = bodyReader.completion(); |
|
393 |
asyncReceiver.subscribe(bodyReader); |
|
394 |
assert bodyReaderCF != null : "parsing not started"; |
|
395 |
// Make sure to keep a reference to asyncReceiver from |
|
396 |
// within this |
|
397 |
CompletableFuture<?> trailingOp = bodyReaderCF.whenComplete((s,t) -> { |
|
398 |
t = Utils.getCompletionCause(t); |
|
399 |
try { |
|
49765 | 400 |
if (t == null) { |
401 |
if (debug.on()) debug.log("Finished reading body: " + s); |
|
48083 | 402 |
assert s == State.READING_BODY; |
403 |
} |
|
49765 | 404 |
if (t != null) { |
405 |
subscriber.onError(t); |
|
48083 | 406 |
cf.completeExceptionally(t); |
407 |
} |
|
408 |
} catch (Throwable x) { |
|
409 |
// not supposed to happen |
|
410 |
asyncReceiver.onReadError(x); |
|
49765 | 411 |
} finally { |
412 |
// we're done: release the ref count for |
|
413 |
// the current operation. |
|
414 |
refCountTracker.tryRelease(); |
|
48083 | 415 |
} |
416 |
}); |
|
417 |
connection.addTrailingOperation(trailingOp); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
418 |
} catch (Throwable t) { |
49765 | 419 |
if (debug.on()) debug.log("Failed reading body: " + t); |
48083 | 420 |
try { |
49765 | 421 |
subscriber.onError(t); |
422 |
cf.completeExceptionally(t); |
|
48083 | 423 |
} finally { |
424 |
asyncReceiver.onReadError(t); |
|
425 |
} |
|
49765 | 426 |
} finally { |
427 |
connection.client().unreference(); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
428 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
429 |
}); |
49765 | 430 |
try { |
431 |
p.getBody().whenComplete((U u, Throwable t) -> { |
|
432 |
if (t == null) |
|
433 |
cf.complete(u); |
|
434 |
else |
|
435 |
cf.completeExceptionally(t); |
|
436 |
}); |
|
437 |
} catch (Throwable t) { |
|
438 |
cf.completeExceptionally(t); |
|
439 |
asyncReceiver.setRetryOnError(false); |
|
440 |
asyncReceiver.onReadError(t); |
|
441 |
} |
|
442 |
||
443 |
return cf.whenComplete((s,t) -> { |
|
444 |
if (t != null) { |
|
445 |
// If an exception occurred, release the |
|
446 |
// ref count for the current operation, as |
|
447 |
// it may never be triggered otherwise |
|
448 |
// (BodySubscriber ofInputStream) |
|
449 |
// If there was no exception then the |
|
450 |
// ref count will be/have been released when |
|
451 |
// the last byte of the response is/was received |
|
452 |
refCountTracker.tryRelease(); |
|
453 |
} |
|
454 |
}); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
455 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
456 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
457 |
|
48083 | 458 |
private void onFinished() { |
459 |
asyncReceiver.clear(); |
|
460 |
if (return2Cache) { |
|
461 |
Log.logTrace("Attempting to return connection to the pool: {0}", connection); |
|
462 |
// TODO: need to do something here? |
|
463 |
// connection.setAsyncCallbacks(null, null, null); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
464 |
|
48083 | 465 |
// don't return the connection to the cache if EOF happened. |
49765 | 466 |
if (debug.on()) |
467 |
debug.log(connection.getConnectionFlow() + ": return to HTTP/1.1 pool"); |
|
48083 | 468 |
connection.closeOrReturnToCache(eof == null ? headers : null); |
469 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
470 |
} |
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 |
HttpHeaders responseHeaders() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
473 |
return headers; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
474 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
475 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
476 |
int responseCode() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
477 |
return responseCode; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
478 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
479 |
|
48083 | 480 |
// ================ Support for plugging into Http1Receiver ================= |
481 |
// ============================================================================ |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
482 |
|
48083 | 483 |
// Callback: Error receiver: Consumer of Throwable. |
484 |
void onReadError(Throwable t) { |
|
485 |
Log.logError(t); |
|
486 |
Receiver<?> receiver = receiver(readProgress); |
|
487 |
if (t instanceof EOFException) { |
|
488 |
debug.log(Level.DEBUG, "onReadError: received EOF"); |
|
489 |
eof = (EOFException) t; |
|
490 |
} |
|
491 |
CompletableFuture<?> cf = receiver == null ? null : receiver.completion(); |
|
492 |
debug.log(Level.DEBUG, () -> "onReadError: cf is " |
|
493 |
+ (cf == null ? "null" |
|
494 |
: (cf.isDone() ? "already completed" |
|
495 |
: "not yet completed"))); |
|
49765 | 496 |
if (cf != null) { |
497 |
cf.completeExceptionally(t); |
|
498 |
} else { |
|
499 |
debug.log(Level.DEBUG, "onReadError", t); |
|
500 |
} |
|
48083 | 501 |
debug.log(Level.DEBUG, () -> "closing connection: cause is " + t); |
502 |
connection.close(); |
|
503 |
} |
|
504 |
||
505 |
// ======================================================================== |
|
506 |
||
507 |
private State advance(State previous) { |
|
508 |
assert readProgress == previous; |
|
509 |
switch(previous) { |
|
510 |
case READING_HEADERS: |
|
511 |
asyncReceiver.unsubscribe(headersReader); |
|
512 |
return readProgress = State.READING_BODY; |
|
513 |
case READING_BODY: |
|
514 |
asyncReceiver.unsubscribe(bodyReader); |
|
515 |
return readProgress = State.DONE; |
|
516 |
default: |
|
517 |
throw new InternalError("can't advance from " + previous); |
|
518 |
} |
|
519 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
520 |
|
48083 | 521 |
Receiver<?> receiver(State state) { |
522 |
switch(state) { |
|
523 |
case READING_HEADERS: return headersReader; |
|
524 |
case READING_BODY: return bodyReader; |
|
525 |
default: return null; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
526 |
} |
48083 | 527 |
|
528 |
} |
|
529 |
||
530 |
static abstract class Receiver<T> |
|
531 |
implements Http1AsyncReceiver.Http1AsyncDelegate { |
|
532 |
abstract void start(T parser); |
|
533 |
abstract CompletableFuture<State> completion(); |
|
534 |
// accepts a buffer from upstream. |
|
535 |
// this should be implemented as a simple call to |
|
536 |
// accept(ref, parser, cf) |
|
537 |
public abstract boolean tryAsyncReceive(ByteBuffer buffer); |
|
538 |
public abstract void onReadError(Throwable t); |
|
539 |
// handle a byte buffer received from upstream. |
|
540 |
// this method should set the value of Http1Response.buffer |
|
541 |
// to ref.get() before beginning parsing. |
|
542 |
abstract void handle(ByteBuffer buf, T parser, |
|
543 |
CompletableFuture<State> cf); |
|
544 |
// resets this objects state so that it can be reused later on |
|
545 |
// typically puts the reference to parser and completion to null |
|
546 |
abstract void reset(); |
|
547 |
||
548 |
// accepts a byte buffer received from upstream |
|
549 |
// returns true if the buffer is fully parsed and more data can |
|
550 |
// be accepted, false otherwise. |
|
551 |
final boolean accept(ByteBuffer buf, T parser, |
|
552 |
CompletableFuture<State> cf) { |
|
553 |
if (cf == null || parser == null || cf.isDone()) return false; |
|
554 |
handle(buf, parser, cf); |
|
555 |
return !cf.isDone(); |
|
556 |
} |
|
557 |
public abstract void onSubscribe(AbstractSubscription s); |
|
558 |
public abstract AbstractSubscription subscription(); |
|
559 |
||
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
560 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
561 |
|
48083 | 562 |
// Invoked with each new ByteBuffer when reading headers... |
563 |
final class HeadersReader extends Receiver<Http1HeaderParser> { |
|
564 |
final Consumer<State> onComplete; |
|
565 |
volatile Http1HeaderParser parser; |
|
566 |
volatile CompletableFuture<State> cf; |
|
567 |
volatile long count; // bytes parsed (for debug) |
|
568 |
volatile AbstractSubscription subscription; |
|
569 |
||
570 |
HeadersReader(Consumer<State> onComplete) { |
|
571 |
this.onComplete = onComplete; |
|
572 |
} |
|
573 |
||
574 |
@Override |
|
575 |
public AbstractSubscription subscription() { |
|
576 |
return subscription; |
|
577 |
} |
|
578 |
||
579 |
@Override |
|
580 |
public void onSubscribe(AbstractSubscription s) { |
|
581 |
this.subscription = s; |
|
582 |
s.request(1); |
|
583 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
584 |
|
48083 | 585 |
@Override |
586 |
void reset() { |
|
587 |
cf = null; |
|
588 |
parser = null; |
|
589 |
count = 0; |
|
590 |
subscription = null; |
|
591 |
} |
|
592 |
||
593 |
// Revisit: do we need to support restarting? |
|
594 |
@Override |
|
595 |
final void start(Http1HeaderParser hp) { |
|
596 |
count = 0; |
|
597 |
cf = new MinimalFuture<>(); |
|
598 |
parser = hp; |
|
599 |
} |
|
600 |
||
601 |
@Override |
|
602 |
CompletableFuture<State> completion() { |
|
603 |
return cf; |
|
604 |
} |
|
605 |
||
606 |
@Override |
|
607 |
public final boolean tryAsyncReceive(ByteBuffer ref) { |
|
608 |
boolean hasDemand = subscription.demand().tryDecrement(); |
|
609 |
assert hasDemand; |
|
610 |
boolean needsMore = accept(ref, parser, cf); |
|
611 |
if (needsMore) subscription.request(1); |
|
612 |
return needsMore; |
|
613 |
} |
|
614 |
||
615 |
@Override |
|
616 |
public final void onReadError(Throwable t) { |
|
56682
9822bbe48b9b
http-client-branch: more descriptive HTTP/1.1 exception detail messages
chegar
parents:
56631
diff
changeset
|
617 |
t = wrapWithExtraDetail(t, parser::currentStateMessage); |
48083 | 618 |
Http1Response.this.onReadError(t); |
619 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
620 |
|
48083 | 621 |
@Override |
622 |
final void handle(ByteBuffer b, |
|
623 |
Http1HeaderParser parser, |
|
624 |
CompletableFuture<State> cf) { |
|
625 |
assert cf != null : "parsing not started"; |
|
626 |
assert parser != null : "no parser"; |
|
627 |
try { |
|
628 |
count += b.remaining(); |
|
49765 | 629 |
if (debug.on()) |
630 |
debug.log("Sending " + b.remaining() + "/" + b.capacity() |
|
631 |
+ " bytes to header parser"); |
|
48083 | 632 |
if (parser.parse(b)) { |
633 |
count -= b.remaining(); |
|
49765 | 634 |
if (debug.on()) |
635 |
debug.log("Parsing headers completed. bytes=" + count); |
|
48083 | 636 |
onComplete.accept(State.READING_HEADERS); |
637 |
cf.complete(State.READING_HEADERS); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
638 |
} |
48083 | 639 |
} catch (Throwable t) { |
49765 | 640 |
if (debug.on()) |
641 |
debug.log("Header parser failed to handle buffer: " + t); |
|
48083 | 642 |
cf.completeExceptionally(t); |
643 |
} |
|
644 |
} |
|
49765 | 645 |
|
646 |
@Override |
|
647 |
public void close(Throwable error) { |
|
648 |
// if there's no error nothing to do: the cf should/will |
|
649 |
// be completed. |
|
650 |
if (error != null) { |
|
651 |
CompletableFuture<State> cf = this.cf; |
|
652 |
if (cf != null) { |
|
653 |
if (debug.on()) |
|
654 |
debug.log("close: completing header parser CF with " + error); |
|
655 |
cf.completeExceptionally(error); |
|
656 |
} |
|
657 |
} |
|
658 |
} |
|
48083 | 659 |
} |
660 |
||
661 |
// Invoked with each new ByteBuffer when reading bodies... |
|
662 |
final class BodyReader extends Receiver<BodyParser> { |
|
663 |
final Consumer<State> onComplete; |
|
664 |
volatile BodyParser parser; |
|
665 |
volatile CompletableFuture<State> cf; |
|
666 |
volatile AbstractSubscription subscription; |
|
667 |
BodyReader(Consumer<State> onComplete) { |
|
668 |
this.onComplete = onComplete; |
|
669 |
} |
|
670 |
||
671 |
@Override |
|
672 |
void reset() { |
|
673 |
parser = null; |
|
674 |
cf = null; |
|
675 |
subscription = null; |
|
676 |
} |
|
677 |
||
678 |
// Revisit: do we need to support restarting? |
|
679 |
@Override |
|
680 |
final void start(BodyParser parser) { |
|
681 |
cf = new MinimalFuture<>(); |
|
682 |
this.parser = parser; |
|
683 |
} |
|
684 |
||
685 |
@Override |
|
686 |
CompletableFuture<State> completion() { |
|
687 |
return cf; |
|
688 |
} |
|
689 |
||
690 |
@Override |
|
691 |
public final boolean tryAsyncReceive(ByteBuffer b) { |
|
692 |
return accept(b, parser, cf); |
|
693 |
} |
|
694 |
||
695 |
@Override |
|
696 |
public final void onReadError(Throwable t) { |
|
56682
9822bbe48b9b
http-client-branch: more descriptive HTTP/1.1 exception detail messages
chegar
parents:
56631
diff
changeset
|
697 |
t = wrapWithExtraDetail(t, parser::currentStateMessage); |
48083 | 698 |
Http1Response.this.onReadError(t); |
699 |
} |
|
700 |
||
701 |
@Override |
|
702 |
public AbstractSubscription subscription() { |
|
703 |
return subscription; |
|
704 |
} |
|
705 |
||
706 |
@Override |
|
707 |
public void onSubscribe(AbstractSubscription s) { |
|
708 |
this.subscription = s; |
|
49765 | 709 |
try { |
710 |
parser.onSubscribe(s); |
|
711 |
} catch (Throwable t) { |
|
712 |
cf.completeExceptionally(t); |
|
713 |
throw t; |
|
714 |
} |
|
48083 | 715 |
} |
716 |
||
717 |
@Override |
|
718 |
final void handle(ByteBuffer b, |
|
719 |
BodyParser parser, |
|
720 |
CompletableFuture<State> cf) { |
|
721 |
assert cf != null : "parsing not started"; |
|
722 |
assert parser != null : "no parser"; |
|
723 |
try { |
|
49765 | 724 |
if (debug.on()) |
725 |
debug.log("Sending " + b.remaining() + "/" + b.capacity() |
|
726 |
+ " bytes to body parser"); |
|
48083 | 727 |
parser.accept(b); |
728 |
} catch (Throwable t) { |
|
49765 | 729 |
if (debug.on()) |
730 |
debug.log("Body parser failed to handle buffer: " + t); |
|
48083 | 731 |
if (!cf.isDone()) { |
732 |
cf.completeExceptionally(t); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
733 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
734 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
735 |
} |
48083 | 736 |
|
737 |
final void onComplete(Throwable closedExceptionally) { |
|
738 |
if (cf.isDone()) return; |
|
739 |
if (closedExceptionally != null) { |
|
740 |
cf.completeExceptionally(closedExceptionally); |
|
741 |
} else { |
|
742 |
onComplete.accept(State.READING_BODY); |
|
743 |
cf.complete(State.READING_BODY); |
|
744 |
} |
|
745 |
} |
|
746 |
||
747 |
@Override |
|
49765 | 748 |
public final void close(Throwable error) { |
749 |
CompletableFuture<State> cf = this.cf; |
|
750 |
if (cf != null && !cf.isDone()) { |
|
751 |
// we want to make sure dependent actions are triggered |
|
752 |
// in order to make sure the client reference count |
|
753 |
// is decremented |
|
754 |
if (error != null) { |
|
755 |
if (debug.on()) |
|
756 |
debug.log("close: completing body parser CF with " + error); |
|
757 |
cf.completeExceptionally(error); |
|
758 |
} else { |
|
759 |
if (debug.on()) |
|
760 |
debug.log("close: completing body parser CF"); |
|
761 |
cf.complete(State.READING_BODY); |
|
762 |
} |
|
763 |
} |
|
764 |
} |
|
765 |
||
766 |
@Override |
|
48083 | 767 |
public String toString() { |
768 |
return super.toString() + "/parser=" + String.valueOf(parser); |
|
769 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
770 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
771 |
} |