提交 e1aa04cc 编写于 作者: M mzabriskie

Fixing issue #3

上级 3950ceea
......@@ -20,6 +20,11 @@ module.exports = function httpAdapter(resolve, reject, config) {
config.headers || {}
);
// Add Content-Length header if data exists
if (data) {
headers['Content-Length'] = data.length;
}
// Parse url
var parsed = url.parse(config.url);
var options = {
......
......@@ -14,7 +14,7 @@ module.exports = {
return utils.isObject(data) &&
!utils.isFile(data) &&
!utils.isBlob(data) ?
JSON.stringify(data) : null;
JSON.stringify(data) : data;
}],
transformResponse: [function (data) {
......
var defaults = require('../../lib/defaults');
module.exports = {
testTransformRequestJson: function (test) {
var data = defaults.transformRequest[0]({foo: 'bar'});
test.equals(data, '{"foo":"bar"}');
test.done();
},
testTransformRequestString: function (test) {
var data = defaults.transformRequest[0]('foo=bar');
test.equals(data, 'foo=bar');
test.done();
},
testTransformResponseJson: function (test) {
var data = defaults.transformResponse[0]('{"foo":"bar"}');
test.equals(typeof data, 'object');
test.equals(data.foo, 'bar');
test.done();
},
testTransformResponseString: function (test) {
var data = defaults.transformResponse[0]('foo=bar');
test.equals(data, 'foo=bar');
test.done();
}
};
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册