diff --git a/android/widgets/src/main/java/org/nativescript/widgets/Async.java b/android/widgets/src/main/java/org/nativescript/widgets/Async.java index 88c4a382a..8cac1b8ee 100644 --- a/android/widgets/src/main/java/org/nativescript/widgets/Async.java +++ b/android/widgets/src/main/java/org/nativescript/widgets/Async.java @@ -388,23 +388,10 @@ public class Async { int contentLength = connection.getContentLength(); - InputStream inStream; - if (this.statusCode >= 400) - { - inStream = connection.getErrorStream(); - } - else - { - inStream = connection.getInputStream(); - // In the event we don't have a null stream, and we have gzip as part of the encoding - // then we will use gzip to decode the stream - if (inStream != null) { - String encodingHeader = connection.getHeaderField("Content-Encoding"); - if (encodingHeader != null && encodingHeader.toLowerCase().contains("gzip")) { - inStream = new GZIPInputStream(inStream); - } - } - } + InputStream inStream = + this.statusCode >= 400 + ? connection.getErrorStream() + : connection.getInputStream(); if (inStream == null) { @@ -413,6 +400,13 @@ public class Async return; } + // In the event we don't have a null stream, and we have gzip as part of the encoding + // then we will use gzip to decode the stream + String encodingHeader = connection.getHeaderField("Content-Encoding"); + if (encodingHeader != null && encodingHeader.toLowerCase().contains("gzip")) { + inStream = new GZIPInputStream(inStream); + } + openedStreams.push(inStream); BufferedInputStream buffer = new BufferedInputStream(inStream, 4096);