then-request
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -0,0 +0,0 @@ 'use strict'; |
10
index.js
'use strict'; | ||
var assert = require('assert'); | ||
var parseUrl = require('url').parse; | ||
@@ -49,2 +50,9 @@ var Promise = require('promise'); | ||
var body = options.body ? options.body : new Buffer(0); | ||
if (typeof body === 'string') body = new Buffer(body); | ||
assert(Buffer.isBuffer(body), 'body should be a Buffer or a String'); | ||
if (!Object.keys(options.headers).some(function (name) { return name.toLowerCase() === 'content-length'; })) { | ||
options.headers['content-length'] = body.length; | ||
} | ||
var req = module.exports._request(method, url, { | ||
@@ -64,3 +72,3 @@ headers: options.headers, | ||
if (req) { | ||
req.end(options.body ? options.body : new Buffer(0)); | ||
req.end(body); | ||
} | ||
@@ -67,0 +75,0 @@ }); |
@@ -0,0 +0,0 @@ 'use strict'; |
{ | ||
"name": "then-request", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A request library that returns promises, inspired by request", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -0,0 +0,0 @@ # then-request |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
assert(handleQs('http://example.com/', {foo: 'bar'}) === 'http://example.com/?foo=bar'); | ||
assert(handleQs('http://example.com/', {foo: {bar: 'baz'}}) === 'http://example.com/?foo[bar]=baz'); | ||
assert(handleQs('http://example.com/', {foo: {bar: 'baz'}}) === 'http://example.com/?foo%5Bbar%5D=baz'); | ||
assert(handleQs('http://example.com/', {foo: 'bar', bing: 'bong'}) === 'http://example.com/?foo=bar&bing=bong'); | ||
@@ -13,0 +13,0 @@ assert(handleQs('http://example.com/?foo=bar', {bing: 'bong'}) === 'http://example.com/?foo=bar&bing=bong'); |
@@ -0,0 +0,0 @@ 'use strict'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15957
311