joyent/node — Issue #2474: HTTPS request not working with proxy
Author: chowey
Created: 2012-01-06 03:01:02+00:00
State: open

I have a squid proxy on my local computer (127.0.0.1:3128). It is configured to require no authentication. If I try to use an `https.request`, I get an error like:

{ [Error: socket hang up] code: 'ECONNRESET' }

The following code reproduces this issue (provided of course that you have a squid proxy set up on port 3128):

```javascript
var https = require('https');

var options = {
hostname: '127.0.0.1',
port: 3128,
path: 'https://github.com/',
headers: {
Host: 'github.com',
'User-Agent': 'Node.js/0.6.6'
},
method: 'GET'
};

var req = https.request(options, function (res) {
console.log('statusCode: ', res.statusCode);
console.log('headers: ', res.headers);

res.on('data', function (chunk) {
process.stdout.write(chunk);
});
}).on('error', function (e) {
console.error(e);
}).end();
```

It is definitely an error with node itself. If the problem were with squid, it would just result in responses with statusCode 501.

I am running v0.6.6 on Windows 7.