diff --git a/index.js b/index.js index 315d43b..8bac67c 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ var timedOut = require('timed-out'); var prependHttp = require('prepend-http'); var lowercaseKeys = require('lowercase-keys'); var isRedirect = require('is-redirect'); -var pinkiePromise = require('pinkie-promise'); +var PinkiePromise = require('pinkie-promise'); var unzipResponse = require('unzip-response'); var createErrorClass = require('create-error-class'); @@ -102,7 +102,7 @@ function asCallback(opts, cb) { } function asPromise(opts) { - return new pinkiePromise(function (resolve, reject) { + return new PinkiePromise(function (resolve, reject) { asCallback(opts, function (err, data, response) { response.body = data; @@ -180,6 +180,7 @@ function normalizeArguments(url, opts) { }, lowercaseKeys(opts.headers)); var query = opts.query; + if (query) { if (typeof query !== 'string') { opts.query = querystring.stringify(query); @@ -194,6 +195,7 @@ function normalizeArguments(url, opts) { } var body = opts.body; + if (body) { if (typeof body !== 'string' && !Buffer.isBuffer(body) && !isStream.readable(body)) { throw new Error('options.body must be a ReadableStream, string or Buffer'); diff --git a/test/test-stream.js b/test/test-stream.js index 5a7128e..6b11eef 100644 --- a/test/test-stream.js +++ b/test/test-stream.js @@ -1,5 +1,4 @@ 'use strict'; - var test = require('tap').test; var got = require('../'); var server = require('./server.js'); @@ -69,7 +68,7 @@ test('request event', function (t) { test('redirect event', function (t) { got.stream(s.url + '/redirect') - .on('redirect', function (res, opts) { + .on('redirect', function (res) { t.equal(res.headers.location, s.url); t.end(); });