this._requestCert,
this._rejectUnauthorized);
- this._ssl.setNPNProtocols(NPNProtocols);
+ if (NPN_ENABLED && NPNProtocols) {
++ this.ssl.setNPNProtocols(NPNProtocols);
+ this.npnProtocol = null;
+ }
/* Acts as a r/w stream to the cleartext side of the stream. */
this.cleartext = new CleartextStream(this);
};
- SecurePair.prototype._maybeInitFinished = function() {
- if (this._ssl && !this._secureEstablished && this._ssl.isInitFinished()) {
+ SecurePair.prototype.maybeInitFinished = function() {
+ if (this.ssl && !this._secureEstablished && this.ssl.isInitFinished()) {
+ if (NPN_ENABLED) {
- this.npnProtocol = this._ssl.getNegotiatedProtocol();
++ this.npnProtocol = this.ssl.getNegotiatedProtocol();
+ }
-
this._secureEstablished = true;
debug('secure established');
this.emit('secure');
socket.connect(port, host);
pair.on('secure', function() {
- var verifyError = pair._ssl.verifyError();
+ var verifyError = pair.ssl.verifyError();
+ cleartext.npnProtocol = pair.npnProtocol;
+
if (verifyError) {
cleartext.authorized = false;
cleartext.authorizationError = verifyError;
assert.equal(2, z.length);
assert.equal(0x66, z[0]);
assert.equal(0x6f, z[1]);
+
+assert.equal(0, Buffer('hello').slice(0, 0).length)
+
+b = new Buffer(50);
+b.fill("h");
+for (var i = 0; i < b.length; i++) {
+ assert.equal("h".charCodeAt(0), b[i]);
+}
+
+b.fill(0);
+for (var i = 0; i < b.length; i++) {
+ assert.equal(0, b[i]);
+}
+
+b.fill(1, 16, 32);
+for (var i = 0; i < 16; i++) assert.equal(0, b[i]);
+for (; i < 32; i++) assert.equal(1, b[i]);
+for (; i < b.length; i++) assert.equal(0, b[i]);
+
+ var b = new SlowBuffer(10);
+ b.write('あいうえお', 'ucs2');
+ assert.equal(b.toString('ucs2'), 'あいうえお');