Skip to content

Instantly share code, notes, and snippets.

@pgriess
Created June 14, 2010 15:33
Show Gist options
  • Save pgriess/437842 to your computer and use it in GitHub Desktop.
Save pgriess/437842 to your computer and use it in GitHub Desktop.
diff --git a/lib/http.js b/lib/http.js
index 1cf9eca..e9d7c6a 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -863,11 +863,18 @@ function Client ( ) {
self.destroy(ret);
} else if (parser.incoming && parser.incoming.upgrade) {
var bytesParsed = ret;
- var upgradeHead = d.slice(start + bytesParsed, end - start);
- parser.incoming.upgradeHead = upgradeHead;
- var req = self._outgoing[0];
self.ondata = null;
self.onend = null
+
+ var req = self._outgoing[0];
+
+ var upgradeHead = d.slice(start + bytesParsed + 1, end - start);
+
+ if (self.listeners('upgrade').length) {
+ self.emit('upgrade', req, self, upgradeHead);
+ } else {
+ self.destroy();
+ }
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment