Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion okhttp/src/main/java/okhttp3/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,17 @@ public long receivedResponseAtMillis() {
return receivedResponseAtMillis;
}

/** Closes the response body. Equivalent to {@code body().close()}. */
/**
* Closes the response body. Equivalent to {@code body().close()}.
*
* <p>It is an error to close a response that is not eligible for a body. This includes the
* responses returned from {@link #cacheResponse}, {@link #networkResponse}, and {@link
* #priorResponse()}.
*/
@Override public void close() {
if (body == null) {
throw new IllegalStateException("response is not eligible for a body and must not be closed");
}
body.close();
}

Expand Down
6 changes: 6 additions & 0 deletions okhttp/src/main/java/okhttp3/WebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public interface WebSocket {
void cancel();

interface Factory {
/**
* Creates a new web socket and immediately returns it. Creating a web socket initiates an
* asynchronous process to connect the socket. Once that succeeds or fails, {@code listener}
* will be notified. The caller must either close or cancel the returned web socket when it is
* no longer in use.
*/
WebSocket newWebSocket(Request request, WebSocketListener listener);
}
}