Skip to content

Commit

Permalink
Merge pull request #1960 from bower/add-user-agent
Browse files Browse the repository at this point in the history
add User-Agent to downloadd
  • Loading branch information
sheerun committed Oct 24, 2015
2 parents 8f0a3d7 + 0f790f4 commit eaa05ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/util/download.js
Expand Up @@ -5,6 +5,7 @@ var mout = require('mout');
var retry = require('retry');
var createError = require('./createError');
var createWriteStream = require('fs-write-stream-atomic');
var userAgent = require('./userAgent');

var errorCodes = [
'EADDRINFO',
Expand All @@ -31,7 +32,10 @@ function download(url, file, options) {

operation.attempt(function () {
Q.fcall(fetch, url, file, {
progressDelay: progressDelay
progressDelay: progressDelay,
headers: {
'User-Agent': userAgent
}
}).then(function(response) {
deferred.resolve(response);
}).fail(function (error) {
Expand Down
3 changes: 3 additions & 0 deletions lib/util/userAgent.js
@@ -0,0 +1,3 @@
var pkg = require('../../package.json');

module.exports = 'node/' + process.version + ' ' + process.platform + ' ' + process.arch + ' ' + ';Bower ' + pkg.version;

0 comments on commit eaa05ac

Please sign in to comment.