Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1500] Android: HTTP POST response with no body throws exception on SDK 5.0

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionDuplicate
Resolution Date2015-10-02T13:33:45.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, httpclient
ReporterAnders Dahl Pape
AssigneeShak Hossain
Created2015-09-24T12:13:11.000+0000
Updated2016-03-08T07:37:57.000+0000

Description

If a POST request issues an 200 OK response with no body (which is optional) and thereby no content-type:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 0
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 23 Sep 2015 19:30:19 GMT
A nullPointerException is thrown on Android:
[ERROR] : TiHTTPClient: (TiHttpClient-10) [44708,46136] HTTP Error (java.lang.NullPointerException): Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
[ERROR] : TiHTTPClient: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:195)
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:84)
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1194)
[ERROR] : TiHTTPClient: at java.lang.Thread.run(Thread.java:818)
As noted by Fokke in this post: https://community.appcelerator.com/topic/3447/android-http-post-request-fails-on-5-0-but-works-on-4-1/2 it seems as if theres a bug in TiHTTPClient.java in line 193-197.

Comments

  1. Carlos Henrique Zinato 2015-09-24

    On iOS everything is fine... Facing same problem only on Android (no matter which version). Switch to SDK 4.1 and 3.5.1 and it works.
  2. Osiel Bonilla Quezada 2015-09-27

    I have the same issue with Titanium SDK 5.0.1.GA And Android api 23 [ERROR] : TiHTTPClient: (TiHttpClient-3) [11093,12862] HTTP Error (java.lang.NullPointerException): Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference [ERROR] : TiHTTPClient: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:195) [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:84) [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1194) [ERROR] : TiHTTPClient: at java.lang.Thread.run(Thread.java:818)
  3. David Vermeir 2015-09-29

    I have an issue with sending the request on Android in the first place. If you have form-data together with a file, the body is empty on arrival on the server but the file is still there. Without the file, the body is filled correctly. This worked on 3.5.0.
  4. Ryan Asleson 2015-10-02

  5. Ashraf Abu 2015-10-02

  6. Anders Dahl Pape 2015-10-02

    Sounds great :D
  7. Carlos Henrique Zinato 2015-10-02

    awesome! Quotes issues =P
  8. Ingo Muschenetz 2015-10-02

    Duplicate of linked issue

JSON Source