如何将带有:
的HTTP标头发送到另一台服务器(不是我的)?有可能吗?
var http = require('http');
var options = {
host: 'example.net',
path: '/',
method: 'POST',
headers: {
':custom': 'Custom Header Demo works'
}
};
callback = function (response) {
var str = ''
response.on('data', (chunk) => str += chunk);
response.on('end', () => console.log(str));
}
var req = http.request(options, callback);
req.write("foo=bar");
req.end();
这是我得到的:
TypeError: Header name must be a valid HTTP Token [":custom"]