Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib/request.js')
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/request.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/request.js b/deps/npm/node_modules/npm-registry-client/lib/request.js
index 3cbb07228b9..72401e60e73 100644
--- a/deps/npm/node_modules/npm-registry-client/lib/request.js
+++ b/deps/npm/node_modules/npm-registry-client/lib/request.js
@@ -8,12 +8,17 @@ var url = require("url")
, Stream = require("stream").Stream
, request = require("request")
, retry = require("retry")
+ , crypto = require("crypto")
function regRequest (method, where, what, etag, nofollow, cb_) {
if (typeof cb_ !== "function") cb_ = nofollow, nofollow = false
if (typeof cb_ !== "function") cb_ = etag, etag = null
if (typeof cb_ !== "function") cb_ = what, what = null
+ if (!this.sessionToken) {
+ this.sessionToken = crypto.randomBytes(8).toString("hex")
+ }
+
var registry = this.conf.get('registry')
if (!registry) return cb(new Error(
"No registry url provided: " + method + " " + where))
@@ -143,6 +148,12 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) {
headers[method === "GET" ? "if-none-match" : "if-match"] = etag
}
+ headers['npm-session'] = this.sessionToken
+
+ if (this.refer) {
+ headers.referer = this.refer
+ }
+
headers.accept = "application/json"
headers['accept-encoding'] = 'gzip'