mikeal/request — pull request #374 by ypocat (2012-11-18 20:00:57+00:00)
Title: Correct Host header for proxy tunnel CONNECT

As per [RFC 2817](http://www.ietf.org/rfc/rfc2817.txt), section _5.2 Requesting a Tunnel with CONNECT_, there is a `Host` header to be set. The examples in the RFC use the same example host/port which is confusing, but logically, it makes no sense to use the same hostname in `CONNECT` statement and in the `Host` header. The `Host` header is meant to be set to the actual host to be proxied/tunelled to, and it looks like at least some of the proxies out there work that way.

I believe this also closes #367.

Notes:

1. it would probably be ideal if the tunnel options were overridable from the main api, e.g. via `opts = { tunnelOptions: { .. } }`

2. it would probably be better if the Host header for the tunnel was set after the logic for resolving the target hostname/port/protocol, which is below the tunnel config code, but it contains a few references to self.tunnel, so I'm not sure on that.