Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-2798

Android: xhr NPE for posts with empty http body

    Details

      Description

      {html}<div><p>I have a page that returns a 200 response, but nothing in the
      body.<br></p>
      <pre>
      <code>var xhr = Titanium.Network.createHTTPClient();
      xhr.onload = function() {Ti.API.info('I am in utf-8 onload for POST');};
      xhr.onerror = function() {Ti.API.info('I am in utf-8 error for POST');};
      xhr.open("POST","http://mywebsite.com/script.cfm");
      xhr.send({"a":"hi", "b":"there"});</code>
      </pre>
      If the sript I post to doesn't return a body, only a 200, then the
      NPE happens. If I change the script to return any text at all the
      NPE is avoided.
      <p>The resulting log of the NPE looks like:<br></p>
      <pre>
      <code>[TRACE] E/TiUIView( 1729): (main) [5383,101697] TAP, TAP, TAP on [Ti.UI.Button]
      [TRACE] D/TiHttpClient( 1729): (kroll$3) [10,101707] Setting ready state to 1
      [TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 12700 objects / 611088 bytes in 124ms
      [TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 1967 objects / 297312 bytes in 369ms
      [TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [2521,104228] Setting ready state to 2
      [TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [0,104228] Setting ready state to 3
      [TRACE] E/TiHttpClient( 1729): (TiHttpClient-2) [2,104230] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException
      [TRACE] E/TiHttpClient( 1729): java.lang.NullPointerException
      [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:321)
      [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:257)
      [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:166)
      [TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
      [TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
      [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1010)
      [TRACE] E/TiHttpClient( 1729): at java.lang.Thread.run(Thread.java:1096)
      [TRACE] I/TiHttpClient( 1729): (TiHttpClient-2) [3,104233] Sending error java.lang.NullPointerException</code>
      </pre></div>{html}

        Attachments

          Activity

            People

            • Assignee:
              dthorp Don Thorp
              Reporter:
              anthonywebb Anthony Webb
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-2441
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration