Skip to content

Commit 282c3c5

Browse files
committed
Check if response body is available before using it.
1 parent 0ac1d2d commit 282c3c5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/org/tinystruct/net/handlers/HTTPHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public HTTPResponse(HttpResponse<InputStream> response) {
278278
this.headers = response.headers().map();
279279

280280
try (InputStream in = response.body()) {
281-
if (in != null) {
281+
if (in != null && in.available() > 0) {
282282
String contentEncoding = response.headers()
283283
.firstValue("Content-Encoding").orElse(null);
284284
InputStream decodedStream = getDecodedInputStream(contentEncoding, in);

0 commit comments

Comments
 (0)