Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Iphone xhr.setRequestHeader User Agent Override Error

I was trying to change the User-Agent see the code below… But still the default user-agent is showing in the server log.

Please help me to figure out the exact command to send a user define user-agent.

125.xx.xx.12 www.xxx.com - [14/May/2010:12:53:09 +0400] "GET / HTTP/1.1" 200 18520 "-" "Appcelerator Titanium/1.2.0 (iPhone Simulator/3.1.2; iPhone OS; en_US;)"

125.xx.xx.12 www.xxx.com - [14/May/2010:12:53:09 +0400] "GET / HTTP/1.1" 200 18520 "-" "Appcelerator Titanium/1.2.0 (iPhone Simulator/3.1.2; iPhone OS; en_US;)"

125.xx.xx.12 www.xxx.com - [14/May/2010:12:53:09 +0400] "GET / HTTP/1.1" 200 18520 "-" "Appcelerator Titanium/1.2.0 (iPhone Simulator/3.1.2; iPhone OS; en_US;)"

var c = Titanium.Network.createHTTPClient();

c.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)");    

c.setTimeout(10000);
c.onload = function()
{
    alert(this.responseText);

};
c.error = function(e)
{
    Ti.UI.createAlertDialog({title:'Image Search', message:'Error: ' + e.error}).show();
};

c.open('POST', url);
c.send();
— asked May 14th 2010 by Sherwin Terunez
  • agent
  • error
  • iphone
  • network
  • setrequestheader
  • simulator
  • user
0 Comments

1 Answer

  • setting the request header should be after open and before send.

    — answered July 3rd 2010 by Clayton Narcis
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.