Comparing version 0.3.4 to 0.3.5
@@ -11,4 +11,4 @@ var httpreq = require('./httpreq'); | ||
// example6(); // u can use doRequest instead of .get or .post | ||
// example7(); // download a binary file: | ||
example8(); //send json | ||
example7(); // download a binary file: | ||
// example8(); // send json | ||
// example9(); // send your own body content (eg. xml): | ||
@@ -117,3 +117,9 @@ // example10(); // set max redirects: | ||
function example7(){ | ||
httpreq.get('https://ssl.gstatic.com/gb/images/k1_a31af7ac.png', {binary: true}, function (err, res){ | ||
httpreq.get('https://ssl.gstatic.com/gb/images/k1_a31af7ac.png', { | ||
binary: true, | ||
progressCallback: function (err, progress) { | ||
console.log(progress); | ||
} | ||
}, | ||
function (err, res){ | ||
if (err){ | ||
@@ -120,0 +126,0 @@ console.log(err); |
@@ -165,5 +165,22 @@ /* | ||
var ended = false; | ||
var currentsize = 0; | ||
res.on('data', function (chunk) { | ||
chunks.push(chunk); | ||
if(o.progressCallback){ | ||
var totalsize = res.headers['content-length']; | ||
if(totalsize){ | ||
currentsize += chunk.length; | ||
o.progressCallback(null, { | ||
totalsize: totalsize, | ||
currentsize: currentsize, | ||
percentage: currentsize*100/totalsize | ||
}); | ||
}else{ | ||
o.progressCallback(new Error("no content-length specified for file, so no progress monitoring possible")); | ||
} | ||
} | ||
}); | ||
@@ -170,0 +187,0 @@ |
{ | ||
"name": "httpreq", | ||
"description": "node-httpreq is a node.js library to do HTTP(S) requests the easy way", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Sam Decrock", |
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
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
81953
463