Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes GH-674 Load https lazily

  • Loading branch information...
commit 4926fa87dcc553b72000eeb0c41a2941e20b324d 1 parent 5f14164
@isaacs isaacs authored
Showing with 10 additions and 4 deletions.
  1. +5 −2 lib/utils/fetch.js
  2. +5 −2 lib/utils/registry/request.js
View
7 lib/utils/fetch.js
@@ -2,8 +2,8 @@
* Fetch an HTTP url to a local file.
**/
-var http = require("http")
- , https = require("https")
+var http
+ , https
, url = require("url")
, sys = require("./sys")
, fs = require("./graceful-fs")
@@ -61,6 +61,9 @@ function fetchAndWrite (remote, fstr, headers, maxRedirects, redirects) {
opts = proxyify(npm.config.get("proxy"), remote, opts)
if (!opts) return cb(new Error("Bad proxy config: "+npm.config.get("proxy")))
+ if (opts.secure) https = https || require("https")
+ else http = http || require("http")
+
;(opts.secure ? https : http).get(opts, function (response) {
// handle redirects.
var loc = get(response.headers, "location")
View
7 lib/utils/registry/request.js
@@ -6,8 +6,8 @@ request.reg = reg
request.upload = upload
var npm = require("../../../npm")
- , http = require("http")
- , https = require("https")
+ , http
+ , https
, url = require("url")
, log = require("../log")
, ini = require("../ini")
@@ -103,6 +103,9 @@ function request (method, where, what, etag, nofollow, cb_) {
opts = proxyify(npm.config.get("proxy"), remote, opts)
if (!opts) return cb(new Error("Bad proxy config: "+npm.config.get("proxy")))
+ if (opts.secure) https = https || require("https")
+ else http = http || require("http")
+
var req = (opts.secure ? https : http).request(opts, function (response) {
log.verbose(where, "response")
// if (response.statusCode !== 200) return cb(new Error(
Please sign in to comment.
Something went wrong with that request. Please try again.