Browse Source

Bump dependencies and fix lint issues

extract-response
Sindre Sorhus 8 years ago
parent
commit
1f1b6ffb6d
  1. 5
      index.js
  2. 13
      package.json
  3. 3
      test/helpers/server.js
  4. 4
      test/post.js
  5. 2
      test/redirects.js
  6. 2
      test/stream.js

5
index.js

@ -194,7 +194,7 @@ function asStream(opts) {
function normalizeArguments(url, opts) { function normalizeArguments(url, opts) {
if (typeof url !== 'string' && typeof url !== 'object') { if (typeof url !== 'string' && typeof url !== 'object') {
throw new Error(`Parameter \`url\` must be a string or object, not ${typeof url}`); throw new TypeError(`Parameter \`url\` must be a string or object, not ${typeof url}`);
} }
if (typeof url === 'string') { if (typeof url === 'string') {
@ -250,7 +250,8 @@ function normalizeArguments(url, opts) {
opts.headers['content-type'] = opts.headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`; opts.headers['content-type'] = opts.headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`;
} else if (body !== null && typeof body === 'object' && !Buffer.isBuffer(body) && !isStream(body)) { } else if (body !== null && typeof body === 'object' && !Buffer.isBuffer(body) && !isStream(body)) {
opts.headers['content-type'] = opts.headers['content-type'] || 'application/x-www-form-urlencoded'; opts.headers['content-type'] = opts.headers['content-type'] || 'application/x-www-form-urlencoded';
body = opts.body = querystring.stringify(body); body = querystring.stringify(body);
opts.body = body;
} }
if (opts.headers['content-length'] === undefined && opts.headers['transfer-encoding'] === undefined && !isStream(body)) { if (opts.headers['content-length'] === undefined && opts.headers['transfer-encoding'] === undefined && !isStream(body)) {

13
package.json

@ -19,9 +19,6 @@
"engines": { "engines": {
"node": ">=4" "node": ">=4"
}, },
"browser": {
"unzip-response": false
},
"scripts": { "scripts": {
"test": "xo && nyc ava", "test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls" "coveralls": "nyc report --reporter=text-lcov | coveralls"
@ -61,18 +58,18 @@
"ava": "^0.18.0", "ava": "^0.18.0",
"coveralls": "^2.11.4", "coveralls": "^2.11.4",
"form-data": "^2.1.1", "form-data": "^2.1.1",
"get-port": "^2.0.0", "get-port": "^3.0.0",
"into-stream": "^3.0.0", "into-stream": "^3.0.0",
"nyc": "^10.0.0", "nyc": "^10.0.0",
"pem": "^1.4.4", "pem": "^1.4.4",
"pify": "^2.3.0", "pify": "^2.3.0",
"tempfile": "^1.1.1", "tempfile": "^1.1.1",
"xo": "*" "xo": "^0.18.0"
},
"xo": {
"esnext": true
}, },
"ava": { "ava": {
"concurrency": 4 "concurrency": 4
},
"browser": {
"unzip-response": false
} }
} }

3
test/helpers/server.js

@ -4,7 +4,8 @@ const https = require('https');
const pify = require('pify'); const pify = require('pify');
const getPort = require('get-port'); const getPort = require('get-port');
const host = exports.host = 'localhost'; exports.host = 'localhost';
const host = exports.host;
exports.createServer = function () { exports.createServer = function () {
return getPort().then(port => { return getPort().then(port => {

4
test/post.js

@ -53,7 +53,7 @@ test('sends strings', async t => {
}); });
test('sends Buffers', async t => { test('sends Buffers', async t => {
const {body} = await got(s.url, {body: new Buffer('wow')}); const {body} = await got(s.url, {body: Buffer.from('wow')});
t.is(body, 'wow'); t.is(body, 'wow');
}); });
@ -77,7 +77,7 @@ test('content-length header with string body', async t => {
test('content-length header with Buffer body', async t => { test('content-length header with Buffer body', async t => {
const {body} = await got(`${s.url}/headers`, { const {body} = await got(`${s.url}/headers`, {
body: new Buffer('wow'), body: Buffer.from('wow'),
json: true json: true
}); });
t.is(body['content-length'], '3'); t.is(body['content-length'], '3');

2
test/redirects.js

@ -59,7 +59,7 @@ test.before('setup', async () => {
http.on('/redirect-with-utf8-binary', (req, res) => { http.on('/redirect-with-utf8-binary', (req, res) => {
res.writeHead(302, { res.writeHead(302, {
location: new Buffer(`${http.url}/utf8-url-áé`, 'utf8').toString('binary') location: Buffer.from(`${http.url}/utf8-url-áé`, 'utf8').toString('binary')
}); });
res.end(); res.end();
}); });

2
test/stream.js

@ -60,7 +60,7 @@ test.cb('throws on write to stream with body specified', t => {
got.stream(s.url, {body: 'wow'}).write('wow'); got.stream(s.url, {body: 'wow'}).write('wow');
}, 'got\'s stream is not writable when options.body is used'); }, 'got\'s stream is not writable when options.body is used');
// wait for request to end // Wait for request to end
setTimeout(t.end, 10); setTimeout(t.end, 10);
}); });

Loading…
Cancel
Save