Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/waitress/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,10 @@ def get_environment(self):
# channel_request_lookahead larger than 0.
environ["waitress.client_disconnected"] = self.channel.check_client_disconnected

# Insert the raw socket object into the environment that allows the
# application to upgrade to WebSocket communication.
environ["waitress.socket"] = self.channel.socket

# cache the environ for this request
self.environ = environ
return environ
3 changes: 3 additions & 0 deletions tests/test_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import socket
import unittest


Expand Down Expand Up @@ -804,6 +805,7 @@ def test_get_environment_values(self):
"SERVER_PROTOCOL",
"SERVER_SOFTWARE",
"waitress.client_disconnected",
"waitress.socket",
"wsgi.errors",
"wsgi.file_wrapper",
"wsgi.input",
Expand Down Expand Up @@ -960,6 +962,7 @@ class DummyChannel:
adj = DummyAdj()
creation_time = 0
addr = ("127.0.0.1", 39830)
socket = socket.socket()

def check_client_disconnected(self):
# For now, until we have tests handling this feature
Expand Down