node@0.12 and proxy with https over http combination is not working
Opened this issue · 1 comments
masakura commented
Node.js v0.12.7 and proxy with https over http combination is not working. Error occurs.
I test my ta.js
script. http://www.nasa.gov
is 200 OK, but, https://travis-ci.org
is failed.
$ nvm use v0.12.7 && node ta.js https://travis-ci.org
Now using node v0.12.7
{ [Error: write EPROTO 140128450471808:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:782:
] code: 'EPROTO', errno: 'EPROTO', syscall: 'write' }
$ nvm use v0.12.7 && node ta.js http://www.nasa.gov
Now using node v0.12.7
200 (http://www.nasa.gov)
$ nvm use v0.10.40 && node ta.js https://travis-ci.org
Now using node v0.10.40
200 (https://travis-ci.org)
$ nvm use v0.10.40 && node ta.js http://www.nasa.gov
Now using node v0.10.40
200 (http://www.nasa.gov)
ta.js
is here.
'use strict';
var url = process.argv[2];
var options = require('url').parse(url);
var protocol = options.protocol.replace(':', '');
var tunnel = require('tunnel-agent')[protocol + 'OverHttp'];
options.agent = tunnel({
proxy: {
host: '{proxyhost}',
port: 8080,
proxyAuth: '{userid}:{password}'
}
});
options.headers = {
'Connection': 'close'
};
var func = protocol === 'http' ? require('http') : require('https');
var req = func.request(options, function (res) {
console.log(res.statusCode + ' (' + url + ')');
});
req.on('error', function (error) {
console.log(error);
})
req.end();