Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17566] Android: setting createHTTPClient properties autoRedirect and autoEncodeURL are ignored

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-01-06T21:52:53.000+0000
Affected Version/sRelease 3.2.3, Release 3.3.0
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsnetwork, parity, qe-automatedtest
ReporterEwan Harris
AssigneeAshraf Abu
Created2014-08-27T22:09:17.000+0000
Updated2015-02-16T07:14:09.000+0000

Description

Description

When using Ti.Network.createHTTPClient and setting the properties in the create method to false it is ignored and they default to true. The workaround is to use one of the two ways below to set the properties to false.
client.setAutoRedirect(false);
client.setAutoEncodeUrl(false);
or
client.autoRedirect = false;
client.autoEncodeUrl = false;

Steps To Reproduce

1. Create a project and add the app.js attached 2. Build to an Android device/simulator and then tap the button

Actual Result

The properties set to true, the URL is auto-redirected and auto-encoded, in the Studio console you should see what is attached in consoleLog.txt

Expected Result

The properties should stay false and it should not auto-redirect or auto-encode the URL.

Attachments

FileDateSize
app.js2014-08-27T22:09:17.000+00001580
consoleLog.txt2014-08-27T22:09:17.000+00001608

Comments

  1. Ingo Muschenetz 2014-08-27

    FYI.
  2. Ingo Muschenetz 2014-08-28

    Docs to not specify otherwise, so it's assumed you can do this in the constructor. Appears to work for iOS.
  3. Ashraf Abu 2015-01-05

    To allow this in Android when creating HTTPClient. PR: https://github.com/appcelerator/titanium_mobile/pull/6532
       
       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://httpbin.org/redirect/2";
           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);
                   alert(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);
                   alert(this.status);
                   Ti.API.info("Received statusText: " + this.statusText);
                   Ti.API.info("Received responseText: " + this.responseText);
        
                   alert('error');
               },
               timeout : 5000, // in milliseconds*
        
        		autoRedirect : false,
           	autoEncodeUrl : false,
        
           });
           
       
           // Prepare the connection.
        
           client.open("GET", url);
           // Send the request.
           client.send();
        
       });
        
       // Add to the parent view.
       win1.add(aButton);
        
       win1.open();
       
       
    Expected behavior running this code with PR above: Status code 200 (OK) Otherwise we'd get status 302 (needs redirecting)
  4. Ingo Muschenetz 2015-01-05

    Not a regression, moving out of 3.5.0.
  5. Ashraf Abu 2015-02-12

    Useful link to test autoEncodeURL: var url = "http://chart.apis.google.com/chart?chco=666666,555555,444444,333333,222222&chs=288x150&cht=p&chd=t:36,15,12,10,26&chdl=xyz%7Cabc%7Cdef%7Cghi%7Cjkl&chdlp=b&chf=c,s,ffffff%7Cbg,s,ffffff&chl=36%|15%|12%|10%|26%";
  6. Khushbu Agrawal 2015-02-12

    Verified with below Test Environment: 1. Mac OSX Yosemite 10.10.1 2. Appcelerator Studio, build: 4.0.0.201502111458 3. Titanium SDK, build: 4.0.0.v20150211151855 4. Titanium CLI, build: 3.6.0-dev 5. Alloy: 1.5.1 6. Nexus 6 with Android 5.0 The properties autoRedirect and autoEncodeUrl are set as false. The URL is neither auto-redirected nor auto-encoded as seen in the studio console. Closing this ticket.

JSON Source