[AC-1500] Android: HTTP POST response with no body throws exception on SDK 5.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Duplicate |
Resolution Date | 2015-10-02T13:33:45.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android, httpclient |
Reporter | Anders Dahl Pape |
Assignee | Shak Hossain |
Created | 2015-09-24T12:13:11.000+0000 |
Updated | 2016-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.
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.
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)
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.
Sounds great :D
awesome! Quotes issues =P
Duplicate of linked issue