Browse Source

minor tweaks

http2
Sindre Sorhus 10 years ago
parent
commit
c05add501c
  1. 16
      index.js
  2. 4
      package.json

16
index.js

@ -6,7 +6,7 @@ var zlib = require('zlib');
var assign = require('object-assign');
var agent = require('infinity-agent');
var duplexify = require('duplexify');
var isReadableStream = require('isstream').isReadable;
var isStream = require('is-stream');
var read = require('read-all-stream');
var timeout = require('timed-out');
var prependHttp = require('prepend-http');
@ -103,7 +103,12 @@ function got(url, opts, cb) {
}
if (!proxy) {
isReadableStream(body) ? body.pipe(req) : req.end(body);
if (isStream.readable(body)) {
body.pipe(req);
} else {
req.end(body);
}
return;
}
@ -112,7 +117,12 @@ function got(url, opts, cb) {
throw new Error('got\'s stream is not writable when options.body is used');
};
isReadableStream(body) ? body.pipe(req) : req.end(body);
if (isStream.readable(body)) {
body.pipe(req);
} else {
req.end(body);
}
return;
}

4
package.json

@ -39,8 +39,8 @@
],
"dependencies": {
"duplexify": "^3.2.0",
"infinity-agent": "^0.2.0",
"isstream": "^0.1.1",
"infinity-agent": "^1.0.0",
"is-stream": "^1.0.0",
"object-assign": "^2.0.0",
"prepend-http": "^1.0.0",
"read-all-stream": "^0.1.0",

Loading…
Cancel
Save