@@ -3860,16 +3860,18 @@ describe('WebSocket', () => {
3860
3860
3861
3861
it ( 'honors the `finishRequest` option' , ( done ) => {
3862
3862
const wss = new WebSocket . Server ( { port : 0 } , ( ) => {
3863
- const ws = new WebSocket ( `ws://localhost:${ wss . address ( ) . port } ` , {
3864
- finishRequest ( request , websocket ) {
3865
- process . nextTick ( ( ) => {
3866
- assert . strictEqual ( request , ws . _req ) ;
3867
- assert . strictEqual ( websocket , ws ) ;
3868
- } ) ;
3869
- request . on ( 'socket' , ( socket ) => {
3863
+ const host = `localhost:${ wss . address ( ) . port } ` ;
3864
+ const ws = new WebSocket ( `ws://${ host } ` , {
3865
+ finishRequest ( req , ws ) {
3866
+ assert . ok ( req instanceof http . ClientRequest ) ;
3867
+ assert . strictEqual ( req . getHeader ( 'host' ) , host ) ;
3868
+ assert . ok ( ws instanceof WebSocket ) ;
3869
+ assert . strictEqual ( req , ws . _req ) ;
3870
+
3871
+ req . on ( 'socket' , ( socket ) => {
3870
3872
socket . on ( 'connect' , ( ) => {
3871
- request . setHeader ( 'Cookie' , 'foo=bar' ) ;
3872
- request . end ( ) ;
3873
+ req . setHeader ( 'Cookie' , 'foo=bar' ) ;
3874
+ req . end ( ) ;
3873
3875
} ) ;
3874
3876
} ) ;
3875
3877
}
0 commit comments