Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ebcda8e

Browse filesBrowse files
reinaldorauchmanoldonev
authored andcommitted
fix: add support for gzipped content in http error stream (#134)
When the HTTP server responded with an error (statusCode >= 400), the readResponseStream didn't decode the inStream as gzip even if the request sended had the Content-Encoding header. My fix moves the code that parses Content-Encoded header and decodes gzipped body out the test to get the input stream to the point where we are certain that we have a inStream that we can decode.
1 parent 6211db3 commit ebcda8e
Copy full SHA for ebcda8e

File tree

Expand file treeCollapse file tree

1 file changed

+11
-17
lines changed
Filter options
  • android/widgets/src/main/java/org/nativescript/widgets
Expand file treeCollapse file tree

1 file changed

+11
-17
lines changed

‎android/widgets/src/main/java/org/nativescript/widgets/Async.java

Copy file name to clipboardExpand all lines: android/widgets/src/main/java/org/nativescript/widgets/Async.java
+11-17Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -388,23 +388,10 @@ public void readResponseStream(HttpURLConnection connection, Stack<Closeable> op
388388
{
389389
int contentLength = connection.getContentLength();
390390

391-
InputStream inStream;
392-
if (this.statusCode >= 400)
393-
{
394-
inStream = connection.getErrorStream();
395-
}
396-
else
397-
{
398-
inStream = connection.getInputStream();
399-
// In the event we don't have a null stream, and we have gzip as part of the encoding
400-
// then we will use gzip to decode the stream
401-
if (inStream != null) {
402-
String encodingHeader = connection.getHeaderField("Content-Encoding");
403-
if (encodingHeader != null && encodingHeader.toLowerCase().contains("gzip")) {
404-
inStream = new GZIPInputStream(inStream);
405-
}
406-
}
407-
}
391+
InputStream inStream =
392+
this.statusCode >= 400
393+
? connection.getErrorStream()
394+
: connection.getInputStream();
408395

409396
if (inStream == null)
410397
{
@@ -413,6 +400,13 @@ public void readResponseStream(HttpURLConnection connection, Stack<Closeable> op
413400
return;
414401
}
415402

403+
// In the event we don't have a null stream, and we have gzip as part of the encoding
404+
// then we will use gzip to decode the stream
405+
String encodingHeader = connection.getHeaderField("Content-Encoding");
406+
if (encodingHeader != null && encodingHeader.toLowerCase().contains("gzip")) {
407+
inStream = new GZIPInputStream(inStream);
408+
}
409+
416410
openedStreams.push(inStream);
417411

418412
BufferedInputStream buffer = new BufferedInputStream(inStream, 4096);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.