Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix bug when upgrade header has data #167

Open
wants to merge 1 commit into from

3 participants

@andrewrk

No description provided.

@einaros
Owner

I'll look into this one. Thank you!

@andrewrk

@3rd-Eden have you considered this PR?

@3rd-Eden
Owner

@superjoe30 I haven't as @einaros said he would look in to it. But if you can update the pull request (it cannot be merged in to master) I'll be more than happy to look at it as long as it comes with tests that demonstrate this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @andrewrk
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/WebSocket.js
View
16 lib/WebSocket.js
@@ -518,19 +518,19 @@ function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) {
upgradeHead = null;
self._receiver.add(head);
}
- dataHandler = realHandler;
+ socket.removeListener('data', firstHandler);
+ socket.on('data', realHandler);
+ realHandler(data);
+ }
+ // subsequent packets are pushed straight to the receiver
+ function realHandler(data) {
+ if (self.readyState != WebSocket.OPEN) return;
if (data) {
self.bytesReceived += data.length;
self._receiver.add(data);
}
}
- // subsequent packets are pushed straight to the receiver
- function realHandler(data) {
- if (data) self.bytesReceived += data.length;
- self._receiver.add(data);
- }
- var dataHandler = firstHandler;
- socket.on('data', dataHandler);
+ socket.on('data', firstHandler);
// if data was passed along with the http upgrade,
// this will schedule a push of that on to the receiver.
// this has to be done on next tick, since the caller
Something went wrong with that request. Please try again.