This fixes a critical bug see in MJR's production. Very difficult to build a
test case. Sometimes HTTPS server gets sockets that are hanging in a
half-duplex state.
This commit does three things:
1. Uses an exposed counter rather than a hidden array for tracking dest
streams that may have multiple inputs. This allows for significantly
faster lookups, since the counter can be checked in constant time rather
than searching an array for the dest object. (A proper O(1) WeakMap
would be better, but that may have to wait for Harmony.)
2. Calls the 'end' event logic when there is an 'error' event on the
source object (and then throws if there are no other error listeners.)
This is important, because otherwise 'error' events would lead to
memory leaks.
3. Clean up the style a bit. Function Declarations are not allowed
within blocks in ES strict. Prefer Function Declarations to Function
Expressions, because hoisting allows for more expressive ordering of
logic.
Downside: It adds "_pipeCount" as part of the Stream API. It'll work
fine if the member is missing, but if anyone tries to use it for some
other purpose, it can mess things up.
1. Allow single-quotes in urls, but escape them.
2. Add comments about which RFCs we're following for guidance.
3. Handle any invalid character in the hostname portion.
4. lcase protocol and hostname portions, since they are
case-insensitive.
Implemented a new property for writable file streams that keeps track
of the bytes written (not queued). This helps when you are piping
another stream to a file, and would like to know how big the file is
without having to issue another stat call.
closes#930
When creating multiple .pipe()s to the same destination stream, the
first source to end would close the destination, breaking all remaining
pipes. This patch fixes the problem by keeping track of all open
pipes, so that we only call end on destinations that have no more
sources piping to them.
closes#929
Previously the return value of write was dependent on if it was paused or
not which was causing a strange error demoed in the previous commit.
Fixes#892