Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ module.exports = function(options, onprogress) {
update.remaining = length - update.transferred;
tr.emit('length', length);
};

// Expose `onlength()` handler as `setLength()` to support custom use cases where length
// is not known until after a few chunks have already been pumped, or is
// calculated on the fly.
tr.setLength = onlength;

tr.on('pipe', function(stream) {
if (typeof length === 'number') return;
if (options.length && typeof length === 'number') return;
// Support http module
if (stream.readable && !stream.writable && stream.headers) {
return onlength(parseInt(stream.headers['content-length'] || 0));
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
],
"main": "index.js",
"dependencies": {
"through2": "~0.2.3",
"speedometer": "~0.1.2"
"speedometer": "^1.0.0",
"through2": "^2.0.1"
},
"devDependencies": {
"request": "~2.29.0",
"single-line-log": "~1.0.0",
"numeral": "~1.5.2"
"numeral": "~1.5.2",
"request": "^2.72.0",
"single-line-log": "^1.1.1"
},
"scripts": {
"test": "node test/http.js && node test/request.js"
Expand Down