Skip to content

Commit 3ec1be2

Browse files
omarickullfar
authored andcommitted
Add Javadoc regarding closing body stream
1 parent 03321f0 commit 3ec1be2

File tree

1 file changed

+9
-0
lines changed
  • scribejava-core/src/main/java/com/github/scribejava/core/model

1 file changed

+9
-0
lines changed

scribejava-core/src/main/java/com/github/scribejava/core/model/Response.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
import java.util.Map;
66
import com.github.scribejava.core.utils.StreamUtils;
77

8+
/**
9+
* An HTTP response.
10+
*
11+
* <p>This response may contain a non-null body stream of the HttpUrlConnection. If so, this body must be closed to
12+
* avoid leaking resources. Use either {@code getBody()} or {@code getStream().close()} to close the body.
13+
*/
814
public class Response {
915

1016
private final int code;
@@ -45,6 +51,9 @@ public boolean isSuccessful() {
4551
return code >= 200 && code < 400;
4652
}
4753

54+
/**
55+
* Returns the response body as a string, closing the stream that backs it. Idempotent.
56+
*/
4857
public String getBody() throws IOException {
4958
return body == null ? parseBodyContents() : body;
5059
}

0 commit comments

Comments
 (0)