函数计算http服务
返回的结果总是包含头:Content-Disposition:attachment
导致页面不能在浏览器上显示,而是变成下载
代码如下:(nodejs)
var getRawBody = require('raw-body');
var getFormBody = require('body/form');
var body = require('body');
/*
if you open the initializer feature, please implement the initializer function, as below:
module.exports.initializer = function(context, callback) {
console.log('initializing');
callback(null, '');
};
*/
module.exports.handler = function(req, resp, context) {
console.log('hello world');
var params = {
path: req.path,
queries: req.queries,
headers: req.headers,
method : req.method,
requestURI : req.url,
clientIP : req.clientIP,
}
getRawBody(req, function(err, body) {
resp.deleteHeader('Content-Disposition');
for (var key in req.queries) {
var value = req.queries[key];
resp.setHeader(key, value);
}
resp.deleteHeader('Content-Disposition');
resp.setHeader('Content-Disposition', 'inline');
params.body = body;
resp.send(JSON.stringify(params, null, 4));
});
/*
getFormBody(req, function(err, formBody) {
for (var key in req.queries) {
var value = req.queries[key];
resp.setHeader(key, value);
}
params.body = formBody;
console.log(formBody);
resp.send(JSON.stringify(params));
});
*/
}