@Override void writeBody(final BufferedSource in, final BufferedSink out) throws IOException { try { final ResponseBody data = body(); if (data != null) { final long length = data.contentLength(); if (length > 0) { out.write(data.source(), data.contentLength()); out.flush(); } else if (length < 0) { final Buffer buffer = new Buffer(); final long step = 65536; long read; while ((read = data.source().read(buffer, step)) > -1) { buffer.flush(); out.write(buffer, read); out.flush(); } } } } finally { // try { in.close(); } catch (final IOException ignore) {} // try { out.close(); } catch (final IOException ignore) {} // try { socket.close(); } catch (final IOException ignore) {} } }