Skip to content

Commit

Permalink
added custom User-Agent header to http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlacot committed Mar 14, 2011
1 parent 3e6a3b0 commit b270074
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Resources/js/lib/initialize.js
Expand Up @@ -8,6 +8,7 @@ if (!Titanium.App.Properties.hasProperty('site_name')) {
}

Titanium.App.Properties.setString('api_url', 'http://api.xav.cc/');
Titanium.App.Properties.setString('api_user_agent', 'xavccMobileApp/2.0 (' + Titanium.Platform.name + '/' + Titanium.Platform.version + '; ' + Titanium.Platform.osname + '; ' + Titanium.Platform.locale + ')');

if (!Titanium.App.Properties.hasProperty('auto_copy')) {
Titanium.App.Properties.setBool('auto_copy', true);
Expand Down
7 changes: 5 additions & 2 deletions Resources/js/lib/xavcc.js
Expand Up @@ -4,7 +4,7 @@ var xavcc = (function() {

api.createClient = function() {
var client = Titanium.Network.createHTTPClient();
client.timeout = 10000; // 10 s. timeout
client.timeout = 20000; // 20 s. timeout
return client;
};

Expand All @@ -30,6 +30,7 @@ var xavcc = (function() {
}

this.showIndicator();
client.setRequestHeader('User-Agent', Titanium.App.Properties.getString('api_user_agent'));
client.send(null);
};

Expand Down Expand Up @@ -63,6 +64,7 @@ var xavcc = (function() {
}

this.showIndicator();
client.setRequestHeader('User-Agent', Titanium.App.Properties.getString('api_user_agent'));
client.send(null);
};

Expand Down Expand Up @@ -246,6 +248,7 @@ var xavcc = (function() {
client.open('GET', url, false);
}

client.setRequestHeader('User-Agent', Titanium.App.Properties.getString('api_user_agent'));
client.send(null);
}
};
Expand All @@ -256,7 +259,7 @@ var xavcc = (function() {
.from('shorturl')
.where('shorturl.shorturl = ?', shorturl)
.execute();
Titanium.API.log('info', 'count returns : ' + result);
Titanium.API.log('info', 'count returns : ' + result);
return (result > 0);
};

Expand Down

0 comments on commit b270074

Please sign in to comment.