Browse Source

Merge remote-tracking branch 'origin/v0.10' into master

Conflicts:
	doc/api/buffer.markdown
	lib/_stream_readable.js
	lib/assert.js
	lib/buffer.js
	lib/child_process.js
	lib/http.js
	lib/string_decoder.js
	lib/zlib.js
	node.gyp
	test/simple/test-buffer.js
	test/simple/test-https-foafssl.js
	test/simple/test-stream2-compatibility.js
	test/simple/test-tls-server-verify.js
archived-io.js-v0.10
Fedor Indutny 11 years ago
parent
commit
f310c0f16b
  1. 2
      configure
  2. 16
      doc/api/buffer.markdown
  3. 11
      doc/api/console.markdown
  4. 4
      doc/api/crypto.markdown
  5. 3
      doc/api/modules.markdown
  6. 5
      lib/_stream_readable.js
  7. 2
      lib/assert.js
  8. 2
      lib/buffer.js
  9. 2
      lib/net.js
  10. 7
      lib/zlib.js
  11. 2
      node.gyp
  12. 11
      src/node_constants.cc
  13. 1
      test/simple/test-https-foafssl.js
  14. 58
      test/simple/test-stream2-base64-single-char-read-end.js
  15. 25
      test/simple/test-zlib-write-after-close.js

2
configure

@ -473,6 +473,8 @@ def configure_node(o):
if target_arch != host_arch and not options.without_snapshot:
o['variables']['want_separate_host_toolset'] = 1
else:
o['variables']['want_separate_host_toolset'] = 0
if target_arch == 'arm':
configure_arm(o)

16
doc/api/buffer.markdown

@ -37,6 +37,22 @@ encoding method. Here are the different string encodings.
* `'hex'` - Encode each byte as two hexadecimal characters.
Creating a typed array from a `Buffer` works with the following caveats:
1. The buffer's memory is copied, not shared.
2. The buffer's memory is interpreted as an array, not a byte array. That is,
`new Uint32Array(new Buffer([1,2,3,4]))` creates a 4-element `Uint32Array`
with elements `[1,2,3,4]`, not an `Uint32Array` with a single element
`[0x1020304]` or `[0x4030201]`.
NOTE: Node.js v0.8 simply retained a reference to the buffer in `array.buffer`
instead of cloning it.
While more efficient, it introduces subtle incompatibilities with the typed
arrays specification. `ArrayBuffer#slice()` makes a copy of the slice while
`Buffer#slice()` creates a view.
## Class: Buffer
The Buffer class is a global type for dealing with binary data directly.

11
doc/api/console.markdown

@ -74,14 +74,15 @@ Finish timer, record output. Example:
}
console.timeEnd('100-elements');
## console.trace(label)
## console.trace(message, [...])
Print a stack trace to stderr of the current position.
Print to stderr `'Trace :'`, followed by the formatted message and stack trace
to the current position.
## console.assert(expression, [message])
## console.assert(value, [message], [...])
Same as [assert.ok()][] where if the `expression` evaluates as `false` throw an
AssertionError with `message`.
Similar to [assert.ok()][], but the error message is formatted as
`util.format(message...)`.
[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message
[util.format()]: util.html#util_util_format_format

4
doc/api/crypto.markdown

@ -188,8 +188,8 @@ 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.
the stream is ended, use the `read()` method to get the enciphered
contents. The legacy `update` and `final` methods are also supported.
## crypto.createCipheriv(algorithm, key, iv)

3
doc/api/modules.markdown

@ -385,7 +385,8 @@ in pseudocode of what require.resolve does:
LOAD_AS_FILE(X)
1. If X is a file, load X as JavaScript text. STOP
2. If X.js is a file, load X.js as JavaScript text. STOP
3. If X.node is a file, load X.node as binary addon. STOP
3. If X.json is a file, parse X.json to a JavaScript Object. STOP
4. If X.node is a file, load X.node as binary addon. STOP
LOAD_AS_DIRECTORY(X)
1. If X/package.json is a file,

5
lib/_stream_readable.js

@ -85,9 +85,6 @@ function ReadableState(options, stream) {
// if true, a maybeReadMore has been scheduled
this.readingMore = false;
// if true, stream is in old mode
this.oldMode = false;
this.decoder = null;
this.encoding = null;
if (options.encoding) {
@ -227,7 +224,7 @@ function howMuchToRead(n, state) {
if (state.objectMode)
return n === 0 ? 0 : 1;
if (isNaN(n) || util.isNull(n)) {
if (util.isNull(n) || isNaN(n)) {
// only flow one buffer at a time
if (state.flowing && state.buffer.length)
return state.buffer[0].length;

2
lib/assert.js

@ -60,7 +60,7 @@ function replacer(key, value) {
if (util.isUndefined(value)) {
return '' + value;
}
if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
if (util.isNumber(value) && !isFinite(value)) {
return value.toString();
}
if (util.isFunction(value) || util.isRegExp(value)) {

2
lib/buffer.js

@ -505,7 +505,7 @@ Buffer.prototype.readUInt32BE = function(offset, noAssert) {
return (this[offset] * 0x1000000) +
((this[offset + 1] << 16) |
(this[offset + 2] << 8) |
(this[offset + 3]) >>> 0);
this[offset + 3]);
};

2
lib/net.js

@ -305,7 +305,7 @@ Socket.prototype.listen = function() {
Socket.prototype.setTimeout = function(msecs, callback) {
if (msecs > 0 && !isNaN(msecs) && isFinite(msecs)) {
if (msecs > 0 && isFinite(msecs)) {
timers.enroll(this, msecs);
timers._unrefActive(this);
if (callback) {

7
lib/zlib.js

@ -403,6 +403,7 @@ Zlib.prototype.params = function(level, strategy, callback) {
if (this._level !== level || this._strategy !== strategy) {
var self = this;
this.flush(binding.Z_SYNC_FLUSH, function() {
assert(!self._closed, 'zlib binding closed');
self._handle.params(level, strategy);
if (!self._hadError) {
self._level = level;
@ -416,6 +417,7 @@ Zlib.prototype.params = function(level, strategy, callback) {
};
Zlib.prototype.reset = function() {
assert(!this._closed, 'zlib binding closed');
return this._handle.reset();
};
@ -476,6 +478,9 @@ Zlib.prototype._transform = function(chunk, encoding, cb) {
if (!util.isNull(chunk) && !util.isBuffer(chunk))
return cb(new Error('invalid input'));
if (this._closed)
return cb(new Error('zlib binding closed'));
// If it's the last chunk, or a final flush, we use the Z_FINISH flush flag.
// If it's explicitly flushing at some other time, then we use
// Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression
@ -512,6 +517,7 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
error = er;
});
assert(!this._closed, 'zlib binding closed');
do {
var res = this._handle.writeSync(flushFlag,
chunk, // in
@ -532,6 +538,7 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
return buf;
}
assert(!this._closed, 'zlib binding closed');
var req = this._handle.write(flushFlag,
chunk, // in
inOff, // in_off

2
node.gyp

@ -182,7 +182,7 @@
'./deps/openssl/openssl.gyp:openssl',
# For tests
'./deps/openssl/openssl.gyp:openssl-cli'
'./deps/openssl/openssl.gyp:openssl-cli',
],
}]]
}, {

11
src/node_constants.cc

@ -19,24 +19,15 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// O_NONBLOCK is not exported unless _XOPEN_SOURCE >= 500.
#if defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 500
#undef _XOPEN_SOURCE
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE 500
#endif
#include "node_constants.h"
#include "uv.h"
#include <errno.h>
#include <fcntl.h>
#if !defined(_MSC_VER)
#include <unistd.h>
#endif
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>

1
test/simple/test-https-foafssl.js

@ -31,6 +31,7 @@ var join = require('path').join;
var fs = require('fs');
var spawn = require('child_process').spawn;
var https = require('https');
var options = {

58
test/simple/test-stream2-base64-single-char-read-end.js

@ -0,0 +1,58 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common.js');
var R = require('_stream_readable');
var W = require('_stream_writable');
var assert = require('assert');
var src = new R({encoding: 'base64'});
var dst = new W();
var hasRead = false;
var accum = [];
var timeout;
src._read = function(n) {
if(!hasRead) {
hasRead = true;
process.nextTick(function() {
src.push(new Buffer('1'));
src.push(null);
});
};
};
dst._write = function(chunk, enc, cb) {
accum.push(chunk);
cb();
};
src.on('end', function() {
assert.equal(Buffer.concat(accum) + '', 'MQ==');
clearTimeout(timeout);
})
src.pipe(dst);
timeout = setTimeout(function() {
assert.fail('timed out waiting for _write');
}, 100);

25
test/simple/test-stream-readable-data-sync-race.js → test/simple/test-zlib-write-after-close.js

@ -19,23 +19,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var common = require('../common.js');
var assert = require('assert');
var zlib = require('zlib');
var Readable = require('stream').Readable;
var closed = false;
var r = new Readable();
var errors = 0;
// Setting `data` listener should not trigger `_read()` calls before we will
// set the `error` listener below
r.on('data', function() {
});
r.on('error', function() {
errors++;
zlib.gzip('hello', function(err, out) {
var unzip = zlib.createGunzip();
unzip.close(function() {
closed = true;
});
assert.throws(function() {
unzip.write(out);
});
});
process.on('exit', function() {
assert.equal(errors, 1);
assert(closed);
});
Loading…
Cancel
Save