Граф коммитов

3083 Коммитов

Автор SHA1 Сообщение Дата
James Hartig 30666f22ca net: use cached peername to resolve remote fields
Allows socket.remote* properties to still be accessed even after the
socket is closed.

Fixes: https://github.com/joyent/node/issues/9287
PR-URL: https://github.com/joyent/node/pull/9366
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-03-16 16:20:16 -04:00
cjihrig eb995d6822 path: add type checking for path inputs
This commit adds type checking of path inputs to exported methods
in the path module. The exception is _makeLong(), which seems to
explicitly support any data type.

Fixes: https://github.com/iojs/io.js/issues/1139
PR-URL: https://github.com/iojs/io.js/pull/1153
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-03-16 12:49:21 -04:00
Chris Dickinson 056ed4b0c9 src: revert -r/--require flags
This reverts commit 7bde3f1a8f.

The added test (test/parallel/test-preload.js) fails on Windows.

PR-URL: https://github.com/iojs/io.js/pull/1150
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-03-13 15:16:00 -07:00
Ali Ijaz Sheikh 7bde3f1a8f src: add -r/--require flags for preloading modules
-r/--require can be used to preload modules on node startup. The option
takes a single module name. The option can be repeated as necessary to
preload multiple modules.

This patch allows 'vendors' (such a cloud host) to inject functionality
that gets executed at application startup without requiring an explicit
require from the user's application. This can be useful to load vendor
specific application monitoring APIs transparently.

PR-URL: https://github.com/iojs/io.js/pull/881
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-03-13 13:54:34 -07:00
Jeremiah Senkpiel 53e200acc2 test: fix test-http-content-length
Previously the test did not allow the last request to complete.

Fixes: https://github.com/iojs/io.js/pull/1137
PR-URL: https://github.com/iojs/io.js/pull/1145
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-03-13 16:50:11 -04:00
Shigeki Ohtsu d8c4a932c9 crypto: add deprecated ValiCert CA for cross cert
The host of melissadata.net has a cross root certification between
Starfield Class 2 and ValiCert Class 2. OpenSSL-1.0.1 only looks up
a cert chain to the deprecated ValiCert Class 2 CA and causes
untrusted error. We add it for a short-term remedy and it is to be
removed after upgrading OpenSSSL-1.0.2 and applying private patches
to support alternative cert chains.
See #402 and #589.

Fixes: https://github.com/iojs/io.js/issues/923
PR-URL: https://github.com/iojs/io.js/pull/1135
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-03-13 20:18:54 +09:00
Shigeki Ohtsu 82f067e60b test: fix ext commands to be double quoted
Paths used on the Windows command line need to be enclosed in double
quotes, or they'll be parsed incorrectly when there are spaces in the
path.

PR-URL: https://github.com/iojs/io.js/pull/1122
Reviewed-by: Bert Belder <bertbelder@gmail.com>
2015-03-12 17:35:20 -07:00
Santiago Gimeno 5ecdc0314d test: add test for reading a large file through a pipe
PR-URL: https://github.com/iojs/io.js/pull/1074
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-03-12 16:40:35 -07:00
Santiago Gimeno 0782c24993 test: fix readfile-zero-byte-liar test
PR-URL: https://github.com/iojs/io.js/pull/1074
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-03-12 16:40:31 -07:00
skenqbx 8453fbc879 https: don't overwrite servername option
PR-URL: https://github.com/iojs/io.js/pull/1110
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-03-10 23:28:04 -07:00
Ben Noordhuis 480b48244f lib: allow server.listen({ port: "1234" })
net.connect() accepts `{ port: "1234" }` (i.e. a string) as of commit
9d2b89d06 ("net: allow port 0 in connect()") but net.Server#listen()
did not, creating a minor inconsistency.  This commit rectifies that.

Fixes: https://github.com/iojs/io.js/issues/1111
PR-URL: https://github.com/iojs/io.js/pull/1116
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-03-10 16:13:29 +01:00
Trevor Norris 8070b1ff99 buffer: Don't assign .parent if none exists
The .parent property of the allocated buffer should remain undefined in
the case that it's not a slice. Also included test to verify this.

PR-URL: https://github.com/iojs/io.js/pull/1109
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-03-09 12:46:20 -06:00
Fedor Indutny 1a3ca8223e http_client: ensure empty socket on error
Read all pending data out of the socket on `error` event and ensure that
no `data`/`end` handlers will be invoked on `socket.destroy()`.
Otherwise following assertion happens:

    AssertionError: null == true
        at TLSSocket.socketOnData (_http_client.js:308:3)
        at TLSSocket.emit (events.js:107:17)
        at TLSSocket.Readable.read (_stream_readable.js:373:10)
        at TLSSocket.socketCloseListener (_http_client.js:229:10)
        at TLSSocket.emit (events.js:129:20)
        at TCP.close (net.js:476:12)

Fix: https://github.com/joyent/node/issues/9348
PR-URL: https://github.com/iojs/io.js/pull/1103
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
2015-03-09 09:25:09 -04:00
Jeremiah Senkpiel cf565b5516 fs: fix .write() not coercing non-string values
Fixes: https://github.com/iojs/io.js/issues/1098
PR-URL: https://github.com/iojs/io.js/pull/1102
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-03-08 14:42:09 -07:00
Johan Bergström 37bb1df7c4 build: remove mdb from io.js
After upgrading to a newer v8 mdb is pretty much broken - even if using
the latest updates from nodejs. If nodejs decides to update their v8 we
can give it another go, but for now it's better to remove it than have
it in our tree unsupported.

PR-URL: https://github.com/iojs/io.js/pull/1023
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-03-05 23:10:45 +01:00
Christian Tellnes 4874182065 http: send Content-Length when possible
This changes the behavior for http to send send a Content-Length header
instead of using chunked encoding when we know the size of the body when
sending the headers.

Fixes: https://github.com/iojs/io.js/issues/1044
PR-URL: https://github.com/iojs/io.js/pull/1062
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-03-05 22:17:35 +01:00
Ben Noordhuis 1640dedb3b src: fix ucs-2 buffer encoding regression
StringBytes::Write() did a plain memcpy() when is_extern is true but
that's wrong when the source is a two-byte string and the destination
a one-byte or UTF-8 string.

The impact is limited to strings > 1,031,913 bytes because those are
normally the only strings that are externalized, although the use of
the 'externalize strings' extension (--expose_externalize_string) can
also trigger it.

This commit also cleans up the bytes versus characters confusion in
StringBytes::Write() because that was closely intertwined with the
UCS-2 encoding regression.  One wasn't fixable without the other.

Fixes: https://github.com/iojs/io.js/issues/1024
Fixes: https://github.com/joyent/node/issues/8683
PR-URL: https://github.com/iojs/io.js/pull/1042
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05 20:44:19 +01:00
Ben Noordhuis e2fb733a95 test: simplify parallel/test-stringbytes-external
Make the algorithm that creates the big input strings a little easier
to comprehend.  No functional changes, the string lengths are unchanged.

PR-URL: https://github.com/iojs/io.js/pull/1042
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-05 20:44:19 +01:00
Ben Noordhuis 7b554b1a8f test: don't spawn child processes in domain test
Make parallel/test-domain-abort-on-uncaught a little easier to debug,
make it execute the tests in the same process instead of each test in
a separate child process.

PR-URL: https://github.com/iojs/io.js/pull/974
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-03-05 20:08:56 +01:00
Fedor Indutny 3446ff417b tty: do not add `shutdown` method to handle
UV_TTY does not support `uv_shutdown()` so adding this method in
StreamBase will cause an `abort()` in C land.

Fix: https://github.com/iojs/io.js/issues/1068
PR-URL: https://github.com/iojs/io.js/pull/1073
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-03-05 13:38:22 -05:00
cjihrig 9d2b89d06c net: allow port 0 in connect()
The added validation allows non-negative numbers and numeric
strings. All other values result in a thrown exception.

Fixes: https://github.com/joyent/node/issues/9194
PR-URL: https://github.com/joyent/node/pull/9268
Reviewed-By: Julien Gilli <julien.gilli@joyent.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@users.noreply.github.com>
2015-03-05 10:01:15 -05:00
Bert Belder abd3ecfbd1 win,test: fix test-stdin-from-file
The test-stdin-from-from-file test runs a subprocess that verifies stdin
can be piped from a file.

The subprocess additionally attempts to verify that the file descriptor
for stdin never gets closed. It used to do this by creating a TCP server
and asserting that the associated file descriptor is greater than two.
However this strategy doesn't work on windows, because servers don't
have an associated file descriptor. With this patch an ordinary file is
opened instead of creating a server.

PR: https://github.com/iojs/io.js/pull/1067
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
2015-03-05 15:30:52 +01:00
Jonathan Ong 4d0329ebeb fs: remove unnecessary usage of .hasOwnProperty()
PR-URL: https://github.com/iojs/io.js/pull/635
Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
2015-03-05 15:35:15 +03:00
Ken Perkins b72fa03057 test: adds a test for undefined value in setHeader
As a result of 979d0ca8 there is a new check for undefined values on
OutgoingMessage.setHeader. This commit introduces a test for this case.

PR-URL: https://github.com/iojs/io.js/pull/970
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-03-04 21:57:00 -08:00
Johan Bergström a45d4f8fd6 build: remove tools/wrk from the tree
wrk is an optional tool that some of the http benchmarks uses. The removal
doesn't affect any users. Developers are assumed to install it before running
the tests.

This change reduces the tarball by 5%

PR-URL: https://github.com/iojs/io.js/pull/982
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-03-04 20:25:41 -08:00
Johan Bergström 563771d8b1 test: split parts out of host-headers test into its own test
this makes the separation between http and https testing cleaner

PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-03-05 10:31:41 +09:00
Johan Bergström 671fbd5a9d test: refactor all tests that depends on crypto
we had a few ways versions of looking for support before executing a test. this
commit unifies them as well as add the check for all tests that previously
lacked them. found by running `./configure --without-ssl && make test`. also,
produce tap skip output if the test is skipped.

PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-03-05 10:31:41 +09:00
Johan Bergström c7ad320472 test: check for openssl cli and provide path if it exists
the previous version checked if io.js was compiled with openssl support which
isn't really relevant since we're starting a http server. we on the other hand
need an openssl-cli which may or may not exist.

PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-03-05 10:31:41 +09:00
Johan Bergström 71776f9057 test: remove unused https imports
PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-03-05 10:31:41 +09:00
Johan Bergström 3d5726c4ad test: introduce a helper that checks if crypto is available
since this applies to tls and https (among other things), it'll be used
for those tests as well. if we decouple the build system to somehow support
crypto but not tls, we could refine this.

PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-03-05 10:31:41 +09:00
Johan Bergström d0e7c359a7 test: don't assume process.versions.openssl always is available
PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-03-05 10:31:32 +09:00
Trevor Norris 78581c8d90 buffer: add indexOf() method
Add Buffer#indexOf(). Support strings, numbers and other Buffers. Also
included docs and tests.

Special thanks to Sam Rijs <srijs@airpost.net> for first proposing this
change.

PR-URL: https://github.com/iojs/io.js/pull/561
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-03-04 14:16:11 -07:00
Christian Tellnes abb00cc915 url: throw for invalid values to url.format
`'use strict'` changes the behavior for `Function.prototype.call` when
the context is `undefined`. In earlier versions of node the value
`undefined` would make `url.format` look for fields in the global scope.

The docs states that `url.format` takes a parsed URL object and returns
a formatted URL string. So with this change it will now throw for other
values.

The exception is if the input is a string. Then it will call `url.parse`
on the string and then format it. The reason for that is that you can
call `url.format` on strings to clean up potentially wonky urls.

Fixes: https://github.com/iojs/io.js/issues/1033
PR-URL: https://github.com/iojs/io.js/pull/1036
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Julian Duque <julianduquej@gmail.com>
2015-03-04 22:04:14 +01:00
Vladimir Kurchatkin 8f5f12bb48 smalloc: export constants from C++
PR-URL: https://github.com/iojs/io.js/pull/920
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-04 11:37:12 +03:00
Fedor Indutny 7b3b8acfa6 tls: accept empty `net.Socket`s
Accept `new net.Socket()` as a `socket` option to `tls.connect()`
without triggering an assertion error in C++.

This is done by wrapping it into a JSStream to ensure that there will be
a handle at the time of wrapping the socket into TLSSocket.

Fix: https://github.com/iojs/io.js/issues/987
PR-URL: https://github.com/iojs/io.js/pull/1046
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-03-03 17:05:55 -05:00
Fedor Indutny e1bf6709dc test: fix racey-ness in tls-inception
Fix test failure on FreeBSD and SmartOS, which happens due to a bad
timing:

    events.js:141
          throw er; // Unhandled 'error' event
                ^
    Error: read ECONNRESET
        at exports._errnoException (util.js:734:11)
        at TLSWrap.onread (net.js:538:26)

The outer `net.conncet()` socket stays alive after the inner socket is
gone. This happens because `.pipe()`'s implementation does not `destroy`
the source side when the destination has emitted `close`.

Fix: https://github.com/iojs/io.js/issues/1012
PR-URL: https://github.com/iojs/io.js/pull/1040
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-03-03 16:07:37 -05:00
Trevor Norris e0835c9cda node: improve performance of nextTick
Couple micro optimizations to improve performance of process.nextTick().
Removes ~60ns of execution time.

Also added small threshold to test that allows timer to fire early on
the order if microseconds.

PR-URL: https://github.com/iojs/io.js/pull/985
Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
2015-03-03 13:45:19 -07:00
Johan Bergström fd3ea29902 test: fix test-fs-access when uid is 0
Superusers can open files with W_OK permission even though their
mode is set to 0444. This commit makes the test attempt to change
its uid to nobody on non-Windows platforms. Patch originally from
https://github.com/joyent/node/commit/28d0cbbd.

Fixes: https://github.com/iojs/io.js/issues/1031
PR-URL: https://github.com/iojs/io.js/pull/1037
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-03-03 10:17:03 -05:00
Michael Dawson 5abfa930b8 test: make destroyed-socket-write2.js more robust
test/simple/test-http-destroyed-socket-write2.js validates
that you get an appropriate error when trying to write to
a request when the response on the other side has been destroyed.

The test uses http.request to get a request and then keeps writing
to it until either it hits 128 writes or gets the expected error.
Since the writes are asynchronous we see that the writes just end
up adding events to the event loop, which then later get processed
once the connection supporting the request is fully ready.

The test is timing dependent and if takes too long for the connection
to be made the limit of 128 writes is exceeded and the test fails.
The fact that the test allows a number of writes is probably to allow
some delay for the connection to be ready for writing.

On AIX, in the default configuration using the loopback interface
is slower and the test fails because the delay is such that many
more writes can be queued up before the connection takes place.
If we use the host ip instead of defaulting to the loopback then
the test passes.

The test needs to be made more robust to delays. Since each write
simply enqueues an additional write to the event queue there is
probably no point in doing the second write until the first has
completed. This patch schedules the next write when the first one
completes and allows the test to pass even if it takes longer for
the connection to be ready for writing

PR-URL: https://github.com/joyent/node/pull/9270
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
2015-03-03 10:03:42 -05:00
Julien Gilli 1009130495 tests: fix race in test-http-curl-chunk-problem
This test setups two event listeners: one on a child process' exit event
, another for the same child process' stdandard output's 'data' event.
The data even listener writes to a stream, and the exit event listener
ends it.

Because the exit event can be emitted before the data event, there is a
chance that something will be written to the stream after it's ended,
and that an error is thrown.

This change makes the test end the stream in the listener for the child
process' standard output's end event, which is guaranteed to be emitted
after the last data event, thus avoiding the race.

PR: https://github.com/joyent/node/pull/9301
Reviewed-by: Bert Belder <bertbelder@gmail.com>
Reviewed-by: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
2015-03-03 16:00:53 +01:00
Christian Tellnes 675cffb33e http: don't confuse automatic headers for others
If you set a custom http header which includes eg. the string `Date`,
then http will not automatically send the `Date` header.

This is also true for other automatic http headers.

PR-URL: https://github.com/iojs/io.js/pull/828
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-02-27 21:47:39 -08:00
Evan Lucas e435a0114d src: fix intermittent SIGSEGV in resolveTxt
Fixes a SIGSEGV by making sure `txt_chunk` is not empty before setting
it on `txt_records`

PR-URL: https://github.com/iojs/io.js/pull/960
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-02-25 22:45:35 -06:00
Chris Dickinson 0af4c9ea74 src: fix domains + --abort-on-uncaught-exception
If run with --abort-on-uncaught-exception, V8 will abort the process
whenever it does not see a JS-installed CatchClause in the stack. C++
TryCatch clauses are ignored. Domains work by setting a FatalException
handler which is ignored when running in abort mode.

This patch modifies MakeCallback to call its target function through a
JS function that installs a CatchClause and manually calls _fatalException
on error, if the process is both using domains and is in abort mode.

Semver: patch
PR-URL: https://github.com/iojs/io.js/pull/922
Fixes: https://github.com/iojs/io.js/issues/836
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-25 14:01:29 -08:00
Evan Lucas 2ca22aacbd http: emit abort event from ClientRequest
ClientRequest will now emit an abort event the first time abort()
is called.

Semver: Minor
Fixes: https://github.com/joyent/node/issues/9278
PR-URL: https://github.com/iojs/io.js/pull/945
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-25 16:40:31 -05:00
Ben Noordhuis 506c7fd40b test: fix infinite spawn cycle in stdio test
Fix parallel/test-stdio-closed introduced in commit b5f25a9 ("src:
ensure that file descriptors 0-2 are valid") to not keep spawning
child processes ad infinitum.

The test spawns itself as a child process but a missing return statement
made the child process spawn itself again, and again, and again.

It went unnoticed for some time because the child process exits almost
immediately afterwards, i.e. it didn't fill up the process table.  The
observable effect was an iojs process that was quietly consuming CPU
cyles in the background with a PID that was constantly changing.

Refs: https://github.com/iojs/io.js/pull/938
PR-URL: https://github.com/iojs/io.js/pull/948
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-02-25 11:13:03 +01:00
Petka Antonov 872702d9b7 node: implement unhandled rejection tracking
Implement unhandled rejection tracking for promises as
specified in https://gist.github.com/benjamingr/0237932cee84712951a2

Fixes #256
PR-URL: https://github.com/iojs/io.js/pull/758
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Domenic Denicola <domenic@domenicdenicola.com>
2015-02-24 18:27:14 -06:00
Fedor Indutny 1738c77835 streams: introduce StreamWrap and JSStream
Introduce a way to wrap plain-js `stream.Duplex` streams into C++
StreamBase's child class. With such method at hand it is now possible to
pass `stream.Duplex` instance as a `socket` parameter to
`tls.connect()`.

PR-URL: https://github.com/iojs/io.js/pull/926
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-24 22:38:21 +03:00
cjihrig ed3b057e9f util: handle symbols properly in format()
Currently, if util.format() is called with a string as its first
argument, and a Symbol as one of the subsequent arguments, an
exception is thrown due to an attempted implicit string conversion.
This commit causes Symbols to be explicitly converted.

Fixes: https://github.com/iojs/io.js/issues/927
PR-URL: https://github.com/iojs/io.js/pull/931
Reviewed-By: Domenic Denicola <domenic@domenicdenicola.com>
2015-02-24 10:14:24 -05:00
Brendan Ashworth 0df54303c1 test: common.js -> common
This commit changes many test styles to change all references
from require('./common.js'); to require('./common');.

The latter is much more common, with the former only being used in 50
tests. It is just a stylistic change, and it seems that `common.js` was
introduced by a rogue test and copied and pasted into the rest.

Semver: patch
PR-URL: https://github.com/iojs/io.js/pull/917
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-22 19:34:17 -08:00
Fedor Indutny b9686233fc stream_base: introduce StreamBase
StreamBase is an improved way to write C++ streams. The class itself is
for separting `StreamWrap` (with the methods like `.writeAsciiString`,
`.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making
possible to write abstract C++ streams that are not bound to any uv
socket.

The following methods are important part of the abstraction (which
mimics libuv's stream API):

* Events:
  * `OnAlloc(size_t size, uv_buf_t*)`
  * `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)`
  * `OnAfterWrite(WriteWrap*)`
* Wrappers:
  * `DoShutdown(ShutdownWrap*)`
  * `DoTryWrite(uv_buf_t** bufs, size_t* count)`
  * `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)`
  * `Error()`
  * `ClearError()`

The implementation should provide all of these methods, thus providing
the access to the underlying resource (be it uv handle, TLS socket, or
anything else).

A C++ stream may consume the input of another stream by replacing the
event callbacks and proxying the writes. This kind of API is actually
used now for the TLSWrap implementation, making it possible to wrap TLS
stream into another TLS stream. Thus legacy API calls are no longer
required in `_tls_wrap.js`.

PR-URL: https://github.com/iojs/io.js/pull/840
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-22 22:31:57 +03:00