Skip to content

Commit

Permalink
Merge pull request #12 from mduan/set-user-agent
Browse files Browse the repository at this point in the history
Set user agent header when issuing requests to github
  • Loading branch information
arturadib committed May 1, 2013
2 parents 61fb994 + b621086 commit 9434ca0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ function randomHash(count) {
}
}

var HEADERS = {
'User-Agent': 'botio'
};

// checkCredentials()
function checkCredentials(callback) {
process.stdout.write('Verifying Github credentials... ');

var url = 'https://'+global.user+':'+global.pwd+'@api.github.com';

request.get(url, function(err, res, body) {
request.get({
url: url,
headers: HEADERS
}, function(err, res, body) {
if (err) {
console.log('FAILED');
console.log('Could not talk to Github');
Expand All @@ -85,6 +92,7 @@ function postComment(obj, callback) {

request.post({
url: url,
headers: HEADERS,
json: {
body: '#### From: '+config.name+'\n\n'+
'----\n\n'+
Expand All @@ -105,7 +113,10 @@ function postComment(obj, callback) {
function getPullDetails(obj, callback) {
var url = 'https://'+global.user+':'+global.pwd+'@api.github.com/repos/'+config.repo+'/pulls/'+obj.issue;

request.get(url, function(err, res, body) {
request.get({
url: url,
headers: HEADERS
}, function(err, res, body) {
if (err || !res || res.statusCode !== 200) {
if (callback) callback('Status code:' + res ? res.statusCode : '(unknown)');
return;
Expand Down

0 comments on commit 9434ca0

Please sign in to comment.