joyent/node — pull request #3036 by stephank (2012-03-30 09:25:29+00:00)
Title: Response object for HTTP Upgrade/CONNECT

I started a thread on nodejs-dev about this, but it looks like my posts are still in the moderator queue. Will link it here once it gets through.

Briefly:

* The first commit is a test showing that a pipelined Upgrade request to a Node server can cause an out-of-order response. This is because the `upgrade` handler gets immediate access to the socket, while other requests may still be processing async.

* The second commit fixes this by providing a response object even for Upgrade, that is also queued properly along with other responses.

* In addition to fixing the test, I find it makes sense to have a response here. Per the spec, CONNECT and Upgrade **must** be followed by a proper response, before handover.

Regarding `make test`, I have one failing test both before and after this patch set, namely `simple/test-http-full-response`. I consider this a platform irk. `make test-debug` plain crashes the test suite on `simple/test-repl` (also before and after), but a fair amount of HTTP tests do pass.