okio.BufferedSink



API Populatity

5 Client projects

Project: okio

Project square/okhttp in file .../okhttp.src.main.java.com.squareup.okhttp.Job.java (2014-02-23)
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.net.ProtocolException;
 import java.net.Proxy;
 import java.net.URL;
+import okio.BufferedSink;
 import okio.Okio;
 import okio.Source;
 
@@ -125,7 +126,9 @@ final class Job extends NamedRunnable {
         engine.sendRequest();
 
         if (body != null) {
-          body.writeTo(engine.getRequestBody());
+          BufferedSink sink = Okio.buffer(engine.getRequestBody());
+          body.writeTo(sink);
+          sink.flush();
         }
 
         engine.readResponse();
Project square/okhttp in file ...m.squareup.okhttp.internal.http.RetryableSink.java (2014-11-10)
@@ -19,7 +19,6 @@ package com.squareup.okhttp.internal.http;
 import java.io.IOException;
 import java.net.ProtocolException;
 import okio.Buffer;
-import okio.BufferedSink;
 import okio.Sink;
 import okio.Timeout;
 
@@ -72,8 +71,9 @@ public final class RetryableSink implements Sink {
     return content.size();
   }
 
-  public void writeToSocket(BufferedSink socketOut) throws IOException {
+  public void writeToSocket(Sink socketOut) throws IOException {
     // Clone the content; otherwise we won't have data to retry.
-    socketOut.writeAll(content.clone());
+    Buffer buffer = content.clone();
+    socketOut.write(buffer, buffer.size());
   }
 }
Project square/okhttp in file ...m.squareup.okhttp.mockwebserver.MockWebServer.java (2014-02-23)
@@ -62,6 +62,7 @@ import javax.net.ssl.SSLSocket;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
+import okio.BufferedSink;
 import okio.ByteString;
 import okio.Okio;
 
@@ -703,8 +704,9 @@ public final class MockWebServer {
             throw new AssertionError(e);
           }
         }
-        stream.getOutputStream().write(body);
-        stream.getOutputStream().close();
+        BufferedSink sink = Okio.buffer(stream.getSink());
+        sink.write(body);
+        sink.close();
       }
     }
   }