Incorporating Michael Carter's websocket patch that includes query strings in the location headers.
This commit is contained in:
3
AUTHORS
3
AUTHORS
@@ -55,7 +55,8 @@ Thanks To
|
||||
* Benoit Chesneau, bug report on green.os and patch to fix it
|
||||
* Slant, better iterator implementation in tpool
|
||||
* Ambroff, nice pygtk hub example
|
||||
* Michael Carter, and Marcin Bachry, nice repro of a bug and good diagnosis leading to the fix
|
||||
* Michael Carter, websocket patch to improve location handling
|
||||
* Marcin Bachry, nice repro of a bug and good diagnosis leading to the fix
|
||||
* David Ziegler, reporting issue #53
|
||||
* Favo Yang, twisted hub patch
|
||||
* Schmir, patch that fixes readline method with chunked encoding in wsgi.py
|
||||
|
@@ -71,27 +71,33 @@ class WebSocketWSGI(object):
|
||||
response = md5(key).digest()
|
||||
|
||||
# Start building the response
|
||||
location = 'ws://%s%s%s' % (
|
||||
environ.get('HTTP_HOST'),
|
||||
environ.get('SCRIPT_NAME'),
|
||||
environ.get('PATH_INFO')
|
||||
)
|
||||
qs = environ.get('QUERY_STRING')
|
||||
if qs:
|
||||
location += '?' + qs
|
||||
if self.protocol_version == 75:
|
||||
handshake_reply = ("HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
|
||||
"Upgrade: WebSocket\r\n"
|
||||
"Connection: Upgrade\r\n"
|
||||
"WebSocket-Origin: %s\r\n"
|
||||
"WebSocket-Location: ws://%s%s\r\n\r\n" % (
|
||||
"WebSocket-Location: %s\r\n\r\n" % (
|
||||
environ.get('HTTP_ORIGIN'),
|
||||
environ.get('HTTP_HOST'),
|
||||
environ.get('PATH_INFO')))
|
||||
location))
|
||||
elif self.protocol_version == 76:
|
||||
handshake_reply = ("HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
|
||||
"Upgrade: WebSocket\r\n"
|
||||
"Connection: Upgrade\r\n"
|
||||
"Sec-WebSocket-Origin: %s\r\n"
|
||||
"Sec-WebSocket-Protocol: %s\r\n"
|
||||
"Sec-WebSocket-Location: ws://%s%s\r\n"
|
||||
"Sec-WebSocket-Location: %s\r\n"
|
||||
"\r\n%s"% (
|
||||
environ.get('HTTP_ORIGIN'),
|
||||
environ.get('HTTP_SEC_WEBSOCKET_PROTOCOL', 'default'),
|
||||
environ.get('HTTP_HOST'),
|
||||
environ.get('PATH_INFO'),
|
||||
location,
|
||||
response))
|
||||
else: #pragma NO COVER
|
||||
raise ValueError("Unknown WebSocket protocol version.")
|
||||
|
Reference in New Issue
Block a user