Esempio n. 1
0
 def render(self, request):
     # Get around .parent limitation
     if self._factory is None:
         self._makeFactory()
     # Override handling of invalid methods, returning 400 makes SockJS mad
     if request.method != 'GET':
         request.setResponseCode(405)
         request.defaultContentType = None # SockJS wants this gone
         request.setHeader('Allow','GET')
         return ""
     # Override handling of lack of headers, again SockJS requires non-RFC stuff
     upgrade = request.getHeader("Upgrade")
     if upgrade is None or "websocket" not in upgrade.lower():
         request.setResponseCode(400)
         return 'Can "Upgrade" only to "WebSocket".'
     connection = request.getHeader("Connection")
     if connection is None or "upgrade" not in connection.lower():
         request.setResponseCode(400)
         return '"Connection" must be "Upgrade".'
     # Defer to inherited methods
     ret = WebSocketsResource.render(self, request) # For RFC versions of websockets
     if ret is NOT_DONE_YET:
         return ret
     return OldWebSocketsResource.render(self, request) # For non-RFC versions of websockets
Esempio n. 2
0
 def _makeFactory(self):
     f = JsonFactory(self.parent._factory)
     WebSocketsResource.__init__(self, f)
     OldWebSocketsResource.__init__(self, f)
Esempio n. 3
0
 def _makeFactory(self):
     f = PeerOverrideFactory(self.parent._factory)
     WebSocketsResource.__init__(self, self.parent._factory) 
     OldWebSocketsResource.__init__(self, self.parent._factory)
Esempio n. 4
0
 def _makeFactory(self):
     f = PeerOverrideFactory(self.parent._factory)
     WebSocketsResource.__init__(self, self.parent._factory) 
     OldWebSocketsResource.__init__(self, self.parent._factory)
Esempio n. 5
0
 def _makeFactory(self):
     f = JsonFactory(self.parent._factory)
     WebSocketsResource.__init__(self, f)
     OldWebSocketsResource.__init__(self, f)
Esempio n. 6
0
 def _makeFactory(self):
     WebSocketsResource.__init__(self, self.parent._factory) 
     OldWebSocketsResource.__init__(self, self.parent._factory)