Showing with 4,403 additions and 1,013 deletions.
  1. +1 −1 benchmark/net-pipe.js
  2. +42 −9 doc/api/crypto.markdown
  3. +394 −95 doc/api/stream.markdown
  4. +1 −1 lib/_debugger.js
  5. +63 −0 lib/_stream_duplex.js
  6. +18 −13 test/simple/test-zlib-destroy.js → lib/_stream_passthrough.js
  7. +752 −0 lib/_stream_readable.js
  8. +231 −0 lib/_stream_transform.js
  9. +257 −0 lib/_stream_writable.js
  10. +0 −3 lib/child_process.js
  11. +68 −11 lib/crypto.js
  12. +141 −282 lib/fs.js
  13. +64 −70 lib/http.js
  14. +252 −218 lib/net.js
  15. +2 −2 lib/repl.js
  16. +17 −4 lib/stream.js
  17. +7 −0 lib/string_decoder.js
  18. +20 −15 lib/tty.js
  19. +91 −124 lib/zlib.js
  20. +5 −0 node.gyp
  21. +24 −15 src/node.js
  22. +13 −0 src/node_zlib.cc
  23. +1 −0 test/fixtures/x1024.txt
  24. +8 −8 test/message/max_tick_depth_trace.out
  25. +10 −6 test/message/stdin_messages.out
  26. +2 −0 test/simple/test-child-process-disconnect.js
  27. +48 −10 test/simple/test-child-process-fork-net2.js
  28. +3 −0 test/simple/test-child-process-ipc.js
  29. +1 −0 test/simple/test-cluster-http-pipe.js
  30. +2 −0 test/simple/test-cluster-message.js
  31. +75 −2 test/simple/test-crypto.js
  32. +4 −8 test/simple/test-domain-http-server.js
  33. +20 −15 test/simple/test-file-write-stream.js
  34. +27 −13 test/simple/test-file-write-stream2.js
  35. +4 −2 test/simple/test-fs-empty-readStream.js
  36. +27 −13 test/simple/test-fs-read-stream-err.js
  37. +1 −3 test/simple/test-fs-read-stream.js
  38. +2 −1 test/simple/test-fs-write-stream-end.js
  39. +38 −18 test/simple/test-fs-write-stream-err.js
  40. +4 −0 test/simple/test-http-1.0-keep-alive.js
  41. +9 −1 test/simple/test-http-abort-client.js
  42. +7 −3 test/simple/test-http-agent.js
  43. +1 −0 test/simple/test-http-client-agent.js
  44. +3 −2 test/simple/test-http-client-pipe-end.js
  45. +5 −1 test/simple/test-http-connect.js
  46. +1 −0 test/simple/test-http-date-header.js
  47. +1 −0 test/simple/test-http-default-encoding.js
  48. +1 −0 test/simple/test-http-header-read.js
  49. +12 −9 test/simple/test-http-header-response-splitting.js
  50. +4 −2 test/simple/test-http-host-headers.js
  51. +5 −2 test/simple/test-http-keep-alive-close-on-header.js
  52. +3 −0 test/simple/test-http-keep-alive.js
  53. +1 −0 test/simple/test-http-many-keep-alive-connections.js
  54. +1 −0 test/simple/test-http-parser-free.js
  55. +1 −0 test/simple/test-http-request-end-twice.js
  56. +1 −0 test/simple/test-http-request-end.js
  57. +4 −2 test/simple/test-http-res-write-end-dont-take-array.js
  58. +1 −0 test/simple/test-http-response-readable.js
  59. +1 −0 test/simple/test-http-set-trailers.js
  60. +1 −0 test/simple/test-http-status-code.js
  61. +2 −0 test/simple/test-http-timeout.js
  62. +1 −0 test/simple/test-https-agent.js
  63. +2 −0 test/simple/test-https-socket-options.js
  64. +1 −0 test/simple/test-https-strict.js
  65. +2 −0 test/simple/test-net-after-close.js
  66. +23 −5 test/simple/test-net-binary.js
  67. +11 −4 test/simple/test-net-bytes-stats.js
  68. +2 −0 test/simple/test-net-can-reset-timeout.js
  69. +10 −3 test/simple/test-net-connect-buffer.js
  70. +4 −0 test/simple/test-net-connect-options.js
  71. +6 −3 test/simple/test-net-pingpong.js
  72. +14 −4 test/simple/test-net-reconnect.js
  73. +1 −0 test/simple/test-net-remote-address-port.js
  74. +4 −0 test/simple/test-net-write-after-close.js
  75. +13 −0 test/simple/test-pipe-file-to-http.js
  76. +1 −0 test/simple/test-pipe.js
  77. +1 −0 test/simple/test-regress-GH-877.js
  78. +2 −1 test/simple/test-repl-autolibs.js
  79. +320 −0 test/simple/test-stream2-basic.js
  80. +76 −0 test/simple/test-stream2-fs.js
  81. +105 −0 test/simple/test-stream2-pipe-error-handling.js
  82. +109 −0 test/simple/test-stream2-readable-from-list.js
  83. +299 −0 test/simple/test-stream2-set-encoding.js
  84. +314 −0 test/simple/test-stream2-transform.js
  85. +246 −0 test/simple/test-stream2-writable.js
  86. +1 −0 test/simple/test-tcp-wrap-connect.js
  87. +13 −2 test/simple/test-tls-pause.js
  88. +0 −7 test/simple/test-zlib-invalid-input.js
  89. +17 −0 test/simple/test-zlib-random-byte-pipes.js
@@ -27,7 +27,7 @@ Writer.prototype.write = function(chunk, encoding, cb) {

// doesn't matter, never emits anything.
Writer.prototype.on = function() {};

Writer.prototype.once = function() {};
Writer.prototype.emit = function() {};

var statCounter = 0;
@@ -89,6 +89,11 @@ Example: this program that takes the sha1 sum of a file

The class for creating hash digests of data.

It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hash. Once the writable side of
the stream is ended, use the `read()` method to get the computed hash
digest. The legacy `update` and `digest` methods are also supported.

Returned by `crypto.createHash`.

### hash.update(data, [input_encoding])
@@ -114,6 +119,11 @@ called.
Creates and returns a hmac object, a cryptographic hmac with the given
algorithm and key.

It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hmac. Once the writable side of
the stream is ended, use the `read()` method to get the computed
digest. The legacy `update` and `digest` methods are also supported.

`algorithm` is dependent on the available algorithms supported by
OpenSSL - see createHash above. `key` is the hmac key to be used.

@@ -148,6 +158,11 @@ recent releases, `openssl list-cipher-algorithms` will display the
available cipher algorithms. `password` is used to derive key and IV,
which must be a `'binary'` encoded string or a [buffer](buffer.html).

It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hash. Once the writable side of
the stream is ended, use the `read()` method to get the computed hash
digest. The legacy `update` and `digest` methods are also supported.

## crypto.createCipheriv(algorithm, key, iv)

Creates and returns a cipher object, with the given algorithm, key and
@@ -166,6 +181,11 @@ Class for encrypting data.

Returned by `crypto.createCipher` and `crypto.createCipheriv`.

Cipher objects are [streams](stream.html) that are both readable and
writable. The written plain text data is used to produce the
encrypted data on the the readable side. The legacy `update` and
`final` methods are also supported.

### cipher.update(data, [input_encoding], [output_encoding])

Updates the cipher with `data`, the encoding of which is given in
@@ -213,6 +233,11 @@ Class for decrypting data.

Returned by `crypto.createDecipher` and `crypto.createDecipheriv`.

Decipher objects are [streams](stream.html) that are both readable and
writable. The written enciphered data is used to produce the
plain-text data on the the readable side. The legacy `update` and
`final` methods are also supported.

### decipher.update(data, [input_encoding], [output_encoding])

Updates the decipher with `data`, which is encoded in `'binary'`,
@@ -246,28 +271,33 @@ Creates and returns a signing object, with the given algorithm. On
recent OpenSSL releases, `openssl list-public-key-algorithms` will
display the available signing algorithms. Examples are `'RSA-SHA256'`.

## Class: Signer
## Class: Sign

Class for generating signatures.

Returned by `crypto.createSign`.

### signer.update(data)
Sign objects are writable [streams](stream.html). The written data is
used to generate the signature. Once all of the data has been
written, the `sign` method will return the signature. The legacy
`update` method is also supported.

### sign.update(data)

Updates the signer object with data. This can be called many times
Updates the sign object with data. This can be called many times
with new data as it is streamed.

### signer.sign(private_key, [output_format])
### sign.sign(private_key, [output_format])

Calculates the signature on all the updated data passed through the
signer. `private_key` is a string containing the PEM encoded private
sign. `private_key` is a string containing the PEM encoded private
key for signing.

Returns the signature in `output_format` which can be `'binary'`,
`'hex'` or `'base64'`. If no encoding is provided, then a buffer is
returned.

Note: `signer` object can not be used after `sign()` method been
Note: `sign` object can not be used after `sign()` method been
called.

## crypto.createVerify(algorithm)
@@ -281,6 +311,12 @@ Class for verifying signatures.

Returned by `crypto.createVerify`.

Verify objects are writable [streams](stream.html). The written data
is used to validate against the supplied signature. Once all of the
data has been written, the `verify` method will return true if the
supplied signature is valid. The legacy `update` method is also
supported.

### verifier.update(data)

Updates the verifier object with data. This can be called many times
@@ -469,9 +505,6 @@ default, set the `crypto.DEFAULT_ENCODING` field to 'binary'. Note
that new programs will probably expect buffers, so only use this as a
temporary measure.

Also, a Streaming API will be provided, but this will be done in such
a way as to preserve the legacy API surface.


[createCipher()]: #crypto_crypto_createcipher_algorithm_password
[createCipheriv()]: #crypto_crypto_createcipheriv_algorithm_key_iv