云函数本地调试,发起http请求会携带多余的header,如何去掉?
发布于 7 年前 作者 tmo 15075 次浏览 来自 官方Issues

使用云函数对外发起http请求,本地调试会携带多余的header,这个如何去掉- 代码实例:

var http = require('http');
    var options = {
        protocol: 'http:',
        hostname: 'id.qq.com',
        port: '80',
        path: '/',
        method: 'GET'
    };
 
    var client = http.request(options, function (res) {
        var data = '';
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            data += chunk;
        });
        res.on('end', function () {
            console.log(data);
        });
    });
 
    client.end();
  • 实际发出的HTTP报文:

GET / HTTP/1.1X-WORKER-ID: testX-FUNCTION-ID: testX-CALL-STACK: [{“requestId”:“6b75edba-0bb2-422b-8eae-70b3f681b505”,“local”:true,“done”:false,“startTime”:1564715027465,“offsetTime”:-698,“functionId”:“test”,“calls”:[],“workerId”:“test”}] X-REQUEST-ID: 6b75edba-0bb2-422b-8eae-70b3f681b505 X-ORIGIN-ENV: xxxHost: id.qq.comConnection: close

1 回复

这是本地调试时默认带上的,后续可以去掉,现在会有什么问题吗

回到顶部