Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

req.pipe(dest) doesn't return dest #171

Closed
TooTallNate opened this issue Jan 15, 2013 · 2 comments
Closed

req.pipe(dest) doesn't return dest #171

TooTallNate opened this issue Jan 15, 2013 · 2 comments

Comments

@TooTallNate
Copy link
Contributor

For consistency, it should probably return the dest writable stream that was passed in, for chaining.
https://github.com/joyent/node/blob/master/lib/stream.js#L125-L126

@TooTallNate
Copy link
Contributor Author

Looks like it's simple as:

diff --git a/lib/node/index.js b/lib/node/index.js
index 4d21f1c..c8689a7 100644
--- a/lib/node/index.js
+++ b/lib/node/index.js
@@ -375,15 +375,16 @@ Request.prototype.write = function(data, encoding){
  *
  * @param {Stream} stream
  * @param {Object} options
- * @return {Request} for chaining
+ * @return {Stream} the `stream` argument, for chaining
  * @api public
  */

 Request.prototype.pipe = function(stream, options){
   this.buffer(false);
-  return this.end().req.on('response', function(res){
+  this.end().req.on('response', function(res){
     res.pipe(stream, options);
   });
+  return stream;
 };

 /**

@tj tj closed this as completed in d17e466 Jan 15, 2013
@tj
Copy link
Contributor

tj commented Jan 15, 2013

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants