aboutsummaryrefslogtreecommitdiffstats
path: root/okcurl/src
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2015-04-13 13:06:22 +0100
committerNeil Fuller <nfuller@google.com>2015-04-16 11:44:31 +0100
commita2cab72aa5ff730ba2ae987b45398faafffeb505 (patch)
tree283de306182e8f1faff93d4e6515298539d8c21d /okcurl/src
parent9fa0698523b8a573b8862c0e62c533be8bd53bda (diff)
downloadplatform_external_okhttp-a2cab72aa5ff730ba2ae987b45398faafffeb505.tar.gz
platform_external_okhttp-a2cab72aa5ff730ba2ae987b45398faafffeb505.tar.bz2
platform_external_okhttp-a2cab72aa5ff730ba2ae987b45398faafffeb505.zip
Roll-up of upstream OkHttp and Okio changes
OkHttp: From b609edd07864d7191dcda8ba1f6c833c9fe170ad to b40f99a950cb407eff52537a97420bd253a64f63 Okio: From 654ddf5e8f6311fda77e429c22d5e0e15f713b8d to b5811711b141b230e4e58f577c79cfbf4c2d4028 Both "to" are head as of 20150413. Patches applied cleanly without conflicts. This submission will break some CTS tests due to https://github.com/square/okhttp/issues/1552 Solutions will be made upstream and patched in. The CTS tests broken are related to SPDY/HTTP2 which are not used by Android's embedded OkHttp. Change-Id: I84d55b6f5c8dbc05148e86bd9421a2c393b563d4
Diffstat (limited to 'okcurl/src')
-rw-r--r--okcurl/src/main/java/com/squareup/okhttp/curl/Main.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/okcurl/src/main/java/com/squareup/okhttp/curl/Main.java b/okcurl/src/main/java/com/squareup/okhttp/curl/Main.java
index e1054c9..c6a85e1 100644
--- a/okcurl/src/main/java/com/squareup/okhttp/curl/Main.java
+++ b/okcurl/src/main/java/com/squareup/okhttp/curl/Main.java
@@ -25,7 +25,7 @@ import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.internal.http.StatusLine;
-import com.squareup.okhttp.internal.spdy.Http20Draft16;
+import com.squareup.okhttp.internal.spdy.Http2;
import io.airlift.command.Arguments;
import io.airlift.command.Command;
@@ -49,7 +49,9 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
+import okio.BufferedSource;
import okio.Okio;
+import okio.Sink;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -151,9 +153,15 @@ public class Main extends HelpOption implements Runnable {
System.out.println();
}
- response.body().source().readAll(Okio.sink(System.out));
+ // Stream the response to the System.out as it is returned from the server.
+ Sink out = Okio.sink(System.out);
+ BufferedSource source = response.body().source();
+ while (!source.exhausted()) {
+ out.write(source.buffer(), source.buffer().size());
+ out.flush();
+ }
+
response.body().close();
- System.out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
@@ -266,7 +274,7 @@ public class Main extends HelpOption implements Runnable {
}
private static void enableHttp2FrameLogging() {
- Logger logger = Logger.getLogger(Http20Draft16.class.getName() + "$FrameLogger");
+ Logger logger = Logger.getLogger(Http2.class.getName() + "$FrameLogger");
logger.setLevel(Level.FINE);
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.FINE);