Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

stream: unshift('') is a noop #5624

Merged
merged 1 commit into from Jun 3, 2013
Merged

Conversation

isaacs
Copy link

@isaacs isaacs commented Jun 3, 2013

In some cases, the http CONNECT/Upgrade API is unshifting an empty
bodyHead buffer onto the socket.

Normally, stream.unshift(chunk) does not set state.reading=false.
However, this check was not being done for the case when the chunk was
empty (either '' or Buffer(0)), and as a result, it was causing the
socket to think that a read had completed, and to stop providing data.

This bug is not limited to http or web sockets, but rather would affect
any parser that unshifts data back onto the source stream without being
very careful to never unshift an empty chunk. Since the intent of
unshift is to not change the state.reading property, this is a bug.

Fixes #5557
Fixes socketio/socket.io#1242

@bnoordhuis
Copy link
Member

LGTM I guess but isn't it easier to just revert a40133d?

In some cases, the http CONNECT/Upgrade API is unshifting an empty
bodyHead buffer onto the socket.

Normally, stream.unshift(chunk) does not set state.reading=false.
However, this check was not being done for the case when the chunk was
empty (either `''` or `Buffer(0)`), and as a result, it was causing the
socket to think that a read had completed, and to stop providing data.

This bug is not limited to http or web sockets, but rather would affect
any parser that unshifts data back onto the source stream without being
very careful to never unshift an empty chunk.  Since the intent of
unshift is to *not* change the state.reading property, this is a bug.

Fixes nodejs#5557
Fixes socketio/socket.io#1242
@isaacs isaacs merged commit df6ffc0 into nodejs:v0.10 Jun 3, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants