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

HTTPClient - request url with leading blanks cause an exception

    Details

    • Type: Bug
    • Status: Open
    • Priority: None
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: iOS
    • Environment:

      Description

      Problem description

      When the httpclient request url starts with leading blanks, an exception is thrown when the "send()" function is executed.

      message = "-[NSNull rangeOfString:]: unrecognized selector sent to instance 0x3a804690";
      

      Steps to reproduce

      Create HTTPClient and use a request url with leading blanks: " http://www.appcelerator.com"

      Test case

      app.js

      (function() {
      	
      	var urls = [
      		"http://www.appcelerator.com",
      		"www.appcelerator.com",
      		"appcelerator.com",
      		"http://www.appcelerator2.com",
      		"http2://www.appcelerator.com",
      		"http:www.appcelerator.com",
      		"   http://www.appcelerator.com" //exception
      	];	
      	var win = Ti.UI.createWindow({backgroundColor:'#ffffff'});
      	var view = Ti.UI.createView({layout:'vertical'});
      	var button = Ti.UI.createButton({title:' Run test ',top:100,borderRadius:5,borderColor:'#1C1C1C',backgroundColor:'#C0C0C0'});
      	var output = Ti.UI.createLabel({top: 20,font:{fontSize:11}});
      	
      	button.addEventListener('click',function(){
      		output.text = '';
      		for (var i=0; i < urls.length; i++) {
      		  sendGET(i,urls[i]);
      		}		
      	});
      	
      	view.add(button);
      	view.add(output);
      	win.add(view);
      	
      	function sendGET(i,url){
      		
      		var client = Ti.Network.createHTTPClient({
      		     onload : function(e) {
      		     	 var msg = 'Test ' + i + ': ' + url + ' - success';
      		     	 output.text += '\n' + msg;
      		         Ti.API.log(msg);
      		     },
      		     onerror : function(e) {
      		     	var msg = 'Test ' + i + ': ' + url + ' - error';
      		     	output.text += '\n' + msg;
      		     	Ti.API.error(msg);
      		     },
      		});
      	 	client.open("GET", url);
      	 	try{
      			client.send();
      		}catch(e){
      	     	var msg = 'Test ' + i + ': ' + url + ' - EXCEPTION';
      	     	output.text += '\n' + msg;
      	     	Ti.API.error(msg);			
      		}		
      	}
       
      	win.open();
      })();
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Esche Markus Eschenbach
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Source Code