Skip to content

Commit 57c5c6a

Browse files
author
Jonas Pfenniger
committed
websocket.Connection: Tyding things up
* Using the new sendHeader format from patches !! Now works with Google Chrome native WebSocket implementation. * .request is also now available for cookie tracking and stuff
1 parent 18be4a5 commit 57c5c6a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/http/websocket.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ function Connection(request, response) {
1818
var self = this,
1919
conn = this.connection = request.connection;
2020

21+
this.request = request;
22+
this.remoteAddress = conn.remoteAddress;
23+
2124
// TODO: fail differently if not compatible ?
2225
if (!supportUpgrade(request)) {
2326
conn.close();
@@ -31,8 +34,6 @@ function Connection(request, response) {
3134
conn.close();
3235
});
3336

34-
this.remoteAddress = conn.remoteAddress;
35-
3637
request.addListener("complete", function() {
3738
// Hijack connection after handshake
3839
conn.hijack();
@@ -48,10 +49,11 @@ function Connection(request, response) {
4849
});
4950

5051
response.use_chunked_encoding_by_default = false;
51-
response.sendHeader(101, {
52+
response.sendHeader([101, "Web Socket Protocol Handshake"], {
5253
"Upgrade": "WebSocket",
5354
"Connection": "Upgrade",
5455
"WebSocket-Origin": request.headers.origin,
56+
// TODO: wss://
5557
"WebSocket-Location": "ws://" + request.headers.host + request.uri.path
5658
});
5759
response.flush(); // send!!

0 commit comments

Comments
 (0)