Saturday, 22 April 2017

Сolon in custom request headers

How I can send headers with : to another (not my) server? It possible?

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"]



via Евгений Мнацаканов

No comments:

Post a Comment