docs: fix streams example for write() after end()

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.

fix #8814

Signed-off-by: Julien Gilli <julien.gilli@joyent.com>
pull/23395/head
Alejandro Oviedo 2014-12-06 03:44:46 -03:00 committed by Julien Gilli
parent 5e503f45d2
commit f5cb330ab1
1 changed files with 4 additions and 5 deletions

View File

@ -521,11 +521,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'