Since "error" events will throw when unhandled anyhow, it makes no sense
to throw from an EventEmitter's method, especially for such a minor
misdemeanor as attempting to write to a non-writable stream.
This does 3 things:
1. Delimiters and "unwise" characters are never included in the
hostname or path.
2. url.format will sanitize string URLs that are passed to it.
3. The parsed url's 'href' member will be the sanitized url, which may
not match the argument to url.parse.
Since "error" events will throw when unhandled anyhow, it makes no sense
to throw from an EventEmitter's method, especially for such a minor
misdemeanor as attempting to write to a non-writable stream.
Improvements:
* Removes an unnecessary variable
* Avoids having two variables with the same name
* Avoids re-declaring an existing parameter
* Removes an unnecessary ternary operator
* Avoid an inline short-circuit expression for greater clarity.
Problem: Omitting the mode parameter causes the provided callback
parameter to never fire. This was originally fixed in 6078c37b and
later broken in 5f2e9093.
Solution: Overwriting the value of a parameter also overwrites the
reference in the arguments object. This patch works arround this
fact by not touching the mode parameter until a reference to the
callback has been established.
This is important so that in the future, this will work:
$ cd ~/dev/js/some-project
$ npm install redis
$ node
> require.resolve('redis')
'/Users/isaacs/dev/js/some-project/node_modules/redis/index.js'
This works for both ServerResponse and ClientRequest.
Adds three new methods as a couple properties to to OutgoingMessage objects.
Tests by Charlie Robbins.
Change-Id: Ib6f3829798e8f11dd2b6136e61df254f1564807e