doc: change write() after end() streams example
authorAlejandro Oviedo <alejandro.oviedo.g@gmail.com>
Fri, 12 Dec 2014 16:03:13 +0000 (13:03 -0300)
committerBen Noordhuis <info@bnoordhuis.nl>
Sun, 14 Dec 2014 19:06:46 +0000 (20:06 +0100)
Currently there's an example using http.ServerResponse stream, which
has a known bug and will not throw an error while writing after end().
Changed to a writable stream from fs which behaves as expected.

Fixes https://github.com/joyent/node/issues/8814.

PR-URL: https://github.com/iojs/io.js/pull/155
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brendan Ashworth <squirrelslikeacorns@gmail.com>
doc/api/stream.markdown

index 5ffcef91456a594bae3663f46b31673405ca6676..d1fa2cca350e0457377e36756383e473061c8dd9 100644 (file)
@@ -585,11 +585,10 @@ Calling [`write()`][] after calling [`end()`][] will raise an error.
 
 ```javascript
 // write 'hello, ' and then end with 'world!'
-http.createServer(function (req, res) {
-  res.write('hello, ');
-  res.end('world!');
-  // writing more now is not allowed!
-});
+var file = fs.createWriteStream('example.txt');
+file.write('hello, ');
+file.end('world!');
+// writing more now is not allowed!
 ```
 
 #### Event: 'finish'