File tree 2 files changed +22
-5
lines changed
2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -292,16 +292,16 @@ export class Socket<
292
292
*/
293
293
private buildHandshake ( auth : object ) : Handshake {
294
294
return {
295
- headers : this . request . headers ,
295
+ headers : this . request ? .headers || { } ,
296
296
time : new Date ( ) + "" ,
297
297
address : this . conn . remoteAddress ,
298
- xdomain : ! ! this . request . headers . origin ,
298
+ xdomain : ! ! this . request ? .headers . origin ,
299
299
// @ts -ignore
300
- secure : ! ! this . request . connection . encrypted ,
300
+ secure : ! this . request || ! ! this . request . connection . encrypted ,
301
301
issued : + new Date ( ) ,
302
- url : this . request . url ! ,
302
+ url : this . request ? .url ! ,
303
303
// @ts -ignore
304
- query : this . request . _query ,
304
+ query : this . request ? ._query || { } ,
305
305
auth,
306
306
} ;
307
307
}
Original file line number Diff line number Diff line change @@ -684,6 +684,23 @@ describe("socket", () => {
684
684
} ) ;
685
685
} ) ;
686
686
687
+ it ( "should handshake a client without access to the Engine.IO request (WebTransport-only connection)" , ( done ) => {
688
+ const io = new Server ( 0 ) ;
689
+ const clientSocket = createClient ( io , "/" ) ;
690
+
691
+ io . engine . on ( "connection" , ( socket ) => {
692
+ delete socket . request ;
693
+ } ) ;
694
+
695
+ io . on ( "connection" , ( socket ) => {
696
+ expect ( socket . handshake . secure ) . to . be ( true ) ;
697
+ expect ( socket . handshake . headers ) . to . eql ( { } ) ;
698
+ expect ( socket . handshake . query ) . to . eql ( { } ) ;
699
+
700
+ success ( done , io , clientSocket ) ;
701
+ } ) ;
702
+ } ) ;
703
+
687
704
it ( "should handle very large json" , function ( done ) {
688
705
this . timeout ( 30000 ) ;
689
706
const io = new Server ( 0 , { perMessageDeflate : false } ) ;
You can’t perform that action at this time.
0 commit comments