341 boolean async) |
341 boolean async) |
342 throws Exception |
342 throws Exception |
343 { |
343 { |
344 HttpClient client = null; |
344 HttpClient client = null; |
345 for (Where where : Where.values()) { |
345 for (Where where : Where.values()) { |
|
346 |
|
347 // Throwing on onSubscribe needs some more work |
|
348 // for the case of InputStream, where the body has already |
|
349 // completed by the time the subscriber is subscribed. |
|
350 // The only way we have at that point to relay the exception |
|
351 // is to call onError on the subscriber, but should we if |
|
352 // Subscriber::onSubscribed has thrown an exception and |
|
353 // not completed normally? |
346 if (where == Where.ON_SUBSCRIBE) continue; |
354 if (where == Where.ON_SUBSCRIBE) continue; |
|
355 |
|
356 // Don't know how to make the stack reliably cause onError |
|
357 // to be called without closing the connection. |
|
358 // And how do we get the exception if onError throws anyway? |
347 if (where == Where.ON_ERROR) continue; |
359 if (where == Where.ON_ERROR) continue; |
|
360 |
348 if (!sameClient || client == null) |
361 if (!sameClient || client == null) |
349 client = newHttpClient(sameClient); |
362 client = newHttpClient(sameClient); |
350 |
363 |
351 HttpRequest req = HttpRequest. |
364 HttpRequest req = HttpRequest. |
352 newBuilder(URI.create(uri)) |
365 newBuilder(URI.create(uri)) |