@@ -41,7 +41,8 @@ var CIPHERS = [
41
41
* Creates and listens on both HTTP and HTTPS servers.
42
42
*/
43
43
module . exports = function createServers ( options , listening ) {
44
- if ( ! options || ( ! options . http && ! options . https )
44
+ if ( ! options
45
+ || ( typeof options . http === 'undefined' && typeof options . https === 'undefined' )
45
46
|| ( ! options . handler && ! options . http . handler && ! options . https . handler ) ) {
46
47
return listening ( new Error ( 'handler, http and/or https are required options.' ) ) ;
47
48
}
@@ -87,22 +88,19 @@ module.exports = function createServers(options, listening) {
87
88
// Attempts to create and listen on the the HTTP server.
88
89
//
89
90
function createHttp ( ) {
90
- if ( ! options . http ) {
91
+ if ( typeof options . http === 'undefined' ) {
91
92
log ( 'http | no options.http; no server' ) ;
92
93
return onListen ( 'http' ) ;
93
94
}
94
95
95
96
if ( typeof options . http !== 'object' ) {
96
97
options . http = {
97
- // accept both a string and a number
98
- port : ! isNaN ( options . http )
99
- ? + options . http
100
- : false
98
+ port : options . http
101
99
} ;
102
100
}
103
101
104
102
var server = http . createServer ( options . http . handler || handler ) ,
105
- port = options . http . port || 80 ,
103
+ port = ! isNaN ( options . http . port ) ? + options . http . port : 80 , // accepts string or number
106
104
args ;
107
105
108
106
args = [ server , port ] ;
@@ -120,13 +118,13 @@ module.exports = function createServers(options, listening) {
120
118
// Attempts to create and listen on the HTTPS server.
121
119
//
122
120
function createHttps ( next ) {
123
- if ( ! options . https ) {
121
+ if ( typeof options . https === 'undefined' ) {
124
122
log ( 'https | no options.https; no server' ) ;
125
123
return onListen ( 'https' ) ;
126
124
}
127
125
128
126
var ssl = options . https ,
129
- port = + ssl . port || 443 ,
127
+ port = ! isNaN ( ssl . port ) ? + ssl . port : 443 , // accepts string or number
130
128
ciphers = ssl . ciphers || CIPHERS ,
131
129
ca = ssl . ca ,
132
130
server ,
0 commit comments