public static boolean hasBody(Response response) { if (!response.request().method().equals("HEAD")) { int j = response.code(); if ((j < 100 || j >= 200) && j != 204 && j != 304) { return true; } if (OkHeaders.contentLength(response) != -1L || "chunked".equalsIgnoreCase(response.header("Transfer-Encoding"))) { return true; } } return false; }
private Source getTransferStream(Response response) throws IOException { if (!HttpEngine.hasBody(response)) { return httpConnection.newFixedLengthSource(0); } if ("chunked".equalsIgnoreCase(response.header("Transfer-Encoding"))) { return httpConnection.newChunkedSource(httpEngine); } long contentLength = OkHeaders.contentLength(response); if (contentLength != -1) { return httpConnection.newFixedLengthSource(contentLength); } // Wrap the input stream from the connection (rather than just returning // "socketIn" directly here), so that we can control its use after the // reference escapes. return httpConnection.newUnknownLengthSource(); }