tls: set _connecting before starting the flow

When creating a TLSSocket instance based on the existing connecting
socket, `_connecting` property is copied after the initialization of
`net.Socket`. However, since `net.Socket` constructor will call
`.read(0)` if the `readable` is true - error may happen at this code
chunk in net.js:

    Socket.prototype._read = function(n) {
      debug('_read');

      if (this._connecting || !this._handle) {
        debug('_read wait for connection');
        this.once('connect', this._read.bind(this, n));
    ...

Leading to a test failures on windows:

 - test/simple/test-tls-connect-given-socket.js

Signed-off-by: Fedor Indutny <fedor@indutny.com>
tls: support OCSP on client and server
tls: `getPeerCertificate(detailed)`

Add `raw` property to certificate, add mode to output full certificate
chain.
src: lint after OCSP commits
crypto: work around OpenSSL oddness

OpenSSL behaves oddly: on client `cert_chain` contains
the `peer_certificate`, but on server it doesn't.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
crypto: fix memory leak in CipherBase::Final

fix #7497

Signed-off-by: Fedor Indutny <fedor@indutny.com>
doc: tls: added path property to tls.connect

In tls.connect a unix socket connection to a path may be made in
recent versions of node by specifying the value for the path
property.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
deps: provide TXT chunk info in c-ares

Provide more information in `ares_txt_reply` to coalesce chunks from the
same record into one string.

fix #7367
http: add request.flush() method

Forcibly flushes the request headers.  You need this with long-lived
HTTP connections where the first data isn't written until the connection
has been established (think: tunneling requests over HTTP CONNECT.)

Fixes #7296.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
vm: assign Environment to created context

ContextifyContext::CreateV8Context is now create context
with Environment pointer

Signed-off-by: Fedor Indutny <fedor@indutny.com>
buffer: add compare and equals methods

compare() works like String.localeCompare such that:

    Buffer.compare(a, b) === a.compare(b);

equals() does a native check to see if two buffers are equal.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
crypto: fix a couple of VC++ warnings

Signed-off-by: Fedor Indutny <fedor@indutny.com>
crypto: improve error messages

1) ThrowCryptoTypeErrors was not actually used for
   type-related errors. Removed it.
2) For AEAD modes, OpenSSL does not set any internal
   error information if Final does not complete suc-
   cessfully. Therefore, "TypeError:error:00000000:l
   ib(0):func(0):reason(0)" would be the error mess-
   age. Use a default message for these cases.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
child_process: fix assertion error in spawnSync

When ExitCallback was not called with an error such as ENOENT in
uv_spawn, the process handle still remains refed and needs to be closed.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
test: update test-dns.js after a60a9b0

resolveTxt now returns a 2-d array for all the chunks string chunks
relating to the record
stream: split `objectMode` for Duplex

This commit introduces `readableObjectMode` and
`writableObjectMode` options for Duplex streams.
This can be used mostly to make parsers and
serializers with Transform streams.

Also the docs section about stream state objects
is removed, because it is not relevant anymore.
The example from the section is remade to show
new options.

fixes #6284

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>