File tree 2 files changed +18
-0
lines changed 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,16 @@ def transport(self, sid):
534
534
"""
535
535
return self .eio .transport (sid )
536
536
537
+ def get_environ (self , sid , namespace = None ):
538
+ """Return the WSGI environ dictionary for a client.
539
+
540
+ :param sid: The session of the client.
541
+ :param namespace: The Socket.IO namespace. If this argument is omitted
542
+ the default namespace is used.
543
+ """
544
+ eio_sid = self .manager .eio_sid_from_sid (sid , namespace or '/' )
545
+ return self .environ .get (eio_sid )
546
+
537
547
def handle_request (self , environ , start_response ):
538
548
"""Handle an HTTP request from the client.
539
549
Original file line number Diff line number Diff line change @@ -746,6 +746,14 @@ def is_asyncio_based(self):
746
746
with pytest .raises (ValueError ):
747
747
s .register_namespace (AsyncNS ())
748
748
749
+ def test_get_environ (self , eio ):
750
+ s = server .Server ()
751
+ s ._handle_eio_connect ('123' , 'environ' )
752
+ s ._handle_eio_message ('123' , '0' )
753
+ sid = s .manager .sid_from_eio_sid ('123' , '/' )
754
+ assert s .get_environ (sid ) == 'environ'
755
+ assert s .get_environ ('foo' ) is None
756
+
749
757
def test_logger (self , eio ):
750
758
s = server .Server (logger = False )
751
759
assert s .logger .getEffectiveLevel () == logging .ERROR
You can’t perform that action at this time.
0 commit comments