Browse Source

Merge remote-tracking branch 'ry/v0.10'

Conflicts:
	lib/tls.js
v0.11.6-release
isaacs 12 years ago
parent
commit
cdf2a661f2
  1. 21
      deps/http_parser/http_parser.c
  2. 18
      deps/http_parser/test.c
  3. 23
      doc/api/dgram.markdown
  4. 22
      doc/api/process.markdown
  5. 6
      doc/api/stream.markdown
  6. 9
      lib/_tls_legacy.js
  7. 2
      lib/fs.js
  8. 26
      test/simple/test-fs-read-stream.js

21
deps/http_parser/http_parser.c

@ -936,6 +936,7 @@ size_t http_parser_execute (http_parser *parser,
} else if (parser->index == 2 && ch == 'P') {
parser->method = HTTP_COPY;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else if (parser->method == HTTP_MKCOL) {
@ -948,12 +949,14 @@ size_t http_parser_execute (http_parser *parser,
} else if (parser->index == 2 && ch == 'A') {
parser->method = HTTP_MKACTIVITY;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else if (parser->method == HTTP_SUBSCRIBE) {
if (parser->index == 1 && ch == 'E') {
parser->method = HTTP_SEARCH;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else if (parser->index == 1 && parser->method == HTTP_POST) {
@ -964,13 +967,27 @@ size_t http_parser_execute (http_parser *parser,
} else if (ch == 'A') {
parser->method = HTTP_PATCH;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else if (parser->index == 2) {
if (parser->method == HTTP_PUT) {
if (ch == 'R') parser->method = HTTP_PURGE;
if (ch == 'R') {
parser->method = HTTP_PURGE;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else if (parser->method == HTTP_UNLOCK) {
if (ch == 'S') parser->method = HTTP_UNSUBSCRIBE;
if (ch == 'S') {
parser->method = HTTP_UNSUBSCRIBE;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
} else if (parser->index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') {
parser->method = HTTP_PROPPATCH;

18
deps/http_parser/test.c

@ -3117,14 +3117,8 @@ main (void)
/// REQUESTS
test_simple("hello world", HPE_INVALID_METHOD);
test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION);
test_simple("ASDF / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD);
test_simple("PROPPATCHA / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD);
test_simple("GETA / HTTP/1.1\r\n\r\n", HPE_INVALID_METHOD);
// Well-formed but incomplete
test_simple("GET / HTTP/1.1\r\n"
"Content-Type: text/plain\r\n"
@ -3167,13 +3161,23 @@ main (void)
}
static const char *bad_methods[] = {
"ASDF",
"C******",
"COLA",
"GEM",
"GETA",
"M****",
"MKCOLA",
"PROPPATCHA",
"PUN",
"PX",
"SA",
"hello world",
0 };
for (this_method = bad_methods; *this_method; this_method++) {
char buf[200];
sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method);
test_simple(buf, HPE_UNKNOWN);
test_simple(buf, HPE_INVALID_METHOD);
}
const char *dumbfuck2 =

23
doc/api/dgram.markdown

@ -132,13 +132,21 @@ informing the source that the data did not reach its intended recipient).
* `port` Integer
* `address` String, Optional
* `callback` Function, Optional
* `callback` Function with no parameters, Optional. Callback when
binding is done.
For UDP sockets, listen for datagrams on a named `port` and optional `address`.
If `address` is not specified, the OS will try to listen on all addresses.
For UDP sockets, listen for datagrams on a named `port` and optional
`address`. If `address` is not specified, the OS will try to listen on
all addresses. After binding is done, a "listening" event is emitted
and the `callback`(if specified) is called. Specifying both a
"listening" event listener and `callback` is not harmful but not very
useful.
The `callback` argument, if provided, is added as a one-shot `'listening'`
event listener.
A bound datagram socket keeps the node process running to receive
datagrams.
If binding fails, an "error" event is generated. In rare case (e.g.
binding a closed socket), an `Error` may be thrown by this method.
Example of a UDP server listening on port 41234:
@ -146,6 +154,11 @@ Example of a UDP server listening on port 41234:
var server = dgram.createSocket("udp4");
server.on("error", function (err) {
console.log("server error:\n" + err.stack);
server.close();
});
server.on("message", function (msg, rinfo) {
console.log("server got: " + msg + " from " +
rinfo.address + ":" + rinfo.port);

22
doc/api/process.markdown

@ -167,6 +167,28 @@ Example:
/usr/local/bin/node
## process.execArgv
This is the set of node-specific command line options from the
executable that started the process. These options do not show up in
`process.argv`, and do not include the node executable, the name of
the script, or any options following the script name. These options
are useful in order to spawn child processes with the same execution
environment as the parent.
Example:
$ node --harmony script.js --version
results in process.execArgv:
['--harmony']
and process.argv:
['/usr/local/bin/node', 'script.js', '--version']
## process.abort()
This causes node to emit an abort. This will cause node to exit and

6
doc/api/stream.markdown

@ -1085,8 +1085,8 @@ connected in some way to the input, such as a [zlib][] stream or a
There is no requirement that the output be the same size as the input,
the same number of chunks, or arrive at the same time. For example, a
Hash stream will only ever have a single chunk of output which is
provided when the input is ended. A zlib stream will either produce
much smaller or much larger than its input.
provided when the input is ended. A zlib stream will produce output
that is either much smaller or much larger than its input.
Rather than implement the [`_read()`][] and [`_write()`][] methods, Transform
classes must implement the `_transform()` method, and may optionally
@ -1174,7 +1174,7 @@ approach.
```javascript
var util = require('util');
var Transform = require('stream').Transform);
var Transform = require('stream').Transform;
util.inherits(SimpleProtocol, Transform);
function SimpleProtocol(options) {

9
lib/_tls_legacy.js

@ -268,7 +268,14 @@ CryptoStream.prototype._read = function read(size) {
// Get NPN and Server name when ready
this.pair.maybeInitFinished();
} while (read > 0 && !this._buffer.isFull && bytesRead < size);
// `maybeInitFinished()` can emit the 'secure' event which
// in turn destroys the connection in case of authentication
// failure and sets `this.pair.ssl` to `null`.
} while (read > 0 &&
!this._buffer.isFull &&
bytesRead < size &&
this.pair.ssl !== null);
// Create new buffer if previous was filled up
var pool = this._buffer.pool;

2
lib/fs.js

@ -1465,7 +1465,7 @@ ReadStream.prototype.open = function() {
var self = this;
fs.open(this.path, this.flags, this.mode, function(er, fd) {
if (er) {
if (this.autoClose) {
if (self.autoClose) {
self.destroy();
}
self.emit('error', er);

26
test/simple/test-fs-read-stream.js

@ -171,10 +171,6 @@ function file7Next(){
});
file7.on('end', function(err) {
assert.equal(file7.data, 'xyz\n');
process.nextTick(function() {
assert(file7.closed);
assert(file7.destroyed);
});
});
}
@ -182,10 +178,20 @@ function file7Next(){
var file8 = fs.createReadStream(null, {fd: 13337, autoClose: false });
file8.on('data', function() {});
file8.on('error', common.mustCall(function() {}));
file8.on('end', function() {
process.nextTick(function() {
assert(!file8.closed);
assert(!file8.destroyed);
assert(file8.fd);
});
// Make sure stream is destroyed when file does not exist.
var file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
file9.on('data', function() {});
file9.on('error', common.mustCall(function() {}));
process.on('exit', function() {
assert(file7.closed);
assert(file7.destroyed);
assert(!file8.closed);
assert(!file8.destroyed);
assert(file8.fd);
assert(!file9.closed);
assert(file9.destroyed);
});

Loading…
Cancel
Save