Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2400] iOS: HTTPClient: autoEncodeURL not used when redirect is followed

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2013-11-22T22:20:09.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsalloy, encoding, httpclient, ios, ios7, redirect, url
ReporterAdam Lynch
AssigneeMauro Parra-Miranda
Created2013-11-11T18:23:41.000+0000
Updated2016-03-08T07:41:26.000+0000

Description

When trying to GET something which returns a 301, if I set autoEncodeURL to false (via the setter or directly), set autoRedirect to true (or leave it default to that), then the value of the location header returned is encoded before being followed. To get around this, I had to set autoRedirect to false. Then in the success callback, get the value of the location header returned and issue another GET manually (with autoEncodeURL set to false). Edit: This doesn't seem to be a problem on Android

Comments

  1. Adam Lynch 2013-11-13

    This doesn't seem to be a problem on Android
  2. Mostafizur Rahman 2013-11-21

    Hello, We have tested this issue with sample below. We can’t reproduce this problem. If you continue to encounter the error, please send us your test code and steps to reproduce. We look forward to your feedback. Regards,

    Test environment:

    OS: MAC OS X 10.8.5 Ti SDK: 3.1.3 GA Ti CLI: 3.2.0 IOS simulator 7.0

    Test Sample

       var win1 = Titanium.UI.createWindow({
       	 
       });
       
       // Create a Button.
       var aButton = Ti.UI.createButton({
       	title : 'aButton',
       });
       
       // Listen for click events.
       aButton.addEventListener('click', function() {
       
       	var url = "http://www.example.com/redirect.php";
       	var client = Ti.Network.createHTTPClient({
       		// function called when the response data is available
       		onload : function(e) {
       			Ti.API.info('e ' + JSON.stringify(e));
       			Ti.API.info("Received HEADERS_RECEIVED: " + this.HEADERS_RECEIVED);
       			Ti.API.info("Received status: " + this.status);
       			Ti.API.info("Received statusText: " + this.statusText);
       			Ti.API.info("Received responseText: " + this.responseText);
       
       			alert('success');
       		},
       		// function called when an error occurs, including a timeout
       		onerror : function(e) {
       			Ti.API.debug(e.error);
       			Ti.API.info("Received HEADERS_RECEIVED: " + this.HEADERS_RECEIVED);
       			Ti.API.info("Received status: " + this.status);
       			Ti.API.info("Received statusText: " + this.statusText);
       			Ti.API.info("Received responseText: " + this.responseText);
       
       			alert('error');
       		},
       		timeout : 5000, // in milliseconds
       		autoRedirect : true,
       		autoEncodeUrl : false,
       
       	});
       	// Prepare the connection.
       
       	client.open("GET", url);
       	// Send the request.
       	client.send();
       
       });
       
       // Add to the parent view.
       win1.add(aButton);
       
       win1.open();
       

    Server side code

       <?php
       
       error_reporting(1);
       Header( "HTTP/1.1 301 Moved Permanently" );
       //Header( "Location: http://www.example.com" );
       ?>
       

    Step to reproduces

    1. Create a new project 2. Paste test code in app.js 3. Now run on iOS 7 with simulator 7.0 4. Click on button its return success
  3. Mauro Parra-Miranda 2013-11-22

    Tested in 3.1.3, works as expected.

JSON Source