got 5.3.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +14 -6
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -5,7 +5,8 @@ var https = require('https');
5
5
  var urlLib = require('url');
6
6
  var querystring = require('querystring');
7
7
  var objectAssign = require('object-assign');
8
- var duplexify = require('duplexify');
8
+ var PassThrough = require('readable-stream').PassThrough;
9
+ var duplexer2 = require('duplexer2');
9
10
  var isStream = require('is-stream');
10
11
  var readAllStream = require('read-all-stream');
11
12
  var timedOut = require('timed-out');
@@ -140,7 +141,9 @@ function asPromise(opts) {
140
141
  }
141
142
 
142
143
  function asStream(opts) {
143
- var proxy = duplexify();
144
+ var input = new PassThrough();
145
+ var output = new PassThrough();
146
+ var proxy = duplexer2(input, output);
144
147
 
145
148
  if (opts.json) {
146
149
  throw new Error('got can not be used as stream when options.json is used');
@@ -168,7 +171,7 @@ function asStream(opts) {
168
171
  }
169
172
 
170
173
  if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
171
- proxy.setWritable(req);
174
+ input.pipe(req);
172
175
  return;
173
176
  }
174
177
 
@@ -178,7 +181,7 @@ function asStream(opts) {
178
181
  ee.on('response', function (res) {
179
182
  var statusCode = res.statusCode;
180
183
 
181
- proxy.setReadable(res);
184
+ res.pipe(output);
182
185
 
183
186
  if (statusCode < 200 || statusCode > 299) {
184
187
  proxy.emit('error', new got.HTTPError(statusCode, opts), null, res);
@@ -328,8 +331,13 @@ got.stream = function (url, opts, cb) {
328
331
  };
329
332
 
330
333
  helpers.forEach(function (el) {
331
- got.stream[el] = function (url, opts) {
332
- return got.stream(url, objectAssign({}, opts, {method: el.toUpperCase()}));
334
+ got.stream[el] = function (url, opts, cb) {
335
+ if (typeof opts === 'function') {
336
+ cb = opts;
337
+ opts = {};
338
+ }
339
+
340
+ return got.stream(url, objectAssign({}, opts, {method: el.toUpperCase()}), cb);
333
341
  };
334
342
  });
335
343
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Simplified HTTP/HTTPS requests",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
@@ -46,7 +46,7 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "create-error-class": "^2.0.0",
49
- "duplexify": "^3.2.0",
49
+ "duplexer2": "^0.1.4",
50
50
  "is-plain-obj": "^1.0.0",
51
51
  "is-redirect": "^1.0.0",
52
52
  "is-stream": "^1.0.0",
@@ -56,6 +56,7 @@
56
56
  "parse-json": "^2.1.0",
57
57
  "pinkie-promise": "^2.0.0",
58
58
  "read-all-stream": "^3.0.0",
59
+ "readable-stream": "^2.0.5",
59
60
  "timed-out": "^2.0.0",
60
61
  "unzip-response": "^1.0.0",
61
62
  "url-parse-lax": "^1.0.0"