Permalink
Browse files

Merge pull request #374 from ypocat/master

Correct Host header for proxy tunnel CONNECT
  • Loading branch information...
2 parents b638185 + 8014d2a commit 82d3cb1f4423fa61d0021ca29e13b3f2d9380edb @mikeal mikeal committed Nov 19, 2012
Showing with 5 additions and 2 deletions.
  1. +4 −1 main.js
  2. +1 −1 tests/test-tunnel.js
View
@@ -138,6 +138,7 @@ Request.prototype.init = function (options) {
} else {
if (typeof self.uri == "string") self.uri = url.parse(self.uri)
}
+
if (self.proxy) {
if (typeof self.proxy == 'string') self.proxy = url.parse(self.proxy)
@@ -148,7 +149,9 @@ Request.prototype.init = function (options) {
var tunnelOptions = { proxy: { host: self.proxy.hostname
, port: +self.proxy.port
- , proxyAuth: self.proxy.auth }
+ , proxyAuth: self.proxy.auth
+ , headers: { Host: self.uri.hostname + ':' +
+ (self.uri.port || self.uri.protocol === 'https:' ? 443 : 80) }}
, ca: this.ca }
self.agent = tunnelFn(tunnelOptions)
View
@@ -23,7 +23,7 @@ var ready = false
squid.stderr.on('data', function (c) {
console.error('SQUIDERR ' + c.toString().trim().split('\n')
.join('\nSQUIDERR '))
- ready = c.toString().match(/ready to serve requests/i)
+ ready = c.toString().match(/ready to serve requests|Accepting HTTP Socket connections/i)
})
squid.stdout.on('data', function (c) {

0 comments on commit 82d3cb1

Please sign in to comment.