Skip to content

Commit ce14fff

Browse files
committed
fix for empty response with gzip
1 parent 96c2e8f commit ce14fff

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

unirest/src/main/java/kong/unirest/apache/ApacheResponse.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ public byte[] getContentAsBytes() {
8181
}
8282
try {
8383
InputStream is = getContent();
84-
if (isGzipped(getEncoding())) {
85-
is = new GZIPInputStream(getContent());
84+
byte[] bytes = getBytes(is);
85+
if (bytes.length > 0 && isGzipped(getEncoding())) {
86+
is = new GZIPInputStream(new ByteArrayInputStream(bytes));
87+
return getBytes(is);
8688
}
87-
return getBytes(is);
89+
return bytes;
8890
} catch (IOException e2) {
8991
throw new UnirestException(e2);
9092
} finally {

0 commit comments

Comments
 (0)