@@ -487,6 +487,69 @@ describe('lib/http-proxy.js', function() {
487487 } ) ;
488488 } ) ;
489489 } ) ;
490+
491+ it ( 'should forward frames with single frame payload (including on node 4.x)' , function ( done ) {
492+ var payload = Array ( 65529 ) . join ( '0' ) ;
493+ var ports = { source : gen . port , proxy : gen . port } ;
494+ var proxy = httpProxy . createProxyServer ( {
495+ target : 'ws://127.0.0.1:' + ports . source ,
496+ ws : true
497+ } ) ,
498+ proxyServer = proxy . listen ( ports . proxy ) ,
499+ destiny = new ws . Server ( { port : ports . source } , function ( ) {
500+ var client = new ws ( 'ws://127.0.0.1:' + ports . proxy ) ;
501+
502+ client . on ( 'open' , function ( ) {
503+ client . send ( payload ) ;
504+ } ) ;
505+
506+ client . on ( 'message' , function ( msg ) {
507+ expect ( msg ) . to . be ( 'Hello over websockets' ) ;
508+ client . close ( ) ;
509+ proxyServer . close ( ) ;
510+ destiny . close ( ) ;
511+ done ( ) ;
512+ } ) ;
513+ } ) ;
514+
515+ destiny . on ( 'connection' , function ( socket ) {
516+ socket . on ( 'message' , function ( msg ) {
517+ expect ( msg ) . to . be ( payload ) ;
518+ socket . send ( 'Hello over websockets' ) ;
519+ } ) ;
520+ } ) ;
521+ } ) ;
490522
491- } )
523+ it ( 'should forward continuation frames with big payload (including on node 4.x)' , function ( done ) {
524+ var payload = Array ( 65530 ) . join ( '0' ) ;
525+ var ports = { source : gen . port , proxy : gen . port } ;
526+ var proxy = httpProxy . createProxyServer ( {
527+ target : 'ws://127.0.0.1:' + ports . source ,
528+ ws : true
529+ } ) ,
530+ proxyServer = proxy . listen ( ports . proxy ) ,
531+ destiny = new ws . Server ( { port : ports . source } , function ( ) {
532+ var client = new ws ( 'ws://127.0.0.1:' + ports . proxy ) ;
533+
534+ client . on ( 'open' , function ( ) {
535+ client . send ( payload ) ;
536+ } ) ;
537+
538+ client . on ( 'message' , function ( msg ) {
539+ expect ( msg ) . to . be ( 'Hello over websockets' ) ;
540+ client . close ( ) ;
541+ proxyServer . close ( ) ;
542+ destiny . close ( ) ;
543+ done ( ) ;
544+ } ) ;
545+ } ) ;
546+
547+ destiny . on ( 'connection' , function ( socket ) {
548+ socket . on ( 'message' , function ( msg ) {
549+ expect ( msg ) . to . be ( payload ) ;
550+ socket . send ( 'Hello over websockets' ) ;
551+ } ) ;
552+ } ) ;
553+ } ) ;
554+ } ) ;
492555} ) ;
0 commit comments