Mercurial > libervia-web
diff libervia/server/server.py @ 1203:251eba911d4d
server (websockets): fixed websocket handling on HTTPS connections:
Original request used to retrieve a page was stored on dynamic pages, but after the end of
it, the channel was deleted, resulting in a isSecure() always returning False, and
troubles in chain leading to the the use of the wrong session object. This patch fixes
this by reworking the way original request is used, and creating a new wrapping class
allowing to keep an API similar to iweb.IRequest, with data coming from both the original
request and the websocket request.
fix 327
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Jul 2019 14:45:51 +0200 |
parents | 3f791fbc1643 |
children | a2df53dfbf46 |
line wrap: on
line diff
--- a/libervia/server/server.py Fri Jul 12 14:58:11 2019 +0200 +++ b/libervia/server/server.py Sun Jul 14 14:45:51 2019 +0200 @@ -27,6 +27,7 @@ import urlparse import urllib import time +import copy from twisted.application import service from twisted.internet import reactor, defer, inotify from twisted.web import server @@ -2658,7 +2659,11 @@ return self.getExtBaseURL(request, path=scheme, scheme=scheme) def registerWSToken(self, token, page, request): - websockets.LiberviaPageWSProtocol.registerToken(token, page, request) + # we make a shallow copy of request to avoid losing request.channel when + # connection is lost (which would result as request.isSecure() being always + # False). See #327 + request._signal_id = id(request) + websockets.LiberviaPageWSProtocol.registerToken(token, page, copy.copy(request)) ## Various utils ##