joyent/node — pull request #2491 by koichik (2012-01-08 17:01:16+00:00)
Title: http: handle CONNECT response as a Upgrade

`http.Server` emits `'upgrade'` event when a CONNECT request is received (it is not documented, this patch adds the description), and the socket is given to the user. However, on a client side, the socket after a HTTP tunnel is established is not given.

After this patch is applied, `http.ClientRequest` emits `'upgrade'` event (I did not think that it is good API, but I did it in the same way as a server side), and gives the socket when a CONNECT response is received.

Refs: #2474.

Please review.