收藏
回答

云函数本地调试,发起http请求会携带多余的header,如何去掉?

使用云函数对外发起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.1 X-WORKER-ID: test X-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


最后一次编辑于  08-02  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答