File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -292,16 +292,16 @@ export class Socket<
292292 */
293293 private buildHandshake ( auth : object ) : Handshake {
294294 return {
295- headers : this . request . headers ,
295+ headers : this . request ? .headers || { } ,
296296 time : new Date ( ) + "" ,
297297 address : this . conn . remoteAddress ,
298- xdomain : ! ! this . request . headers . origin ,
298+ xdomain : ! ! this . request ? .headers . origin ,
299299 // @ts -ignore
300- secure : ! ! this . request . connection . encrypted ,
300+ secure : ! this . request || ! ! this . request . connection . encrypted ,
301301 issued : + new Date ( ) ,
302- url : this . request . url ! ,
302+ url : this . request ? .url ! ,
303303 // @ts -ignore
304- query : this . request . _query ,
304+ query : this . request ? ._query || { } ,
305305 auth,
306306 } ;
307307 }
Original file line number Diff line number Diff line change @@ -684,6 +684,23 @@ describe("socket", () => {
684684 } ) ;
685685 } ) ;
686686
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+
687704 it ( "should handle very large json" , function ( done ) {
688705 this . timeout ( 30000 ) ;
689706 const io = new Server ( 0 , { perMessageDeflate : false } ) ;
You can’t perform that action at this time.
0 commit comments