@ -1,37 +1,38 @@
'use strict' ;
'use strict' ;
var common = require ( '../common' ) ;
const common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
if ( ! common . hasCrypto ) {
if ( ! common . hasCrypto ) {
common . skip ( 'missing crypto' ) ;
common . skip ( 'missing crypto' ) ;
return ;
return ;
}
}
var tls = require ( 'tls ' ) ;
const assert = require ( 'asser t' ) ;
var f s = require ( 'f s' ) ;
const tl s = require ( 'tl s' ) ;
var dir = common . fixturesDir ;
const fs = require ( 'fs' ) ;
var options = { key : fs . readFileSync ( dir + '/test_key.pem' ) ,
cert : fs . readFileSync ( dir + '/test_cert.pem' ) ,
ca : [ fs . readFileSync ( dir + '/test_ca.pem' ) ] } ;
var writes = [
const dir = common . fixturesDir ;
const options = { key : fs . readFileSync ( dir + '/test_key.pem' ) ,
cert : fs . readFileSync ( dir + '/test_cert.pem' ) ,
ca : [ fs . readFileSync ( dir + '/test_ca.pem' ) ] } ;
const writes = [
'some server data' ,
'some server data' ,
'and a separate packet' ,
'and a separate packet' ,
'and one more' ,
'and one more' ,
] ;
] ;
var receivedWrites = 0 ;
let receivedWrites = 0 ;
var server = tls . createServer ( options , function ( c ) {
const server = tls . createServer ( options , function ( c ) {
writes . forEach ( function ( str ) {
writes . forEach ( function ( str ) {
c . write ( str ) ;
c . write ( str ) ;
} ) ;
} ) ;
} ) . listen ( 0 , function ( ) {
} ) . listen ( 0 , common . mustCall ( function ( ) {
const connectOpts = { rejectUnauthorized : false } ;
const connectOpts = { rejectUnauthorized : false } ;
var c = tls . connect ( this . address ( ) . port , connectOpts , function ( ) {
const c = tls . connect ( this . address ( ) . port , connectOpts , function ( ) {
c . write ( 'some client data' ) ;
c . write ( 'some client data' ) ;
c . on ( 'readable' , function ( ) {
c . on ( 'readable' , function ( ) {
var data = c . read ( ) ;
let data = c . read ( ) ;
if ( data === null )
if ( data === null )
return ;
return ;
@ -47,8 +48,9 @@ var server = tls.createServer(options, function(c) {
}
}
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ) ;
process . on ( 'exit' , function ( ) {
process . on ( 'exit' , function ( ) {
assert . e qual( receivedWrites , writes . length ) ;
assert . strictE qual( receivedWrites , writes . length ) ;
} ) ;
} ) ;