mirror of
https://github.com/xuxiaobo-bobo/boda_jsEnv.git
synced 2025-04-22 23:44:23 +08:00
28 lines
692 B
JavaScript
28 lines
692 B
JavaScript
"use strict";
|
|
exports.__esModule = true;
|
|
var Promise = require("promise");
|
|
function getBody(encoding) {
|
|
if (!encoding) {
|
|
return this.then(getBodyBinary);
|
|
}
|
|
if (encoding === 'utf8') {
|
|
return this.then(getBodyUTF8);
|
|
}
|
|
return this.then(getBodyWithEncoding(encoding));
|
|
}
|
|
function getBodyWithEncoding(encoding) {
|
|
return function (res) { return res.getBody(encoding); };
|
|
}
|
|
function getBodyBinary(res) {
|
|
return res.getBody();
|
|
}
|
|
function getBodyUTF8(res) {
|
|
return res.getBody('utf8');
|
|
}
|
|
function toResponsePromise(result) {
|
|
result.getBody = getBody;
|
|
return result;
|
|
}
|
|
exports["default"] = toResponsePromise;
|
|
exports.ResponsePromise = undefined;
|