@Override public void close() throws IOException { if (closed) return; if (!inputExhausted && cacheBody != null) { discardStream(); // Could make inputExhausted true! } closed = true; if (!inputExhausted) { stream.closeLater(ErrorCode.CANCEL); if (cacheRequest != null) { cacheRequest.abort(); } } }
@Override public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut, InputStream responseBodyIn) { if (streamCanceled) { if (stream != null) { stream.closeLater(ErrorCode.CANCEL); return true; } else { // If stream is null, it either means that writeRequestHeaders wasn't called // or that SpdyConnection#newStream threw an IOException. In both cases there's // nothing to do here and this stream can't be reused. return false; } } return true; }