[TIMOB-4321] HTTP Requests throws null pointer exception
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-06-14T12:49:18.000+0000 |
Affected Version/s | Release 1.7.0 |
Fix Version/s | Sprint 2011-24 |
Components | Android |
Labels | android, enterprise, exception, httpclient |
Reporter | Pedro Enrique |
Assignee | Opie Cyrus |
Created | 2011-06-06T07:28:56.000+0000 |
Updated | 2011-07-06T17:53:49.000+0000 |
Description
If you attempt to open a HTTP connection using the HttpClient, a null pointer exception is thrown if you do not have the protocol http or https specificied in the url. Although not specifying the protocol is bad, it shouldn't throw out a null pointer exception. The issue is in the TiHTTPClient class with the following method signature: private static Uri getCleanUri(String uri). The encodedAuthority String object can be null but is not checked before doing the indexOf operation on which throws an exception.
Example Code:
var window = Ti.UI.createWindow({
backgroundColor:'white'
});
window.open();
var xhr = Ti.Network.createHTTPClient();
xhr.validatesSecureCertificate = true;
xhr.onerror = function(e){
alert(e.error);
};
xhr.onload = function(e){
alert(this.responseText);
}
xhr.open('GET', 'google.com');
xhr.send();
Helpdesk Ticket:
http://support.appcelerator.com/tickets/APP-946174/homepage
Attachments
File | Date | Size |
---|---|---|
tsDefault.zip | 2011-06-13T17:51:59.000+0000 | 5362116 |
test app
Code review and functional tests: no scheme, http scheme, and https scheme. Note if you use https, remember to set validate cert to
false
Null pointer exception no longer occurs in build 1.8.0.v20110706150638. Tested and passed on an Android device running 2.2.1