Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
Apr 04, 2012
Jens Grunert Adding configurable user-agent to request header 737152b
Jens Grunert Merge branch 'master' of github.com:jensgrunert/npm
* 'master' of github.com:jensgrunert/npm:
  Updating doc
  Adding configurable User-Agent to request header

Conflicts:
	doc/cli/config.md
	lib/utils/config-defs.js
0d56414
2  doc/cli/config.md
Source Rendered
@@ -360,7 +360,7 @@ A proxy to use for outgoing https requests.
360 360
361 361 ### user-agent
362 362
363   -* Default: NPM/{npm-version}
  363 +* Default: npm/{npm.version} node/{process.version}
364 364 * Type: String
365 365
366 366 Sets a User-Agent to the request header
3  lib/utils/config-defs.js
@@ -9,6 +9,7 @@ var path = require("path")
9 9 , os = require("os")
10 10 , nopt = require("nopt")
11 11 , log = require("./log.js")
  12 + , npm = require("../npm.js")
12 13
13 14 function Octal () {}
14 15 function validateOctal (data, k, val) {
@@ -183,7 +184,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
183 184 , proxy : process.env.HTTP_PROXY || process.env.http_proxy || null
184 185 , "https-proxy" : process.env.HTTPS_PROXY || process.env.https_proxy ||
185 186 process.env.HTTP_PROXY || process.env.http_proxy || null
186   - , "user-agent" : "NPM/"+process.version
  187 + , "user-agent" : "npm/" + npm.version + " node/" + process.version
187 188 , "rebuild-bundle" : true
188 189 , registry : "http" + (httpsOk ? "s" : "") + "://registry.npmjs.org/"
189 190 , rollback : true
2  lib/utils/npm-registry-client/request.js
@@ -95,6 +95,8 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb) {
95 95
96 96 headers.accept = "application/json"
97 97
  98 + headers["User-Agent"] = opts.userAgent
  99 +
98 100 opts.proxy = npm.config.get( remote.protocol === "https:"
99 101 ? "https-proxy" : "proxy" )
100 102
4 node_modules/request/main.js
@@ -244,10 +244,6 @@ Request.prototype.init = function (options) {
244 244 self.multipart(options.multipart)
245 245 }
246 246
247   - if (self.userAgent) {
248   - self.headers['User-Agent'] = self.userAgent
249   - }
250   -
251 247 if (self.body) {
252 248 var length = 0
253 249 if (!Buffer.isBuffer(self.body)) {

No commit comments for this range

Something went wrong with that request. Please try again.