I want to create a HTTP-1.0 request by net.socket or http.request but I have a problem with this code:
var http = require('http');
var options = {
host:'google.com',
method: 'CONNECT',
path: 'google.com:80',
port: 80
};
var req = http.request(options);
req.end();
req.on('connect', function(res, socket, head) {
socket.write('GET / HTTP/1.0\r\n' +
'Host: google.com:80\r\n' +
'\r\n');
socket.on('data', function(chunk) {
console.log(chunk);
});
socket.end();
});
I get same error:
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1366:r20)
at TCP.onread (net.js:403:27)
Your help is welcome.