Skip to content

Commit

Permalink
fix for empty response with gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
SreeniIO committed Apr 11, 2020
1 parent 96c2e8f commit ce14fff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions unirest/src/main/java/kong/unirest/apache/ApacheResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public byte[] getContentAsBytes() {
}
try {
InputStream is = getContent();
if (isGzipped(getEncoding())) {
is = new GZIPInputStream(getContent());
byte[] bytes = getBytes(is);
if (bytes.length > 0 && isGzipped(getEncoding())) {
is = new GZIPInputStream(new ByteArrayInputStream(bytes));
return getBytes(is);
}
return getBytes(is);
return bytes;
} catch (IOException e2) {
throw new UnirestException(e2);
} finally {
Expand Down

0 comments on commit ce14fff

Please sign in to comment.