Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20247] Regression in android HTTPClient

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-05-10T21:31:15.000+0000
Affected Version/sRelease 5.1.2
Fix Version/sRelease 6.1.0
Componentsn/a
Labelsmerge-6.1.0
ReporterSzymon Tomasz Stefanek
AssigneeJoshua Quick
Created2016-01-13T01:24:55.000+0000
Updated2017-05-12T21:27:06.000+0000

Description

https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java Line 160: setReadyState(READY_STATE_HEADERS_RECEIVED) is called before the headers are actually set. Calling getResponseHeader() will result in an attempt to invoke the isEmpty() method on null responseHeaders member.

Comments

  1. Sharif AbuDarda 2016-01-14

  2. Szymon Tomasz Stefanek 2016-01-14

    Just try to call getResponseHeaders() inside the onreadystatechange handler (when state is READY_STATE_HEADERS_RECEIVED or READY_STATE_LOADING).
  3. Szymon Tomasz Stefanek 2016-01-14

    Btw, it won't return null: it will trigger an exception at java level.
  4. Sharif AbuDarda 2016-01-14

    Hello [~s.stefanek], I am trying the below code in Android 5.1.0 with SDK 5.1.2.GA. Check if it's right.
       var xhr = Titanium.Network.createHTTPClient();
       
       xhr.onreadystatechange = function() {
           if (3 == xhr.readyState) {
               console.log(xhr.getResponseHeader('Last-Modified'));
           }
       
       };
       
       xhr.open('GET', 'http://www.appcelerator.com/assets/The_iPad_App_Wave.pdf');
       
       xhr.send();
       
       [ERROR] :  TiApplication: (main) [21,128] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.PushBroadcastReceiver: java.lang.NullPointerException: PushType is NONE!; Titanium 5.1.2,2015/12/16 19:00,ca822b2
       [ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.PushBroadcastReceiver: java.lang.NullPointerException: PushType is NONE!
       
    Thanks.
  5. Yordan Banev 2017-04-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/8997
  6. Eric Merriman 2017-04-27

    [~ybanev] The PR is for Master. Currently master is 6.2.0, so we need a PR for 6.1.0.
  7. Yordan Banev 2017-04-28

    PR 6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9001
  8. Samir Mohammed 2017-05-12

    Verified fix on SDK version 6.2.0.v20170512073825 and SDK version 6.1.0.v20170512073723. Test and other information can be found at: Master:https://github.com/appcelerator/titanium_mobile/pull/8997 6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9001

JSON Source