Commit Graph

555 Commits (3def66ac3b3c2644bc4f0261662236638b55ba51)

Author SHA1 Message Date
Ryan Dahl 44a287987e Safe constructors: http.Server and http.Client 2010-08-27 13:58:52 -07:00
Brian d9eb64928e Fix home/end keys in repl for putty/xterm. 2010-08-23 09:18:36 -07:00
Russell Haering 6078c37be5 Modify fs.open to use accept a callback without a mode 2010-08-23 02:42:25 -07:00
Johan Euphrosine 748469c71c add readline support for meta-f and meta-b 2010-08-23 01:47:41 -07:00
Johan Euphrosine fd3e84499e add home/end support in rxvt and readline tests 2010-08-23 01:46:14 -07:00
isaacs e55c486801 Missing 'var' in sys.inspect (Found by Oleg Slobodskoi) 2010-08-22 13:45:39 -07:00
Johan Euphrosine 0e1e00e68b fix home/end on GNU/Linux 2010-08-22 12:34:58 -07:00
Ryan Dahl 2982e75a0b set-cookies header is an array of values. always 2010-08-21 16:34:38 -07:00
Ryan Dahl 51ecba8da9 Add get/set methods to Buffer 2010-08-19 23:29:06 -07:00
Trent Mick 293809b8b6 drop obsolete TODO comment 2010-08-18 23:02:54 -07:00
Trent Mick 1aeaf8d289 repl tab completion: insert common prefix of multiple completions 2010-08-18 23:02:30 -07:00
Trent Mick 5c1ffa165f repl completion: completion for arguments to "require" 2010-08-18 22:59:49 -07:00
Trent Mick 2134982ea4 repl completion: comment/TODO cleanup, no functional change 2010-08-18 22:59:35 -07:00
Herbert Vojčík 5dc2b93311 Fix sys.inspect for regex in different context. 2010-08-18 11:47:43 -07:00
Marco Rogers 6744e59e46 detect 0 length fs writes with tests 2010-08-16 23:57:01 -07:00
Ryan Dahl 4593c04959 Implement net.Server.maxConnections
Simplify EMFILE behavior.
2010-08-15 14:01:55 -07:00
Illarionov Oleg cde80d9859 Fix OpenSSL 100% CPU usage on error 2010-08-15 13:23:09 -07:00
Rasmus Andersson cf909e8725 added dns.getHostByAddr() -- resolve an external IP address to hostname(s) 2010-08-12 16:25:45 -07:00
Ryan Dahl 9acd76ed6e Don't throw on HEAD requests 2010-08-12 10:06:52 -07:00
Trent Mick 72e4a49cac repl completion: multi-column display of completions 2010-08-12 00:07:26 -07:00
Trent Mick 1c9a85b9a6 First pass at tab-completion in the REPL 2010-08-11 13:42:45 -07:00
Rasmus Andersson fd3cd755d1 [dgram] only look up hostname for the requested address family
- [lib/dns.js] dns.lookup takes a new optional argument "family" which
  should be the integer 4, 6, dns.AF_INET or dns.AF_INET6. Passing a
  non-false "family" argument makes c-ares explicitly look up addresses for
  the specified family.

- [test/simple/test-c-ares.js] test explicit address family lookups
2010-08-10 17:53:32 -07:00
Ryan Dahl 3d551e5538 Close fd on readFile(emptyfile) 2010-08-10 14:47:40 -07:00
Ryan Dahl 1c5d5e0b72 uppercase request methods 2010-08-09 21:23:52 -07:00
Bert Belder 7d4e8a9a71 If no options are given to child_process.spawn, env should default to process.env
Regression.
2010-08-09 15:37:14 -07:00
Ryan Dahl 7068912fbb Export Interface from readline.js 2010-08-08 11:52:31 -07:00
Bert Belder aaa1f451e6 Expose cwd option to child_process.exec() 2010-08-06 13:38:41 -07:00
Bert Belder 94914135df New api for child_process.spawn; ability to set cwd for spawn()ed process
Tests for child_process.spawn() use new API

Test for deprecated child_process.spawn() API
2010-08-06 13:37:30 -07:00
Ryan Dahl d408de87fc Remove module.js - put code into src/node.js 2010-08-06 12:34:02 -07:00
cloudhead fe3e419687 querystring.parse: handle undefined value properly 2010-08-05 10:46:28 -07:00
Nick Stenning 0a3eff8021 Standardise module load order for native and registered file extensions.
This patch standardises the load order for modules. Highest priority is trying to load exactly the file the user specified, followed by native extensions, followed by registered extra extensions, etc.

In full, if we require('foo') having registered '.coffee' as an alternative extension, we try and load the following files in order:

    foo
    foo.js
    foo.node
    foo.coffee
    foo/index.js
    foo/index.node
    foo/index.coffee
2010-08-04 16:03:08 -07:00
Nick Stenning 78520ba482 Don't attempt to load a directory.
This patch replaces the path.exists check for module loading with a call to
fs.statSync (or fs.stat for require.async) which ensures that it's not trying
to load a directory.
2010-08-04 15:55:47 -07:00
Ryan Dahl adec544fdd Revert "Expose the V8 debug object process.debug"
This reverts commit d9fbb8a580.
2010-08-04 10:38:19 -07:00
Ben Noordhuis 4b19bd2896 Client.onend: Anticipate that the HTTP parser object is uninitialized when the client setup failed. 2010-08-02 11:25:53 -07:00
Ryan Dahl d9fbb8a580 Expose the V8 debug object process.debug
Add one duplicate test from V8, just to make sure it works.
2010-08-02 00:46:09 -07:00
Mikeal Rogers 3214116be6 Implement keep-alive for http.Client
Send the 'Connection: keep-alive' header in your request to enable.
2010-08-01 22:34:17 -07:00
isaacs 65037eeb32 Don't let path.normalize get above the root.
Any path.join or path.normalize that starts with a / will not go "above" that after normalization.  This is important because /../foo is almost *always* some sort of error, and doesn't match the corollary in sh: `cd $p; pwd`

At the worse, this can be a vector for exploits, since a static file server might do path.join(docroot, path.normalize("/"+req)) to get the file.  If the normalized request path could be something like "/../../../etc/passwd" then bad things could happen.
2010-08-01 20:20:17 -07:00
Danny Coates dc8c079d90 remove node::CheckBreak in favor of using the v8 debugger js object 2010-08-01 20:04:31 -07:00
Ryan Dahl b5b83b210b Fix --debug-brk; hacky solution 2010-07-27 20:36:58 -07:00
Matt Ranney f7c5334195 Check for socket on Unix domain connect.
Change scope to context in REPL docs.
2010-07-26 19:02:15 -07:00
Chandra Sekar S 66deea10c7 Support for HOME and END in REPL. 2010-07-26 10:59:34 -07:00
Dmitry Baranovskiy 8ab3c3e7c3 Added ability to pass offset to buffer write and toString methods as a string, i.e. '2' and encoding as anything 2010-07-25 20:16:37 -07:00
Ryan Dahl 2c1ca4078d Implement buffer.write for base64
There might be an off-by-one on the returned value.
2010-07-23 16:36:52 -07:00
Ryan Dahl 528015e0d8 Implement buffer.toString('base64') 2010-07-23 13:52:44 -07:00
isaacs f0f247d7e5 Fix dirname so that dirname('/a/b/') -> '/a', like sh's does.
Before there was this comment:
  Can't strip trailing slashes since module.js incorrectly
  thinks dirname('/a/b/') should yield '/a/b' instead of '/a'.
But now, such thinking is corrected.
2010-07-23 09:08:49 -07:00
Chandra Sekar S f5f7cb9264 Support for reading byte ranges from files using fs.createReadStream. 2010-07-21 11:33:35 -07:00
Peter Griess 56f200af5d Fix Buffer.toString() on 0-length slices.
- Buffer.toString('ascii', 0, 0) incorrectly returns the entire contents
  of the buffer. Fix this.
- Provide similar behavior to Buffer.write() and Buffer.copy() when
  dealing with 0-length in valid and invalid byte ranges.
2010-07-20 15:38:10 -07:00
isaacs d75b63bc3c Support including modules that don't have an extension.
This way, require("/foo") will work if there is a "foo.js", or a file named
simply "foo" with no extension.
2010-07-20 10:26:24 -07:00
Ryan Dahl 7067a7155f Specify env differently in execFile
Callbacks should always be the last argument.
2010-07-19 20:08:35 -07:00
isaacs 49e0f14a2f Cache modules based on filename rather than ID
This is ever so slightly less efficient than caching based on ID, since the
filename has to be looked up before we can check the cache.  However, it's
the most minimal approach possible to get this change in place.  Since
require() is a blocking startup-time operation anyway, a bit of slowness is
not a huge problem.

A test involving require.paths modification and absolute loading. Here's the
gist of it.

Files: /p1/foo.js /p2/foo.js

  1. Add "/p1" to require.paths.
  2. foo1 = require("foo")
  3. assert foo1 === require("/p1/foo") (fail)
  4. Remove /p1 from require.paths.
  5. Add /p2 to require.paths.
  6. foo2 = require("foo")
  7. assert foo1 !== foo2 (fail)
  8. assert foo2 === require("/p2/foo") (fail)

It's an edge case, but it affects how dependencies are mapped by npm.
If your module requires foo-1.2.3, and my module requires foo-2.3.4,
then you should expect to have require("foo") give you foo-1.2.3, and
I should expect require("foo") to give me foo-2.3.4.  However, with
module ID based caching, if your code loads *first*, then your "foo"
is THE "foo", so I'll get your version instead of mine.

It hasn't yet been a problem, but only because there are so few
modules, and everyone pretty much uses the latest version all the
time.  But as things start to get to the 1.x and 2.x versions, it'll
be an issue, I'm sure.  Dependency hell isn't fun, so this is a way to
avoid it before it strikes.
2010-07-19 14:17:22 -07:00
Micheil Smith 299671b731 querystring: Removing typecasting of numeric strings to numbers
The tests did not accurately test for a strict equality, meaning that the
number == to the string.
2010-07-19 11:07:08 -07:00
Jan Kassens bb2acd5e75 querystring.stringify is now more solid
* handles NaN and Infinity
* works with arrays from other contexts
2010-07-19 10:53:32 -07:00
Ryan Dahl 65f2e72d77 Fix style in readline 2010-07-19 10:16:20 -07:00
Jérémy Lal 0fd1656d63 Support DEL in the REPL. 2010-07-18 22:20:23 -07:00
Ryan Dahl 458bbb4687 fs.writeSync should return bytes written 2010-07-16 19:05:28 -07:00
Сергей Крыжановский 078a48a97b added env to child_process.exec 2010-07-15 17:17:03 -07:00
Ryan Dahl 02729d4af7 instanceof Buffer to Buffer.isBuffer() 2010-07-15 15:58:35 -07:00
Ryan Dahl 6961bc568f More instanceof Array fixes 2010-07-15 14:37:56 -07:00
Ryan Dahl 9472812569 Fix reference to root global context 2010-07-15 10:52:31 -07:00
Ryan Dahl 6a57a42109 Use Array.isArray instead of instanceof 2010-07-15 10:35:29 -07:00
Ryan Dahl 3a00470dbb Add 'root' global variable as reference to sandbox 2010-07-15 10:35:29 -07:00
Ryan Dahl 5f30377bbc Load modules in individual contexts
Add NODE_MODULE_CONTEXTS env var

Only one test was modified to check that this works. NEED to go through all
tests and modify them so that

  NODE_MODULE_CONTEXTS=1 make test

passes.
2010-07-15 10:34:39 -07:00
Matt Ranney 4e50197e53 Datagram socket refactor. Add tests and documentation.
Support setTTL() and setBroadcast() socket options.
2010-07-15 10:27:44 -07:00
isaacs 781d51285d Use execPath for default NODE_PATH, not installPrefix 2010-07-14 09:58:18 -07:00
Mikeal Rogers 16cb45103f Adds "pause" and "resume" events to pump and it's readable argument. 2010-07-13 17:17:20 -07:00
David Siegel 2085909aeb fix corner-case bug in Module
and added a test to expose it
2010-07-13 17:15:10 -07:00
rick c9e505791a use delete for removing events after removing the final listener 2010-07-12 16:29:58 -07:00
Ryan Dahl d700a6f74a Return child from execFile 2010-07-12 14:18:09 -07:00
Dmitriy Shalashov 70a8fb3763 Fix headers with empty value. 2010-07-07 18:46:24 +02:00
Ryan Dahl 515dc2161b Experimental: 'on' as alias to 'addListener' 2010-07-03 09:30:32 +02:00
Peter Griess 94cd83ef34 Doc fixes for FD related features, upgrade.
- Add docs for 'fd' events, Server.listenFD(), Stream.write(...[, fd])
  and http.Client 'upgrade' event.
2010-07-03 08:18:42 +02:00
Ryan Dahl 8a52fb7aeb Revert "Fix 'uncaughtException' for top level exceptions"
This reverts commit 8f8dcf8ed6.
2010-07-01 11:10:22 -07:00
Ryan Dahl 8f8dcf8ed6 Fix 'uncaughtException' for top level exceptions
Done by not evaluating the code in the first tick.

This breaks one test in test-error-reporting.js but I believe this to be a
V8 error and I have reported it in
http://code.google.com/p/v8/issues/detail?id=764
2010-06-30 15:04:40 -07:00
Ryan Dahl ce8c30c9de Clean up indention on module compile
Remove strange code artifact
2010-06-30 14:30:37 -07:00
Blake Mizerany 8c8534046c fix whitespace errors 2010-06-29 23:59:24 -07:00
Dmitry Baranovskiy f8ca6b383c Rewrote QueryString.parse to make it smaller and more effective.
Also added ability to parse foo.bar=4 equal to foo[bar]=4
Added tests for this as well
2010-06-29 23:52:42 -07:00
Ryan Dahl 0a8bd34b69 Resolve .local domains with getaddrinfo()
C-Ares doesn't go through the Name Service Switch (NSS) and thus can't
resolve certain classes of names. Generally this doesn't matter and the
whole idea of NSS is rather annoying. Nevertheless until C-Ares gets better
support, adding this hack to go through getaddrinfo() for .local domain look
up.

This reverts commit 9926dacd14.
2010-06-29 22:15:28 -07:00
Blake Mizerany 898afbaf34 Buffer.prototype.write: Indifferent order preference of encoding and offset 2010-06-29 19:56:07 -07:00
Ryan Dahl 5e86d01385 Revert "Buffer.copy should copy through sourceEnd, as specified."
This reverts commit a2f70da4c9.

Keep tests modifies a few edge checks on Copy()
2010-06-29 19:40:20 -07:00
Dmitry Baranovskiy 8ec12339f5 Refactored isA, isBool, etc functions to use some of ES5 goodness. 2010-06-29 19:22:28 -07:00
Dmitry Baranovskiy d3f04933f1 sys.inherts to shadow constructor property from enumerability
thanks to ES5 features in V8 it is quite easily possible.
2010-06-29 19:11:40 -07:00
Ruben Rodriguez 242161bef2 Added new API to Script, and implemented it in the REPL 2010-06-28 15:16:26 -07:00
Matt Ranney a2f70da4c9 Buffer.copy should copy through sourceEnd, as specified.
Improve test-buffer.js to cover all copy error cases.

Fix off by one error in string_decoder.
2010-06-25 09:10:49 -07:00
Ryan Dahl 7b119f8b38 Fix error message 2010-06-23 09:09:15 -07:00
Ryan Dahl f541043618 Remove ini.js 2010-06-22 19:37:29 -07:00
Ryan Dahl fc175a089d Remove mjsunit from repo 2010-06-22 19:33:01 -07:00
Mikeal Rogers f62979da6b Add sys.pump 2010-06-22 17:58:09 -07:00
Peter Griess 51bd1b4483 Only concatenate some incoming HTTP headers.
- Concatenate 'accept', 'accept-charset', 'accept-encoding',
  'accept-language', 'connection', 'cookie', and 'x-*' headers.
- For all others, drop duplicates.
2010-06-21 12:01:50 -07:00
Peter Griess 187f191558 Support 'upgrade' event in HTTP client.
- Add a unit test for client HTTP upgrade.
- Move around unit tests for server HTTP upgrade.
2010-06-16 11:27:56 -07:00
Ryan Dahl cbf2a2233e Add callback to dgramSocket.send() 2010-06-16 11:03:34 -07:00
David Siegel 81ad8106dc Add UDP broadcast support 2010-06-16 10:45:16 -07:00
Micheil Smith b05daaaf69 Adding path.existsSync (with tests.) 2010-06-16 10:26:11 -07:00
Aaron Heckmann 1d088fb906 fs.writeFile accepts Buffers 2010-06-15 23:58:32 -07:00
Peter Dekkers e48f0d1dd9 Fixed incorrect mask for determining fs.Stats types 2010-06-15 19:52:37 -07:00
isaacs 4ce100fa62 A replacement for decodeURIComponent that doesn't throw.
And add a few more tests.
2010-06-15 19:28:09 -07:00
Ryan Dahl ed5f4f3a44 RootCaCerts shouldn't be global 2010-06-15 18:29:45 -07:00
Ryan Dahl 6bed15e074 Refactor: Utf8Decoder -> StringDecoder
Instead of just decoding Utf8, this will proxy requests to buffer.toString()
for other encodings. This makes for a simpler interface.
2010-06-15 18:19:27 -07:00
Peter Griess 4b48042c17 Wrap FD in closure before emitting from Stream.
- Without this, recvMsg can be invoked before the event emitter gets a
  chance to run. In this case, recvMsg.fd will be overwritten and the
  original caller can end up emitting null.
2010-06-15 15:10:30 -07:00
Ben Lowery f3cd7bbe77 Coerce each argument to a String before attempting to print it via sys.print 2010-06-15 14:44:09 -07:00
Ryan Dahl 14414f81f3 Soft deprecation of 'listening' event.
Add callback param to listen() instead
2010-06-15 12:38:25 -07:00