chromedriver
Advanced tools
Comparing version 2.15.1 to 2.15.2
@@ -7,2 +7,3 @@ 'use strict' | ||
var helper = require('./lib/chromedriver') | ||
var http = require('http') | ||
var kew = require('kew') | ||
@@ -12,4 +13,4 @@ var npmconf = require('npmconf') | ||
var path = require('path') | ||
var request = require('request') | ||
var rimraf = require('rimraf').sync | ||
var url = require('url') | ||
var util = require('util') | ||
@@ -57,3 +58,3 @@ | ||
console.log('Saving to', downloadedFile) | ||
return requestBinary(downloadedFile) | ||
return requestBinary(getRequestOptions(conf.get('proxy')), downloadedFile) | ||
}) | ||
@@ -74,3 +75,2 @@ | ||
.fail(function (err) { | ||
console.error(err) | ||
console.error('ChromeDriver installation failed', err.stack) | ||
@@ -109,3 +109,21 @@ process.exit(1) | ||
function requestBinary(filePath) { | ||
function getRequestOptions(proxyUrl) { | ||
if (proxyUrl) { | ||
var options = url.parse(proxyUrl) | ||
options.path = downloadUrl | ||
options.headers = { Host: url.parse(downloadUrl).host } | ||
// Turn basic authorization into proxy-authorization. | ||
if (options.auth) { | ||
options.headers['Proxy-Authorization'] = 'Basic ' + new Buffer(options.auth).toString('base64') | ||
delete options.auth | ||
} | ||
return options | ||
} else { | ||
return url.parse(downloadUrl) | ||
} | ||
} | ||
function requestBinary(requestOptions, filePath) { | ||
var deferred = kew.defer() | ||
@@ -115,32 +133,29 @@ | ||
var notifiedCount = 0 | ||
var reportProgress = function(data) { | ||
count += data.length | ||
if ((count - notifiedCount) > 800000) { | ||
console.log('Received ' + Math.floor(count / 1024) + 'K...') | ||
notifiedCount = count | ||
} | ||
} | ||
var outFile = fs.openSync(filePath, 'w') | ||
console.log('Receiving...') | ||
request({uri: downloadUrl, encoding: null}, function(err, response, body) { | ||
if (err) { | ||
deferred.reject('Error with http request: ' + err) | ||
return | ||
} | ||
var client = http.get(requestOptions, function (response) { | ||
var status = response.statusCode | ||
console.log('Receiving...') | ||
if (response.statusCode !== 200) { | ||
deferred.reject('Error with http request: ' + util.inspect(response.headers)) | ||
return | ||
} | ||
if (status === 200) { | ||
response.addListener('data', function (data) { | ||
fs.writeSync(outFile, data, 0, data.length, null) | ||
count += data.length | ||
if ((count - notifiedCount) > 800000) { | ||
console.log('Received ' + Math.floor(count / 1024) + 'K...') | ||
notifiedCount = count | ||
} | ||
}) | ||
console.log('Received ' + Math.floor(body.length / 1024) + 'K total.') | ||
fs.writeFile(filePath, body, function(err) { | ||
if (err) { | ||
deferred.reject('Error writing to file ' + filePath) | ||
} else { | ||
response.addListener('end', function () { | ||
console.log('Received ' + Math.floor(count / 1024) + 'K total.') | ||
fs.closeSync(outFile) | ||
deferred.resolve(true) | ||
} | ||
}) | ||
}) | ||
}).on('data', reportProgress) | ||
} else { | ||
client.abort() | ||
deferred.reject('Error with http request: ' + util.inspect(response.headers)) | ||
} | ||
}) | ||
@@ -147,0 +162,0 @@ return deferred.promise |
{ | ||
"name": "chromedriver", | ||
"version": "2.15.1", | ||
"version": "2.15.2", | ||
"keywords": [ | ||
@@ -37,5 +37,4 @@ "chromedriver", | ||
"npmconf": "^2.1.1", | ||
"request": "^2.55.0", | ||
"rimraf": "^2.0.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33556080
5
10
188
3
- Removedrequest@^2.55.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)