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

2262 Commits

Author SHA1 Message Date
isaacs
0678480b57 streams2: Allow Writables to opt out of pre-buffer-izing 2012-12-13 17:00:27 -08:00
isaacs
545f512619 streams2: ctor guards on Stream classes 2012-12-13 17:00:26 -08:00
isaacs
8acb416ad0 streams2: Handle immediate synthetic transforms properly 2012-12-13 17:00:26 -08:00
isaacs
06e321d0f9 streams2: Correct drain/return logic
It was testing the length *before* adding the current chunk, which
is the opposite of correct.

Also, the return value was flipped.
2012-12-13 17:00:25 -08:00
isaacs
02f017d24f streams2: Allow 0 as a lowWaterMark value 2012-12-13 17:00:25 -08:00
isaacs
caa853bb06 transform: Automatically read() on _write when read buffer is empty 2012-12-13 17:00:25 -08:00
isaacs
3b59fd70f4 streams2: Make Transform streams pull-style
That is, the transform is triggered by a _read, not by a _write.

This way, backpressure works properly.
2012-12-13 17:00:24 -08:00
isaacs
9b5abe5bfe streams2: setEncoding and abstract out endReadable 2012-12-13 17:00:24 -08:00
isaacs
51a52c43a2 streams2: Set flowing=true when flowing 2012-12-13 17:00:24 -08:00
isaacs
639fbe28d1 streams2: Convert strings to buffers before passing to _write() 2012-12-13 17:00:23 -08:00
isaacs
420e07c577 streams2: The new stream base classes 2012-12-13 17:00:23 -08:00
isaacs
17834ed28c Add 'stream' as a native module in repl 2012-12-13 17:00:23 -08:00
isaacs
314c6b3060 Don't allow invalid encodings in StringDecoder class 2012-12-13 17:00:22 -08:00
isaacs
77ed12fe7a Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/test/test-spawn.c
	deps/uv/uv.gyp
	src/cares_wrap.cc
	src/node.cc
	src/node_version.h
	test/simple/test-buffer.js
	tools/gyp/pylib/gyp/common.py
	tools/install.py
2012-12-13 16:57:58 -08:00
Ben Noordhuis
d65832ccd0 fs: fix WriteStream fd leak
Close the file descriptor when a write operation fails.

Fixes #4387.
2012-12-12 09:46:22 +01:00
Ben Noordhuis
6e97b2cc17 fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.

Fixes #4387.
2012-12-12 09:46:22 +01:00
Ryunosuke SATO
0506d294dc events: fix typos in code comment
- newListeners -> newListener
2012-12-10 13:08:26 +01:00
Ryunosuke SATO
eb502205d5 events: setMaxListeners() should not have side effects
This object initialization has been unnecessary since 12cf730b.

Ref #3803.
2012-12-10 13:07:35 +01:00
Ryunosuke SATO
1c7acd2c84 events: use assigned variable instead of arguments
Always `arguments[0]` is used when `EventEmitter#emit` called.
Using assigned variable is faster than `arguments[0]`.
2012-12-10 13:04:46 +01:00
Ryunosuke SATO
0397223ab4 events: use null assignment instead of deleting property 2012-12-10 08:59:14 +01:00
Bert Belder
3c293ba272 http: protect against response splitting attacks 2012-12-07 17:13:51 -08:00
isaacs
0e95ea42ce lint
introduced in 5b65638.
2012-12-07 16:58:16 -08:00
isaacs
33fa740577 fs: Raise error when null bytes detected in paths
Reworking of @bnoordhuis's more aggressive approach.
2012-12-07 16:52:46 -08:00
Ben Noordhuis
5b65638124 tls, https: add tls handshake timeout
Don't allow connections to stall indefinitely if the SSL/TLS handshake does
not complete.

Adds a new tls.Server and https.Server configuration option, handshakeTimeout.

Fixes #4355.
2012-12-06 17:39:24 +01:00
Ben Noordhuis
1f76a2eddc fs: add long stacktrace debugging facility
Enable long stacktraces if NODE_DEBUG=fs is set in the environment. Only
applies to the default rethrow callback; it's to help you find places where
you forgot to pass in a callback.
2012-12-04 08:12:12 +01:00
Ben Noordhuis
a80434736b fs: fix 'object is not a function' callback errors
Use a default callback if the user omitted one. Avoids errors like the one
below:

  fs.js:777
      if (err) return callback(err);
                      ^
  TypeError: object is not a function
          at fs.appendFile (fs.js:777:21)
          at Object.oncomplete (fs.js:297:15)

This commit fixes the behavior of fs.lchmod(), fs.lchown() and fs.readFile()
when the callback is omitted. Before, they silently swallowed errors.

Fixes #4352.
2012-12-04 08:05:55 +01:00
Trevor Norris
6772308883 buffer: Don't double-negate numeric buffer arg
Fix #4331

Using double negate forces values into 32bit space. Because of this
Math.ceil needs to be used. Since NaN comparisons are always false, use
that to our advantage to return 0 if it is.

Also added two tests to verify the changes.
2012-11-30 16:23:49 -08:00
Joshua Erickson
c9f2531ae0 net: More accurate IP address validation and IPv6 dotted notation.
* Added isIP method to make use of inet_pton to cares_wrap.cc
* Modified net.isIP() to make use of new C++ isIP method.
* Added new tests to test-net-isip.js.

This is a back-port of commit fb6377e from the master branch.
2012-11-28 21:51:27 +01:00
Ben Noordhuis
121ed91331 tls: fix tls.connect() resource leak
The 'secureConnect' event listener was attached with .on(), which blocked it
from getting garbage collected. Use .once() instead.

Fixes #4308.
2012-11-26 01:51:05 +01:00
Ben Noordhuis
4cb17cb219 net: fix net.connect() resource leak
The 'connect' event listener was attached with .on(), which blocked it from
getting garbage collected. Use .once() instead.

Fixes #4308.
2012-11-24 15:27:14 +01:00
Scott Blomquist
f657ce685d windows: add tracing with performance counters
Patch by Henry Rawas and Scott Blomquist.
2012-11-21 01:21:53 +01:00
Bert Belder
bc9388342f windows: fix normalization of UNC paths 2012-11-21 01:21:25 +01:00
Ben Noordhuis
b6e989759b repl: don't interpret floating point numbers
Don't interpret floating point numbers, e.g. ".1234", as REPL commands.

Fixes #4268.
2012-11-10 18:21:17 +01:00
Trevor Norris
13c5db9771 buffer: remove duplicate assertion tests
Many assertion tests are duplicated in buffer.js. These few could be easily
removed and still have all tests pass.
2012-11-10 02:11:04 +01:00
Nathan Rajlich
5e4e87ade5 os: add os.endianness() function 2012-11-08 12:31:45 -08:00
Nathan Rajlich
3c91a7ae10 readline: use a "string_decoder" to parse "keypress" events
While updating the readline test cases to test both "terimal: false" and
"terminal: true" mode, it turned out that the test case testing utf8 chars
being sent over multiple write() calls was failing. The solution is to use
a string_decoder instance when parsing the "keypress" events.
2012-11-06 16:28:30 -08:00
Nathan Rajlich
e95e095289 readline: don't emit "line" events with a trailing '\n' char
Before this commit, readline was inconsistent in whether or not it would emit
"line" events with or without the trailing "\n" included. When "terminal"
mode was true, then there would be no "\n", when it was false, then the "\n"
would be present. However, the trailing "\n" doesn't add much, and most of the
time people just end up stripping it manually.

Part of #4243.
2012-11-06 16:28:24 -08:00
Joshua Erickson
fb6377ebd0 net: More accurate IP address validation and IPv6 dotted notation.
* Added isIP method to make use of inet_pton to cares_wrap.cc
* Modified net.isIP() to make use of new C++ isIP method.
* Added new tests to test-net-isip.js.
2012-11-06 16:49:21 +01:00
Fedor Indutny
05882668f9 debugger: exit and kill child on SIGTERM or SIGHUP 2012-11-04 01:34:46 +01:00
Girish Ramakrishnan
2f03eaf76f doc: tls: rejectUnauthorized defaults to true after 35607f3a 2012-11-01 16:16:27 +01:00
isaacs
07d3b21f43 zlib: s/clear/close/ and match other close() semantics 2012-10-31 16:56:30 -07:00
J. Lee Coltrane
54d293da56 url: make url.format escape delimiters in path and query
`url.format` should escape ? and # chars in pathname, and # chars in
search, because they change the semantics of the operation otherwise.
Don't escape % chars, or anything else. (see: #4082)
2012-10-30 09:16:13 -07:00
Brandon Philips
19b87bbda0 tls: delete useless removeListener call
onclose was never attached to 'end' so this call to remove this listener
is useless.  Delete it.
2012-10-30 16:58:07 +01:00
Ben Noordhuis
570e4be932 zlib: reduce memory consumption, release early
In zlibBuffer(), don't wait for the garbage collector to reclaim the zlib memory
but release it manually. Reduces memory consumption by a factor of 10 or more
with some workloads.

Test case:

  function f() {
    require('zlib').deflate('xxx', g);
  }
  function g() {
    setTimeout(f, 5);
  }
  f();

Observe RSS memory usage with and without this commit. After 10,000 iterations,
RSS stabilizes at ~35 MB with this commit. Without, RSS is over 300 MB and keeps
growing.

Cause: whenever the JS object heap hits the high-water mark, the V8 GC sweeps
it clean, then tries to grow it in order to avoid more sweeps in the near
future. Rule of thumb: the bigger the JS heap, the lazier the GC can be.

A side effect of a bigger heap is that objects now live longer. This is harmless
in general but it affects zlib context objects because those are tied to large
buffers that live outside the JS heap, on the order of 16K per context object.

Ergo, don't wait for the GC to reclaim the memory - it may take a long time.

Fixes #4172.
2012-10-30 15:03:17 +01:00
isaacs
45a13d9674 events: Don't clobber pre-existing _events obj in EE ctor 2012-10-25 13:37:08 -07:00
isaacs
c7b2e29e5e events: Make the EventEmitter class monomorphic
Always add domain, _events, and _maxListeners properties, set to the
default values at first.

Leads to a very very slight perf improvement when using setMaxListeners,
or dealing with a lot of EE objects that don't have any listeners.
2012-10-25 07:51:05 -07:00
Ben Noordhuis
9b61f570d8 Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	configure
	deps/v8/build/common.gypi
2012-10-25 16:08:58 +02:00
Ben Noordhuis
de0303d3ad url: parse hostnames that start with - or _
Allow hostnames like '-lovemonsterz.tumblr.com' and '_jabber._tcp.google.com'.

Fixes #4177.
2012-10-25 01:06:00 +02:00
Bert Belder
f34f1e30a6 repl: call resume() after setRawMode()
Solves #4178, but does not fix the underlying issue
2012-10-24 02:52:18 +02:00
Bert Belder
6822488c93 repl: call resume() after setRawMode()
Solves #4178, but does not fix the underlying issue
2012-10-24 02:42:57 +02:00
isaacs
d7da20c812 crypto: pbkdf2 throws when no callback provided 2012-10-23 10:48:51 -07:00
isaacs
c87b524c5f crypto: Clean up buffer handling and DH methods 2012-10-23 10:48:51 -07:00
isaacs
76b0bdf720 crypto: Add crypto.DEFAULT_ENCODING (defaults to 'buffer')
This is a flag to make it easier for users to upgrade through the
breaking crypto change, and easier for us to switch it back if it's a
problem.

Explicitly set default encoding to 'buffer' in other tests, in case it
ever changes back.
2012-10-23 10:48:51 -07:00
isaacs
4266f5cf2e tls: Provide buffer to Connection.setSession 2012-10-23 10:48:50 -07:00
isaacs
bfb9d5bbe6 crypto: Binding only accepts buffers 2012-10-23 10:48:50 -07:00
isaacs
9901b69c8e crypto: Move encoding logic to JS, default=buffer
crypto: Hash and Hmac default to buffers

crypto: Move Cipher encoding logic to JS

crypto: Move Cipheriv encoding logic to JS

crypto: Move Decipher encoding logic to JS

crypto: Move Decipheriv into JS, default to buffers

crypto: Move Sign class to JS

crypto: Better encoding handling in Hash.update

crypto: Move Verify class to JS

crypto: Move DiffieHellman to JS, default to buffers

crypto: Move DiffieHellmanGroup to JS, default to buffers

Also, create a test for this feature
2012-10-23 10:22:42 -07:00
Soarez
72ce9baa75 streams: remove useless line
The removed line was removing a calllback that was never setup
in first place. 016afe2 forgot to remove this.
2012-10-21 22:58:14 +02:00
Nathan Rajlich
4b238b4c2a Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/test/runner-win.c
	doc/api/process.markdown
	lib/repl.js
	src/node_crypto.cc
	src/node_version.h
2012-10-13 16:16:56 -07:00
Ben Noordhuis
2fbf0612a1 crypto: sort return value of getCiphers/getHashes 2012-10-13 02:55:17 +02:00
Ben Noordhuis
14a6c4efb8 crypto: add crypto.getHashes() 2012-10-13 02:55:14 +02:00
Ben Noordhuis
f53441ab1f crypto: add crypto.getCiphers()
Returns a list of, unsurprisingly, the available ciphers.
2012-10-13 01:49:57 +02:00
Nathan Rajlich
b1e78cef09 repl: ensure each REPL instance gets its own "context"
Before there was this weird module-scoped "context" variable which seemingly
shared the "context" of subsequent REPL instances, unless ".clear" was invoked
inside the REPL. To be proper, we need to ensure that each REPL gets its own
"context" object. I literally don't know why this "sharing" behavior was in place
before, but it was just plain wrong.
2012-10-12 16:37:17 -07:00
Ben Noordhuis
61978f57e6 dgram: remove stale code 2012-10-13 01:27:15 +02:00
isaacs
8509073458 lint 2012-10-12 11:46:36 -07:00
isaacs
061f2075cf string_decoder: Add 'end' method, do base64 properly 2012-10-11 16:46:18 -07:00
Nathan Rajlich
4eb5399bb2 util: add a "customInspect" option to util.inspect()
For disabling calling the custom `inspect()` function when defined on an object
that is being inspected.
2012-10-10 14:40:36 -07:00
Nathan Rajlich
07774e6b95 util: make inspect() accept an "options" argument
Consolidates all the formatting options into an "options" object argument.
This is so that we don't have to be constantly remembering the order of
the arguments and so that we can add more formatting options easily.

Closes #4085.
2012-10-10 13:31:47 -07:00
Ben Noordhuis
0ad005852c https: fix renegotation attack protection
Listen for the 'clientError' event that is emitted when a renegotation attack
is detected and close the connection.

Fixes test/pummel/test-https-ci-reneg-attack.js
2012-10-09 16:38:00 +02:00
Ben Noordhuis
7394e89ff6 tls: remove dead code
Remove dead code. Forgotten in 76ddf06.
2012-10-09 16:32:51 +02:00
Aaditya Bhatia
c668185add cluster: make 'listening' handler see actual port
Make the 'listening' event handler in the master process see the actual port
that the worker bound to when the worker specified port 0, i.e. a random port.
2012-10-09 16:23:24 +02:00
Ricky Ng-Adam
8bd4590a31 buffer: include encoding value in exception when invalid
Encoding failures can be somewhat confusing, especially when they are due to
control flow frameworks auto-filling parameters from the previous step output
values to functions (such as toString and write) that developers don't expect
to take an encoding parameter. By outputting the value as part of the message,
should make it easier to track down these sort of bugs.
2012-10-09 16:18:26 +02:00
Bert Belder
5288ed75be windows: use USERPROFILE to get the user's home dir
Fixes #3461
Close #3462
Close #4093
2012-10-09 00:47:38 +02:00
Ben Noordhuis
76ddf06f10 tls: don't use a timer to track renegotiations
It makes tls.createSecurePair(null, true) hang until the timer expires.

Using a timer here is silly. Use a timestamp instead.
2012-10-08 02:23:46 +02:00
Nathan Rajlich
7611c7cd25 repl: dynamically lookup the require extensions for tab complete
Removes 2 TODO items
2012-10-07 11:33:33 -07:00
Nathan Rajlich
59c166cfba repl: move "isSyntaxError()" definition to the bottom
fixes lint "line length too long" error
2012-10-05 18:33:28 -07:00
isaacs
836a06fc4f Revert "http: make http.ServerResponse emit 'end'"
This reverts commit 790d651f0d.

This makes Duplex streams unworkable, and would only ever be a special
case for HTTP responses, which is not ideal.

Intead, we're going to just bless the 'finish' event for all Writable
streams in 0.10
2012-10-03 17:40:14 -07:00
koichik
016afe21ae streams: fix pipe is destructed by 'end' from destination 2012-10-03 10:57:31 -07:00
Paul Serby
41e53e5579 path: add platform specific path delimiter
Closes #3728
Closes #4071
2012-10-01 22:10:36 +02:00
Nathan Rajlich
3b7312d23a repl: make "end of input" JSON.parse() errors throw in the REPL 2012-10-01 11:36:06 -07:00
Nathan Rajlich
f1722a280c repl: make invalid RegExp modifiers throw in the REPL
Fixes #4012.
2012-09-30 22:47:57 -07:00
isaacs
ae40f1c438 Merge remote-tracking branch 'ry/v0.8' into v0.8-merge
Conflicts:
	AUTHORS
	ChangeLog
	deps/openssl/openssl.gyp
	deps/uv/src/unix/linux/linux-core.c
	deps/uv/src/unix/process.c
	deps/uv/src/unix/stream.c
	deps/v8/src/arm/builtins-arm.cc
	deps/v8/src/arm/code-stubs-arm.cc
	deps/v8/src/arm/full-codegen-arm.cc
	lib/tls.js
	src/node_version.h
	test/simple/test-http-client-timeout-agent.js
2012-09-28 09:47:48 -07:00
Fedor Indutny
d68c02e3fe debugger: test repeating last command
* debugger: Add NODE_FORCE_READLINE environment variable, handle
 `SIGINT`'s sent to process while in this mode.
2012-09-28 10:58:50 +04:00
Alex Kocharin
8ac1a73635 Fixed a bug with last command repeating in debugger 2012-09-28 10:21:37 +04:00
Pavel Lang
b38277be26 http: add response.headersSent property
Boolean property getter. True if headers was sent, false otherwise.
2012-09-28 02:57:01 +02:00
thewilli
33a5c8a814 http: handle multiple Proxy-Authenticate values
Just as the 'WWW-Authenticate' HTTP header the 'Proxy-Authenticate' header might
be received several times as well. Currently only one value is preserved. This
change allows to receive multiple values concatenated by space and comma.
2012-09-27 13:28:16 -07:00
thewilli
ac17dc1764 http: handle multiple Proxy-Authenticate values
Just as the 'WWW-Authenticate' HTTP header the 'Proxy-Authenticate' header might
be received several times as well. Currently only one value is preserved. This
change allows to receive multiple values concatenated by space and comma.
2012-09-27 01:11:00 +02:00
isaacs
411d46087f tls: lint
cc @indutny >_<
2012-09-25 11:09:39 -07:00
isaacs
2a9a5e2318 domain: Remove stray console.log 2012-09-25 11:08:52 -07:00
Fedor Indutny
7651228ab2 tls: use slab allocator 2012-09-25 08:37:08 -07:00
Nathan Rajlich
0f2ed2bc2c http: make the client "res" object gets the same domain as "req"
Fixes #4046.
2012-09-24 11:48:39 -07:00
Nathan Rajlich
4a2670740c repl: make invalid RegExps throw in the REPL
Fixes #2746.
2012-09-21 19:49:29 -07:00
Andreas Madsen
5070eccf1b child_process: don't die when disconnect event exists 2012-09-22 03:49:17 +02:00
Ben Noordhuis
212466bea2 child_process: make .fork()'d child auto-exit
A child process created with .fork() needed to call `process.exit()` explicitly
because the communication channel with the parent kept the event loop alive.

Fix that by only ref'ing the channel when there are 'message' event listeners.

Fixes #3799.
2012-09-22 03:48:59 +02:00
Ben Noordhuis
56668f54d1 events: speed up .removeAllListeners() 2012-09-22 03:48:59 +02:00
Ben Noordhuis
b7fd55e9a0 events: speed up newListener/removeListener events 2012-09-22 03:48:59 +02:00
Ben Noordhuis
84221fd1d6 events: add 'removeListener' event 2012-09-22 03:48:59 +02:00
isaacs
0400571676 domain: Properly exit() on domain disposal
This addresses #4034.  There are two problems happening:

1. The domain is not exited automatically when calling dispose() on it.
Then, since the domain is disposed, attempting to exit it again will do
nothing.

2. The active domain is stored on process.domain.  Since thrown errors
call `process.emit('uncaughtException', er)`, and the process is an
event emitter with a `.domain` member, it re-enters the domain a second
time before calling the error handler, pushing it onto the stack again.

Thus, if the handler calls `domain.dispose()`, then the domain is now on
the stack twice, and cannot be exited properly.  Since the domain is
disposed, any subsequent IO will be no-op'ed, since we've declared that
this context is done and best forgotten.

The solution here is twofold:

1. In EventEmitter.emit, do not enter the domain if `this===process`.
2. Automatically exit the domain when calling `domain.dispose()`.
2012-09-21 09:22:50 -07:00
tasogarepg
21c4b9a9eb debugger: fix --debug-brk 2012-09-18 10:56:37 +04:00
isaacs
7144be70db url: Go much faster by using Url class
V8 loves it when JavaScript pretends to be a Classic inheritance
type of language.

Before:

$ ./node benchmark/url.js
benchmarking parse() ... 1.868 sec
benchmarking format() ... 1.906 sec
benchmarking resolve("../foo/bar?baz=boom") ... 7.800 sec
benchmarking resolve("foo/bar") ... 7.099 sec
benchmarking resolve("http://nodejs.org") ... 8.403 sec
benchmarking resolve("./foo/bar?baz") ... 7.974 sec

After:

$ ./node benchmark/url.js
benchmarking parse() ... 1.769 sec
benchmarking format() ... 1.793 sec
benchmarking resolve("../foo/bar?baz=boom") ... 4.254 sec
benchmarking resolve("foo/bar") ... 3.932 sec
benchmarking resolve("http://nodejs.org") ... 4.382 sec
benchmarking resolve("./foo/bar?baz") ... 4.293 sec
2012-09-17 10:44:23 -07:00
Ben Noordhuis
39a0836d5c fs: fix watchFile() missing deletion events
Make sure the deletion event gets reported in the following scenario:

  1. Watch a file.
  2. The initial stat() goes okay.
  3. Something deletes the watched file.
  4. The second stat() fails with ENOENT.

The second stat() translates into the first 'change' event but a logic error
stopped it from getting emitted.

Fixes #4027.
2012-09-17 17:52:50 +02:00
Ben Noordhuis
35607f3a2d tls, https: validate server certificate by default
This commit changes the default value of the rejectUnauthorized option from
false to true.

What that means is that tls.connect(), https.get() and https.request() will
reject invalid server certificates from now on, including self-signed
certificates.

There is an escape hatch: if you set the NODE_TLS_REJECT_UNAUTHORIZED
environment variable to the literal string "0", node.js reverts to its
old behavior.

Fixes #3949.
2012-09-15 00:19:06 +02:00
isaacs
bb207c2827 Merge remote-tracking branch 'ry/v0.8' into master
Conflicts:
	ChangeLog
	src/node_version.h
	test/simple/test-util-inspect.js
2012-09-12 15:13:07 -07:00
Frédéric Germain
451ff1540a http: Remove timeout handler when data arrives 2012-09-12 09:50:06 -07:00
isaacs
41e1b171ec stream.pipe: Don't call destroy() unless it's a function 2012-09-10 16:00:27 -07:00
Nathan Rajlich
a4ef01df07 buffer: implement Buffer.prototype.toJSON()
Returns an Array-representation of the Buffer.
Closes #3905.
2012-09-09 11:04:16 -07:00
Nathan Rajlich
fb383a0ad0 util: make util.inspect() work when "hasOwnProperty" is overwritten 2012-09-08 15:09:59 -07:00
Ben Noordhuis
9a3521cb25 http: respect HTTP/1.0 TE header
A HTTP/1.0 client does not support 'Transfer-Encoding: chunked' unless it
explicitly requests it by sending a 'TE: chunked' header.

Before this commit, node.js always disabled chunked encoding for HTTP/1.0
clients. Now it will scan for the TE header and turn on chunked encoding if
requested and applicable.

Fixes #940.
2012-09-08 21:43:57 +02:00
Fedor Indutny
8e0c830cd0 tls: async session storage 2012-09-05 02:01:54 +04:00
Ben Noordhuis
790d651f0d http: make http.ServerResponse emit 'end'
This used to be the internal 'finish' event. Make it public so API users will
know when the response has been sent completely.

Fixes #3855.
2012-09-04 22:07:48 +02:00
Ben Noordhuis
972cdf82f1 Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	deps/uv/include/uv.h
	src/node_crypto.cc
2012-09-04 15:02:20 +02:00
koichik
7f404e3509 buffer: added support for writing NaN and Infinity
to writeDoubleBE(), writeDoubleLE(), writeFloatBE() and writeFloatLE().
Fixes #3934.
2012-09-02 21:01:43 +09:00
koichik
37f0eb8df3 Revert "buffer: added support for writing NaN and Infinity"
This reverts commit 6b9425fe37.
2012-09-02 20:59:50 +09:00
koichik
6b9425fe37 buffer: added support for writing NaN and Infinity
to writeDoubleBE(), writeDoubleLE(), writeFloatBE() and writeFloatLE().
Fixes #3934.
2012-09-02 00:27:17 +09:00
Shigeki Ohtsu
f347077e78 tls: support unix domain socket/named pipe in tls.connect 2012-08-31 00:23:36 +02:00
Bert Belder
b0d2795fe9 child process: fix processes with IPC channel don't emit 'close'
With this patch the IPC socket is no longer available in the
ChildProcess.stdio array. This shouldn't be very problematic, since
this socket was effectively non-functional; it would never emit any
events.
2012-08-30 16:13:27 +02:00
Ben Noordhuis
8bec26122d tls, https: throw exception on missing key/cert
Throw an exception in the tls.Server constructor when the options object
doesn't contain either a PFX or a key/certificate combo.

Said change exposed a bug in simple/test-tls-junk-closes-server. Addressed.

Fixes #3941.
2012-08-29 22:53:07 +02:00
Ben Noordhuis
e4cef1a083 doc: update assert.doesNotThrow() docs
It takes an optional "expected exception" argument that is not used meaningfully
but is nevertheless documented. Undocument it, it confuses casual readers of the
documentation.

Fixes #3935.
2012-08-29 02:36:22 +02:00
Bert Belder
bf16d9280e Merge branch 'v0.8'
Conflicts:
	ChangeLog
	deps/openssl/openssl.gyp
	src/node_version.h
2012-08-28 02:54:22 +02:00
Bert Belder
2418434568 windows: fix single-accept mode for shared server sockets 2012-08-28 02:17:08 +02:00
isaacs
985e3a25cb lint 2012-08-27 13:03:30 -07:00
isaacs
e5d95ba939 fs: Throw early on invalid encoding args
Re #3918
2012-08-27 13:03:30 -07:00
isaacs
05282588e0 Buffer.isEncoding(enc)
Re: #3918
2012-08-27 13:01:29 -07:00
Nathan Rajlich
0285dae26a repl: create a new Console instance for the repl when "useGlobal" is off
Now `console.log('blah')` will work in a REPL running over a socket.

Closes #3876.
2012-08-24 14:31:32 -07:00
Nathan Rajlich
025f53c306 console: refactor the console module to be reusable
So that multiple instances can be created pointing
to different writable streams.

This is needed for #3876.
2012-08-24 14:31:32 -07:00
Brian White
c78678b081 http: bubble up parser errors to ClientRequest
Make parser errors bubble up to the ClientRequest instead of the underlying
net.Socket object.

Fixes #3776.
2012-08-24 17:26:31 +02:00
koichik
752ac320ae https: make https.get() accept a URL
https.get() now accepts either a URL (as a string) or an options object.

Refs #2859.
Fixes #3882.
2012-08-24 16:56:06 +02:00
Ben Noordhuis
422772f23b net: fix asserts
Fixes a 'Converting circular structure to JSON' TypeError.
2012-08-23 16:03:48 +02:00
isaacs
ee200942dd lint 2012-08-22 11:03:14 -07:00
Ben Noordhuis
badbd1af27 tls: update default cipher list
Update the default cipher list from RC4-SHA:AES128-SHA:AES256-SHA
to ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
in order to mitigate BEAST attacks.

The documentation suggested AES256-SHA but unfortunately that's a CBC cipher
and therefore susceptible to attacks.

Fixes #3900.
2012-08-21 22:27:13 +02:00
Ben Noordhuis
63d13e86a5 child_process: emit error on exec failure
libuv calls the exit cb with exit code == -1 when it fails to spawn the new
process. Anticipate that and emit the error on the ChildProcess object.
2012-08-21 14:29:20 +02:00
Ben Noordhuis
6c999fd285 timers: fix assertion in Timeout.unref()
Ensure that the delay >= 0 when detaching the timer from the queue. Fixes the
following assertion:

  uv_timer_start: Assertion `timeout >= 0' failed.

No test included, it's timing sensitive.
2012-08-17 14:11:35 +02:00
Ben Noordhuis
a177f55b0c Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	ChangeLog
	src/node_version.h
	test/message/stdin_messages.out
	tools/install.py
2012-08-17 13:05:20 +02:00
Bert Belder
9918e5d4f6 windows: make junctions work again
Closes GH-3879
2012-08-17 02:30:57 +02:00
isaacs
22804a9eb8 module: use 'repl' as the filename arg if missing
Fix #3859
2012-08-13 22:07:03 +02:00
isaacs
50c7d80fb0 events: emitter.listeners() should not have side effects
Fixes #3803
2012-08-13 19:04:40 +02:00
Ben Noordhuis
c492d43f48 tls: fix segfault in pummel/test-tls-ci-reneg-attack
Commit 4e5fe2d changed the way how process.nextTick() works:

    process.nextTick(function foo() {
      process.nextTick(function bar() {
        // ...
      });
    });

Before said commit, foo() and bar() used to run on separate event loop ticks
but that is no longer the case.

However, that's exactly the behavior that the TLS renegotiation attack guard
relies on. It gets called by OpenSSL and needs to defer the 'error' event to a
later tick because the default action is to destroy the TLS context - the same
context that OpenSSL currently operates on.

When things change underneath your feet, bad things happen and OpenSSL is no
exception. Ergo, use setImmediate() instead of process.nextTick() to ensure
that the 'error' event is actually emitted at a later tick.

Fixes #3840.
2012-08-13 18:10:26 +02:00
Ben Noordhuis
6b18e88b68 tls: handle multiple CN fields when verifying cert
Fixes #3861.
2012-08-12 21:48:26 +02:00
Timothy J Fontaine
320ae691d8 timers: make unref'd timeouts execute in a domain 2012-08-12 01:15:08 +02:00
Timothy J Fontaine
382f22f229 timers: implement setImmediate 2012-08-12 00:07:22 +02:00
Felix Böhm
d15bfc04cd path: small speed improvements 2012-08-10 12:55:49 +02:00
Ben Noordhuis
5fba3b85c5 fs: fix ReferenceError in truncateSync()
Fixes a minor oversight introduced in 168a555, resulting in the following error:

  fs.js:467
      return fs.ftruncateSync(path, len, callback);
                                         ^
  ReferenceError: callback is not defined
      at Object.fs.truncateSync (fs.js:467:40)
2012-08-08 23:07:18 +02:00
Ben Noordhuis
4c150ca0d0 net: fix listen() regression, revert patches
This commit reverts the following commits (in reverse chronological order):

  74d076c errnoException must be done immediately
  ddb02b9 net: support Server.listen(Pipe)
  085a098 cluster: do not use internal server API
  d138875 net: lazy listen on handler

Commit d138875 introduced a backwards incompatible change that broke the
simple/test-net-socket-timeout and simple/test-net-lazy-listen tests - it
defers listening on the target port until the `net.Server` instance has at
least one 'connection' event listener.

The other patches had to be reverted in order to revert d138875.

Fixes #3832.
2012-08-06 23:55:38 +02:00
Josh Erickson
7b367a93ce net: add support for IPv6 addresses ending in ::
Modified net.isIP Ipv6 regex to allow for addresses ending in "::".
Added tests for new IPv6 matching reqex.
2012-08-06 22:25:55 +02:00
isaacs
168a555780 fs: fix naming of truncate/ftruncate functions
For backwards compatibility, fs.truncate(<number>) will proxy to
fs.ftruncate.

Fix #3805
2012-08-06 08:40:56 -07:00
Ben Noordhuis
2f7e0f2da6 fs: remove undocumented .destroy callbacks
The destroy() method of fs.ReadStream and fs.WriteStream takes a callback.
It's a leftover from the node 0.1 days, undocumented and not part of the
streams API. Remove it.
2012-08-06 00:45:32 +02:00
isaacs
7bb814f9db errnoException must be done immediately 2012-08-05 14:42:22 -07:00
Ben Noordhuis
3219616f43 util: mark util.pump() as deprecated 2012-08-05 23:40:28 +02:00
isaacs
74d076caf1 errnoException must be done immediately 2012-08-05 14:22:44 -07:00
Andreas Madsen
ddb02b978d net: support Server.listen(Pipe) 2012-08-05 13:53:31 -07:00
Andreas Madsen
085a09874b cluster: do not use internal server API 2012-08-05 13:53:31 -07:00
Andreas Madsen
d13887512e net: lazy listen on handler
This allow the server to be shared without the need to handle connection
from master
2012-08-04 22:13:07 -07:00
Dominic Tarr
f4a4ef7a2d zlib: Emit 'close' on destroy(). 2012-08-04 13:04:15 -07:00
Tyler Neylon
b48684c6f1 child_process: Fix stdout=null when stdio=['pipe']
Previously, a command with a short stdio array would result in the child's
stdout and stderr objects set to null. For example:

var c = child_process.spawn(cmd, args, {stdio: ['pipe']});
// results in c.stdout === null.

The expected behavior is the above line functioning the same as this one:

var c = child_process.spawn(cmd, args, {stdio: ['pipe', null, null]});
// provides correct (non-null) c.stdout; as does the above, after this fix.
2012-08-04 11:30:58 -07:00
isaacs
3bf1846bb7 Merge remote-tracking branch 'ry/v0.8'
Conflicts:
	ChangeLog
	deps/uv/src/unix/sunos.c
	deps/uv/test/test-tcp-unexpected-read.c
	src/node_version.h
2012-08-03 16:23:14 -07:00
Bert Belder
5fdeebd94d net: make pause work with connecting sockets
This fixes the problem that calling pause() on a socket would not
actually prevent 'data' events from being emitted. It also replaces
the existing test by a more elaborate one.

Ref: #3118
2012-08-03 17:11:08 +02:00
Ben Noordhuis
34c750d7a9 net: fix .listen({fd:0}) 2012-08-02 13:37:02 +02:00
Gil Pedersen
f1fba8d1f5 fs: fix ReadStream / WriteStream missing callback
The (undocumented) callback argument to .destroy() was not called if the
stream was no longer readable / writable.
2012-08-02 01:25:53 +02:00
Ben Noordhuis
23f09d7e02 fs: fix readFileSync("/proc/cpuinfo") regression
Don't use positional reads. Not all proc files support pread(), especially on
older linux kernels.

Fixes #3808.
2012-08-01 20:30:40 +02:00
koichik
72bc4dcda4 assert: fix throws() throws an error without message property
Fixes #2893.
2012-07-29 19:48:16 +09:00
Ben Noordhuis
aa0650f444 cluster: fix libuv assert in net.listen()
Problem: calling `server.listen()` (no port) on a net.Server triggered the
following libuv assertion:

  node: ../deps/uv/src/unix/stream.c:406: uv__write: Assertion `fd_to_send >= 0'
  failed.

Cause: uv_tcp_t handles are lazily initialized. Omitting the port made the
handle get initialized even more lazily. Too lazily - it wasn't initialized
when the handle was sent over to the child process.

Solution: implicitly bind to a random port in listen() when the port number
is omitted, it forces the handle to initialize. This is not a change in
behavior, listen() has always been identical to listen(0).

Fixes #3325.
2012-07-29 02:07:16 +02:00
Tom Hughes-Croucher
c05f52c254 child_process: improve maxBuffer error message
Mention what buffer (stdout, stderr) overflowed.
2012-07-29 01:28:50 +02:00
Joe Andaverde
20e12e4be3 events: make .listeners() return a copy
Make EventEmitter.listeners(event) return a copy of the listeners array instead
of the array itself.

Fixes #3442.
2012-07-27 20:28:51 +02:00
Ben Noordhuis
332fea5ac1 dgram: make .bind() always asynchronous 2012-07-26 23:55:25 +02:00
isaacs
e5498331f4 Merge remote-tracking branch 'ry/v0.8'
Conflicts:
	AUTHORS
	ChangeLog
	src/node_version.h
2012-07-26 11:58:03 -07:00
isaacs
b0c0111b04 https: Use host header as effective servername 2012-07-25 13:38:43 -07:00
Nathan Rajlich
9eddaebb79 assert: remove unnecessary use of __proto__
AssertionError already inherits from Error above using util.inherits(),
so this extra line was redundant.

test/simple/test-assert.js already tests for `instanceof`, and still passes.
2012-07-25 10:41:08 -07:00
isaacs
5809426d75 net.js: lint 2012-07-24 17:05:31 -07:00
Ben Noordhuis
1513848f88 net: fix Socket({ fd: 42 }) api
Make the implementation match the documentation. This should work:

  var s = new net.Socket({ fd: 42, allowHalfOpen: true };

And now it does.
2012-07-24 15:53:22 -07:00
isaacs
e4c9c9f412 readline: Remove event listeners on close
Fix #3756
2012-07-24 15:36:53 -07:00
Bert Belder
febffc107d Merge branch 'v0.8'
Conflicts:
	lib/tls.js
2012-07-23 18:34:03 +02:00
Timothy J Fontaine
cd6122edeb add ref/unref to setTimeout timers 2012-07-23 18:31:30 +02:00
Timothy J Fontaine
2637b5c261 ref/unref for net.Socket net.Server dgram.Socket 2012-07-23 18:31:30 +02:00
Bert Belder
43a0c88116 windows: correctly prep long path for fs.exists(Sync)
Closes GH-3739
2012-07-23 13:55:42 +02:00
Brian White
e06b5d7af7 http: remove duplicate assignments
Closes GH-3754
2012-07-23 11:35:52 +02:00
Fedor Indutny
42c6952edb tls: pass linting 2012-07-20 22:07:39 +04:00
Fedor Indutny
85185bbbaa tls: pass linting 2012-07-20 22:07:16 +04:00
Fedor Indutny
92e7433ff9 tls: fix 'hostless' tls connection verification
And fix last failing tests
2012-07-20 21:48:59 +04:00
Fedor Indutny
1ccdde9a69 Revert "http/https: pass request to .createConnection()"
This reverts commit 53716eb0b5.
2012-07-20 21:48:56 +04:00
Fedor Indutny
50122fed8a tls: fix 'hostless' tls connection verification
And fix last failing tests
2012-07-20 21:43:12 +04:00
Fedor Indutny
93d496a4ec tls: revert accidental API change
socket.authorizationError should always be string. Also make sni test
pass.
2012-07-20 21:13:54 +04:00
Fedor Indutny
5950db197c tls: revert accidental API change
socket.authorizationError should always be string. Also make sni test
pass.
2012-07-20 21:10:23 +04:00
Fedor Indutny
4aa09d1e0e tls: localhost is valid against identity-check 2012-07-20 20:51:38 +04:00
Fedor Indutny
e43fe5c833 Revert "http/https: pass request to .createConnection()"
This reverts commit 53716eb0b5.
2012-07-20 20:51:02 +04:00
Fedor Indutny
0cf235410d tls: localhost is valid against identity-check 2012-07-20 20:47:05 +04:00
Fedor Indutny
eb2ca10462 tls: veryify server's identity 2012-07-20 01:49:31 +04:00
Fedor Indutny
53716eb0b5 http/https: pass request to .createConnection()
It's useful for passing some additional options of request object to the
underlying API
2012-07-20 01:49:30 +04:00
Fedor Indutny
1fa0bca2ad net: ignore socket.setTimeout(Infinity) (and NaN) 2012-07-20 01:49:30 +04:00
Fedor Indutny
8ba189b8d3 tls: veryify server's identity 2012-07-20 00:53:36 +04:00
Fedor Indutny
2b3ba3f538 http/https: pass request to .createConnection()
It's useful for passing some additional options of request object to the
underlying API
2012-07-20 00:45:10 +04:00
Fedor Indutny
b0950cbea2 net: ignore socket.setTimeout(Infinity) (and NaN) 2012-07-20 00:43:41 +04:00
isaacs
8973c3d2b6 Merge remote-tracking branch 'ry/v0.8' 2012-07-16 18:35:07 -07:00
Pavel Lang
ff14007573 Enable color customization of util.inspect
This is rewrite of #3701 and #3603 before.

This patch introduce `util.inspect.styles`
and `util.inspect.colors` objects, which enables customization
of color sequences.
2012-07-16 18:32:03 -07:00
isaacs
d6b78d0e37 domain: Fix stack leak on error 2012-07-16 18:04:55 -07:00
isaacs
db59c84ba0 Merge remote-tracking branch 'ry/v0.8'
Conflicts:
	deps/npm
2012-07-13 12:18:39 -07:00
Nathan Rajlich
713b9249e1 Revert "events: don't delete the listeners array in removeListener()"
This reverts commit 928ea564d1.

Keeping the original Array instance in-place essentially causes a memory leak
on EventEmitters that use an infinite number of event names (an incrementing
counter, for example), which isn't an unreasonable thing to want to do.

Fixes #3702.
2012-07-12 15:43:35 -07:00
Ben Noordhuis
3a6314dbe1 net: fix net.Server.listen({fd:x}) error reporting
* don't assert when fd isn't an open file descriptor

* don't die with a ReferenceError when fd isn't a file descriptor
  you can listen() on

Fixes #3699.
2012-07-12 18:18:38 +02:00
Ben Noordhuis
5d97d72753 net: fix bogus errno reporting
_listen2() emits the error on the next tick. The errno value may have changed
by then.
2012-07-12 16:56:44 +02:00
isaacs
3ad07ed0b8 lint 2012-07-11 17:46:28 -07:00
isaacs
424cd5a020 Merge remote-tracking branch 'ry/v0.8' into v0.8-merge
Conflicts:
	src/node_version.h
2012-07-11 17:38:11 -07:00
Shigeki Ohtsu
76104f3414 timer: change new Date to Date.now for performance
Speeds up benchmark/settimeout.js by about 30%.
2012-07-10 22:44:07 +02:00