@@ -40,22 +40,48 @@ var serverUtils = {
4040 } ;
4141 } ,
4242 /**
43- * Get either an http or https server
43+ * Get either http or https server
44+ * or use the httpModule provided in options if present
4445 */
4546 getServer : function ( app , options ) {
4647 return {
4748 server : ( function ( ) {
49+
50+ var httpModule = serverUtils . getHttpModule ( options ) ;
51+
4852 if ( options . get ( "scheme" ) === "https" ) {
4953 var pfxPath = options . getIn ( [ "https" , "pfx" ] ) ;
5054 return pfxPath ?
51- https . createServer ( serverUtils . getPFX ( pfxPath ) , app ) :
52- https . createServer ( serverUtils . getKeyAndCert ( options ) , app ) ;
55+ httpModule . createServer ( serverUtils . getPFX ( pfxPath ) , app ) :
56+ httpModule . createServer ( serverUtils . getKeyAndCert ( options ) , app ) ;
5357 }
54- return http . createServer ( app ) ;
58+
59+ return httpModule . createServer ( app ) ;
5560 } ) ( ) ,
5661 app : app
5762 } ;
5863 } ,
64+ getHttpModule : function ( options ) {
65+ /**
66+ * Users may provide a string to be used by nodes
67+ * require lookup.
68+ */
69+ var httpModule = options . get ( "httpModule" ) ;
70+
71+ if ( typeof httpModule === "string" ) {
72+ /**
73+ * Note, this could throw, but let that happen as
74+ * the error message good enough.
75+ */
76+ return require ( httpModule ) ;
77+ }
78+
79+ if ( options . get ( "scheme" ) === "https" ) {
80+ return https ;
81+ }
82+
83+ return http ;
84+ } ,
5985 getMiddlewares : function ( bs ) {
6086
6187 var clientJs = bs . pluginManager . hook ( "client:js" , {
0 commit comments