是否可以在以下脚本中添加自定义标头?可以在python中使用,而我只需要在lambda中进行测试即可。
const http = require('http');
exports.handler = async (event, context) => {
return new Promise((resolve, reject) => {
const options = {
host: 'www.some.url.com',
path: '/api/',
port: 80,
method: 'GET'
};
const req = http.request(options, (res) => {
let data = '';
// A chunk of data has been recieved.
res.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
res.on('end', () => {
console.log(JSON.parse(data));
});
});
req.write('');
req.end();
});
};
示例为:
host: 'www.some.url.com',
path: '/api/',
port: 80,
method: 'GET'
header: User-Agent: chrome
header: Content-Type: application/xjson
我不是开发人员,所以也许根本不可能:)