Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3318] No Redirect when using Titanium.Network.createHTTPClient

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-08T23:28:58.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelstbs-1.8.0
Reportermarco.schierhorn (at gmail)
AssigneeIngo Muschenetz
Created2011-04-15T03:42:02.000+0000
Updated2017-06-08T23:28:58.000+0000

Description

I have an issue using Titanium.Network.createHTTPClient with Android. Im trying to call an url http://www.motorsport-total.com/f1/live/htdocs/ticker.php">http://www.motorsport-total.com/f1/live/htdocs/ticker.php . When i call this url a redirect should happen as you can see if you use an usual web browser like firefox or chrome. It usually redirects to this url : http://www.motorsport-total.com/f1/live/htdocs/ticker.php?strecken_id=19&;event_id=7&kunde=default"> http://www.motorsport-total.com/f1/live/htdocs/ticker.php?strecken_...

Then i want to get those get parameters for using them in my app to get the latest race results. This works great with iOs but doenst work with Android. It still keeps on http://www.motorsport-total.com/f1/live/htdocs/ticker.php">http://www.motorsport-total.com/f1/live/htdocs/ticker.php

Is there any way to get the redirect working or to get those get parameters? I really need that fast because the iOs Version is already available in the iTunes Store and our client wants to go live with the Android Version. And thats the last big issue i have.

This is the code:

function get_last()
{
  var req = new r_ajax('http://www.motorsport-total.com/f1/live/htdocs/ticker.php', function(f)
  {
    Titanium.API.info('location of request = ' + f.location);
    var query = f.location.replace('http://www.motorsport-total.com/f1/live/htdocs/ticker.php?', '');
    var vars = query.split("&");
 
    for (var i = 0; i < vars.length; i++) 
    {
      Titanium.API.error(vars[i]);
      var pair = vars[i].split("=");
 
      if (pair[0] == 'strecken_id') 
      {
        win.strecken_id = pair[1];
      }
 
      if (pair[0] == 'event_id') 
      {
        win.event_id = pair[1];
      }
    }
 
    Titanium.API.info('win.strecken_id = ' + win.strecken_id );
    Titanium.API.info('win.event_id = ' + win.event_id);
 
    xmlFile = 'http://www.motorsport-total.com/f1/live/xmlfeed/generic/S_ID_' + win.strecken_id + '_EV_ID_' + win.event_id + '.xml';
    xmlNewsFile = 'http://www.motorsport-total.com/f1/live/xmlfeed/generic/S_ID_' + win.strecken_id + '_EV_ID_' + win.event_id + '_news.xml';
    createTickerValues(
    {
      url: xmlFile
    }, showLive, live_err);
  }, function()
  {
    Titanium.API.error('Error at function get_last live.js = ' + e);
  }, 'GET').send();
}
var r_ajax =  function(url,on_ok, on_err, method, async) {
    var async = !!async ? true : false;
    var method = !!method ? method : 'POST';
    var xhr = Titanium.Network.createHTTPClient();
 
    xhr.onload = function()
  {
        on_ok(this);
        xhr.abort();
    };
 
    xhr.onerror = function(e){
        on_err(e);
        xhr.abort();
    };  
 
 
    xhr.open(method,url,async);
 
    return {
        xhr:xhr,
        send:function(data) {
            xhr.send(data); 
        },
        abort:function() { xhr.abort();}
    };
};

Comments

  1. Alan Leard 2011-04-15

    Problem

    Confirmed that above code works properly if not redirected and fails only on Android when redirect is required.

    Test

    Tested on TiDev 1.6 and 1.7 (03/10/11) emulator APIs 2.2.

    Failed test results:

    win.strecken_id = undefined
    win.event_id = undefined

    Ticket Reference

    HD Ticket Reference: http://developer.appcelerator.com/helpdesk/view/76362">http://developer.appcelerator.com/helpdesk/view/76362

  2. Lee Morris 2017-06-08

    Closing ticket as there has been no input for the last 6 years. Any problems, please file a new ticket.

JSON Source