Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17612] Titanium Android: HTTPClient doesn't decompress gzipped data for error responses

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-01-07T19:26:40.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsdecompression, httpclient, module_network, parity, qe-manualtest, qe-testadded
ReporterStephen Woodford
AssigneeAshraf Abu
Created2014-09-03T18:43:36.000+0000
Updated2015-01-07T19:26:40.000+0000

Description

Gzipped data isn't decompressed if the response status code is >=400 (https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L273-L275) Whereas for response status codes <400, the response is properly decompressed. (https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L285)

Comments

  1. Stephen Woodford 2014-09-03

    Forgot to mention, iOS properly decompresses data in error responses, so this is a parity issue as well.
  2. Shannon Hicks 2014-10-03

    Took *FOREVER* to track this down. To hopefully help others with some google bait... The dump I get when I hit this bug:
       [ERROR] :  V8Exception: Exception occurred at undefined:1: Uncaught SyntaxError: Unexpected token 
       [ERROR] :  XMLModule: (KrollRuntimeThread) [19,11721] Error parsing XML
       ......
       [ERROR] :  TiHttpClient: 	at android.os.Looper.loop(Looper.java:136)
       [ERROR] :  TiHttpClient: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
       
    Also, the raw response:
  3. Fokke Zandbergen 2014-10-04

    I have the same issue. The bug seems to be introduced in 3.3.0 with the new HTTPClient.
  4. Shannon Hicks 2014-10-04

    I was able to reproduce the bug in 3.2.1 and 3.1.2.
  5. Nikolai Derzhak 2014-10-13

    [~iotashan] Can you please attach raw code and probably log as file ? That black diamonds with questions marks kills email notifications in JIRA too ) . So I had to remove them.
  6. Ashraf Abu 2015-01-05

    PR: https://github.com/appcelerator/titanium_mobile/pull/6530 Test App:
       var url = "https://api.stackexchange.com/2.2/answers?order=desc&sort=activity&site=stackoverflo2w";
        var client = Ti.Network.createHTTPClient({
            // function called when the response data is available
            onload : function(e) {
                Ti.API.info("Received text: " + this.responseText);
                alert('success');
                
            },
            // function called when an error occurs, including a timeout
            onerror : function(e) {
                Ti.API.debug(e.error);
                 alert('error ' + this.responseText);
       
            },
            timeout : 5000  // in milliseconds
        });
        // Prepare the connection.
        client.open("GET", url);
        // Send the request.
        client.send();
       
  7. Lokesh Choudhary 2015-01-07

    Verified the fix. The gzip data gets decompressed as expected. Closing. Environment: Appc Studio : 3.4.1.201410281743 Ti SDK : 3.6.0.v20150106160923 CLI : 3.4.1 Alloy : 1.5.1 GA Code Processor : 1.1.1 MAC Yosemite : 10.10

JSON Source