0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

2840 Commits

Author SHA1 Message Date
Gabriel Wicke
b705b73e46 url: make query() consistent
Match the behavior of the slow path by setting url.query to an empty
object when the url contains no query, but query parsing is requested.

Also add a test for this case, and update the documents to clearly
reflect this behavior.

Fixes: https://github.com/joyent/node/issues/8332
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-10-01 12:23:01 -07:00
Trevor Norris
57ed3daebf buffer: fix and cleanup fill()
Running fill() with an empty string would cause Node to hang
indefinitely. Now it will return without having operated on the buffer.

User facing function has been pulled into JS to perform all initial
value checks and coercions. The C++ method has been placed on the
"internal" object.

Coerced non-string values to numbers to match v0.10 support.

Simplified logic and changed a couple variable names.

Added tests for fill() and moved them all to the beginning of
buffer-test.js since many other tests depend on fill() working properly.

Fixes: https://github.com/joyent/node/issues/8469
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-29 17:36:03 -07:00
Trevor Norris
979d0ca874 http: cleanup setHeader()
Several fields on OutgoingMessage were set after instantiation. These
have been included in the constructor to prevent mutation of the object
map after instantiation.

"name" is now explicitly checked to be a string. Where before if a
non-string was passed the following cryptic error was thrown:

    _http_outgoing.js:334
      var key = name.toLowerCase();
                     ^
    TypeError: undefined is not a function

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-29 12:32:42 -07:00
cjihrig
9d95774722 child_process: improve spawn() argument handling
Add stricter argument type checking to normalizeSpawnArguments().

Removes a number of extraneous checks in spawn().

Fix regression in handling of the optional args argument.

Add more thorough testing of spawn() arguments.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-25 15:13:14 -07:00
Patrick Mooney
b26dd4e5ab net: Make server.connections un-enumerable
The property server.connections should no longer be enumerable because
it has been deprecated. This will prevent deprecation warnings when
server objects are accessed by functions such as JSON.stringify.

Fixes: https://github.com/joyent/node/issues/8373
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-24 16:06:46 -07:00
Timothy J Fontaine
f773fb41cc test: disable dgram-bind-shared-ports on win32
Windows currently doesn't support clustered dgram sockets, when it does
re-enable this test
2014-09-24 14:17:42 -07:00
Julien Gilli
2f7234d89c tests: add test for buffer.slice.
4c9b30d introduced a regression in buffer.slice that 7c3c51b fixed, but
no test had been added to make sure that a similar regression is caught
by the tests suite in the future.
2014-09-24 09:48:41 -07:00
Julien Gilli
64d6de9f34 http: write() after end() emits an error.
When calling write() after end() has been called on an OutgoingMessage,
an error is emitted and the write's callback is called with an instance
of Error.

Fix #7477.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-23 11:54:26 +04:00
Vladimir Kurchatkin
30bd7b672c node: support v8 microtask queue
When V8 started supporting Promises natively it also introduced a
microtack queue. This feature operates similar to process.nextTick(),
and created an issue where neither knew when the other had run. This
patch has nextTick() call the microtask queue runner at the end of
processing callbacks in the nextTickQueue.

Fixes: https://github.com/joyent/node/issues/7714
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-18 14:13:06 -07:00
Julien Gilli
9c992bdb75 test: add test for cluster.worker.destroy()
Add a simple test to cover workers' implementation of
Worker.prototype.destroy(). Before adding this test, this code wouldn't
be covered by the tests suite, and any regression introduced in workers'
implementation of Worker.prototype.destroy wouldn't be caught.

Fixes: https://github.com/joyent/node/issues/8223
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-18 14:06:21 -07:00
Timothy J Fontaine
7ca5af87a0 Merge remote-tracking branch 'upstream/v0.10' into v0.12
Conflicts:
	ChangeLog
	deps/v8/src/hydrogen.cc
	lib/http.js
	lib/querystring.js
	src/node_crypto.cc
	src/node_version.h
	test/simple/test-querystring.js
2014-09-16 17:48:09 -07:00
Fedor Indutny
1fddc1fee8 http: do not send 0\r\n\r\n in TE HEAD responses
When replying to a HEAD request, do not attempt to send the trailers and
EOF sequence (`0\r\n\r\n`). The HEAD request MUST not have body.

Quote from RFC:

The presence of a message body in a response depends on both the
request method to which it is responding and the response status code
(Section 3.1.2).  Responses to the HEAD request method (Section 4.3.2
of [RFC7231]) never include a message body because the associated
response header fields (e.g., Transfer-Encoding, Content-Length,
etc.), if present, indicate only what their values would have been if
the request method had been GET (Section 4.3.1 of [RFC7231]).

fix #8361

Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
2014-09-16 15:24:19 -07:00
Chris Dickinson
6e689ece46 crypto: use domains for any callback-taking method
This adds domains coverage for pdbkdf2, pseudoRandomBytes, and randomBytes.
All others should be covered by event emitters.

Fixes #5801.

Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
2014-09-16 15:23:04 -07:00
Ben Noordhuis
21e60643b0 lib, src: add vm.runInDebugContext()
Compiles and executes source code in V8's debugger context.  Provides
a programmatic way to get access to the debug object by executing:

    var Debug = vm.runInDebugContext('Debug');

Fixes #7886.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-16 12:28:47 -07:00
Maciej Małecki
174f7d2820 dns: include host name in error message if available
This makes errors more readable and similar to FS errors, which also
include file name.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-16 15:32:04 +04:00
Adam Lippai
11d57a535c tls: fix encoding in certificate-related functions
Strings are treated as UTF8 instead of one-byte strings when
names are processed and when OpenSSL's ..._print functions are used.

This commit fixes simple/test-tls-peer-certificate-encoding test.

fix #8366
2014-09-15 17:42:20 +04:00
Trevor Livingston
bf5e2f246e tls: checkServerIdentity option
Allow overriding `checkServerIdentity` function, when connecting to a
TLS server.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-09 17:15:50 +01:00
cjihrig
86bb7fa5cd test: listen on exclusive port in cluster workers
Test that listening on exclusive ports with the cluster module works
correctly.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-04 15:18:48 -07:00
cjihrig
029cfc12a0 net,dgram: workers can listen on exclusive ports
Allow cluster workers to listen on exclusive ports for TCP and UDP,
instead of forcing all calls to go through the cluster master.

Fixes: #3856
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
2014-09-03 15:16:16 -07:00
Fedor Indutny
73631bbcc8 tls: support multiple keys/certs
Required to serve website with both ECDSA/RSA certificates.
2014-09-03 17:36:54 +04:00
Trevor Norris
81a9739108 node,async-wrap: verify domain enter/exit are set
The REPL global object lazy loads modules by placing getters for each.
This causes MakeDomainCallback() to be run if a native module is loaded
from the REPL, but if the domain module hasn't been loaded then there
are no enter/exit callbacks to be called. Causing an assert() to fail.

Fix the issue by conditionally running the callback instead of asserting
it is available. Also add "addon" test to verify the fix.

Fixes: #8231
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-02 11:30:45 -07:00
Julien Gilli
8e60b4523c tests: add test for non-integer delay timers.
PR #8034 came with a test to make sure that timers expiry is based on
monotonic time and not on wall-clock time. However, a bug in the
implementation broke timers with non-integer delays. A fix for this
issue was provided with PR #8073, but it didn't come with a test.

Because #8073 fixed a subtle issue that could reappear in the future,
and because the impact of such an issue would be significant, I suggest
adding this test.

The test would timeout after 1 minute if the issue was reproduced.
Otherwise it will run very quickly.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 22:22:57 +04:00
Julien Gilli
90d1147b8b cluster: centralize removal from workers list.
Currently, cluster workers can be removed from the workers list in three
different places:
- In the exit event handler for the worker process.
- In the disconnect event handler of the worker process.
- In the disconnect event handler of the cluster master.

However, handles for a given worker are cleaned up only in one of these
places: in the cluster master's disconnect event handler.

Because these events happen asynchronously, it is possible that the
workers list is empty before we even clean up one handle. This makes
the assert that makes sure that no handle is left when the workers
list is empty fail.

This commit removes the worker from the cluster.workers list only when
the worker is dead _and_ disconnected, at which point we're sure that
its associated handles are cleaned up.

Fixes #8191 and #8192.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 22:14:04 +04:00
Shigeki Ohtsu
0dfedb7127 tls, crypto: add DHE support
In case of an invalid DH parameter file, it is sliently discarded. To
use auto DH parameter in a server and DHE key length check in a
client, we need to wait for the next release of OpenSSL-1.0.2.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-29 00:36:48 +04:00
Fedor Indutny
6e453fad87 crypto: introduce ECDH 2014-08-29 00:27:09 +04:00
Tristan Berger
0f2956192c querystring: fix unescape override
Documentation states that `querystring.unescape` may be overridden to
replace unescaper during parsing. However, the function was only
being used as a fallback for when the native decoder throws (on a
malformed URL). This patch moves the call to the native function and
the try/catch around it into querystring.unescape then has the parser
always invoke it, so that an override will always be used.

Fixes #4055

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-27 13:49:16 +04:00
Fedor Indutny
6adf3ecebb crypto: allow padding in RSA methods
Reviewed-By: Trevor Norris <trevnorris@gmail.com>
2014-08-27 00:24:57 +04:00
Chris Dickinson
4ef2a5a672 net,stream: add isPaused, don't read() when paused
net Sockets were calling read(0) to start reading, without
checking to see if they were paused first. This would result
in paused Socket objects keeping the event loop alive.

Fixes #8200

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-20 13:58:12 -07:00
cjihrig
5086d6ef94 dns: throw if hostname is not string or falsey
Fix assertion failure from poor argument parsing logic introduced in
6ea5d16. Add tests to make sure arguments are properly parsed.

Fixes: 6ea5d16 "dns: always set variable family in lookup()"
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-20 13:51:09 -07:00
Alexis Campailla
0d357fa135 test: fix dns test
Fix a few issues in test/internet/test-dns.js:
- 'hint' should be 'hints'
- reverse name lookup is not guaranteed to return 'localhost'
- V4MAPPED hint requires IPV6 address family

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:44:20 -07:00
Julien Gilli
0565d52a71 tests: don't assume IPv4 only in remote addr tests
Tests in test-net-remote-address-port.js assume that client and server
sockets always use IPv4. However, depending on the OS and the network
interfaces setup, this is not true. This change makes the test consider
that both IPv4 or IPv6 sockets are valid

Fixes #8096.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:44:15 -07:00
Fedor Indutny
c7b42fe2e5 test: check ipv6 support before testing it
fix #7983
fix #8049

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:43:58 -07:00
Julien Gilli
f5f5bd76e6 tests: do not hardcode service name in test-dns.
Instead of hard-coding http service name in test-dns, retrieve it from
/etc/services. This is not ideal, but it's still better than hard-coding
it.

Fixes #8047.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:43:41 -07:00
Julien Gilli
7d1860a678 tests: fix invalid hints flags dns test.
1 is actually a valid flag on SmartOS. More generally, hints flags'
values are defined by the underlying native flags, and these can have
different values on different systems.

Using (ADDRCONFIG | V4MAPPED) + 1 ensure that the flag will be invalid,
since it will always be different from ADDRCONFIG, V4MAPPED, ADDRCONFIG
| V4MAPPED,  0 and any other combination of even flags.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:43:09 -07:00
Ezequiel Rabinovich
678ead2608 querystring: remove prepended ? from query field
Fixes an issue that caused the first querystring to be parsed prepending
a "?" in the first variable name on relative urls with no #fragment

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 20:38:30 -07:00
seishun
42bda05af8 crypto: add RSA encryption
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-11 22:00:34 +04:00
Alexis Campailla
2a415358ee test: fix test-process-kill-pid on Windows
Disabling the part of the test that relies on dispatching SIGHUP,
because sending SIGHUP is not supported on Windows.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-07 17:22:53 -07:00
Timothy J Fontaine
a5778cdf01 Merge remote-tracking branch 'upstream/v0.10' into v0.12
Conflicts:
	ChangeLog
	Makefile
	deps/uv/ChangeLog
	deps/uv/build.mk
	deps/uv/src/unix/darwin.c
	deps/uv/src/unix/getaddrinfo.c
	deps/uv/src/version.c
	deps/v8/src/checks.h
	deps/v8/src/isolate.h
	lib/cluster.js
	lib/module.js
	lib/timers.js
	lib/tls.js
	src/node_version.h
2014-08-07 16:33:35 -07:00
Julien Gilli
b0277f35bd tests: fix child-process-fork-dgram on SmartOS.
Send messages until both the parent and the child process have received
at least one message. If at least one of them doesn't receive any
message, the test runner will make the test timeout.

Fixes #8046.
2014-08-07 16:06:59 -07:00
Jackson Tian
63a4268218 fs: fs.readFile should not throw uncaughtException
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-05 16:13:07 +04:00
cjihrig
430678640c net: don't prefer IPv4 addresses during resolution
Currently the address resolution family defaults to IPv4. Instead remove
the preference and instead resolve to a family suitable for the host.

Expose the getaddrinfo flags and allow them to be passed.

Add documentation about new flags.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-04 16:57:18 -07:00
Julien Gilli
7da63a10ac test: fix test-net-remote-address-port
Do not use first socket in second socket's connect handler. Probably a
copy/paste mistake.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-04 13:48:19 -07:00
Julien Gilli
6f043940bd timers: fix timers with non-integer delay hanging.
When backporting f8193ab into v0.10, a regression was introduced. Timers
with non-integer timeout could trigger a infinite recursion with 100%
cpu usage. This commit backports 93b0624 which fixes the regression.

After backporting f8193ab, instead of using Date.now(), timers would use
Timer.now() to determine if they had expired. However, Timer.now() is
based on loop->time, which is not updated when a timer's remaining time
is > 0 and < 1. Timers would thus never timeout if their remaining time
was at some point > 0 and < 1.

With this commit, Timer.now() updates loop->time itself, and timers
always timeout eventually.

Fixes #8065 and #8068.
2014-08-04 12:00:40 -07:00
Jackson Tian
962e651476 process: improve process binding
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-02 20:14:46 +04:00
Fedor Indutny
47a103a029 test: disable 0-dgram tests on darwin
fix #8023
2014-08-02 15:07:07 +04:00
Sam Roberts
2fd7ee12d9 cluster: disconnect should not be synchronous
Callbacks in node are usually asynchronous, and should never be
sometimes synchronous, and sometimes asynchronous.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-02 00:41:13 -07:00
Sam Roberts
aab126bb06 test: assert cluster.disconnect is async
See joyent/node#8043, test passed on v0.11 already, but this makes the
test stronger.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-02 00:07:18 -07:00
James Halliday
8e2cc69e78 stream: fix Readable.wrap objectMode falsy values
A streams1 stream will have its falsy values such as 0, false, or ""
eaten by the upgrade to streams2, even when objectMode is enabled.

Include test for said cases.

Reviewed-by: isaacs <i@izs.me>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-01 13:01:23 -07:00
cjihrig
d287b8e58a cluster: support options in Worker constructor
This commit moves some common Worker code into the constructor
via support for an options argument.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-01 00:34:40 +04:00
Julien Gilli
befbbad051 timers: backport f8193ab
Original commit message:

 timers: use uv_now instead of Date.now

 This saves a few calls to gettimeofday which can be expensive, and
 potentially subject to clock drift. Instead use the loop time which
 uses hrtime internally.

In addition to the backport, this commit:
 - keeps _idleStart timers' property which is still set to
   Date.now() to avoid breaking existing code that uses it, even if
   its use is discouraged.
 - adds automated tests. These tests use a specific branch of
   libfaketime that hasn't been submitted upstream yet. libfaketime
   is git cloned if needed when running automated tests.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-07-31 08:53:24 -07:00