def info(self, request): response = request.response response.content_type = 'application/json; charset=UTF-8' response.headerlist.append( ('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')) response.headerlist.extend(cors_headers(request)) if request.method == 'OPTIONS': session_cookie(request) response.status = 204 response.headerlist.append( ("Access-Control-Allow-Methods", "OPTIONS, GET")) response.headerlist.extend(cache_headers(request)) return response info = {'entropy': random.randint(1, 2147483647), 'websocket': 'websocket' not in self.disable_transports, 'cookie_needed': self.cookie_needed, 'origins': ['*:*']} response.body = json.dumps(info) return response
def handler(self, request): matchdict = request.matchdict # lookup transport tid = matchdict['transport'] if tid not in handlers or tid in self.disable_transports: return HTTPNotFound() create, transport = handlers[tid] # session manager = self.session_manager sid = matchdict['session'] if not sid or '.' in sid or '.' in matchdict['server']: return HTTPNotFound() if self.per_user: sid = (authenticated_userid(request), sid) try: session = manager.get(sid, create, request=request) except KeyError: return HTTPNotFound(headers=(session_cookie(request),)) request.environ['wsgi.sockjs_session'] = session # websocket if tid == 'websocket': if 'HTTP_SEC_WEBSOCKET_VERSION' in request.environ: res = init_websocket(request) elif 'HTTP_ORIGIN' in request.environ: res = init_websocket_hixie(request) else: res = init_websocket(request) if res is not None: return res try: return transport(session, request) except Exception as exc: session.release() log.exception('Exception in transport: %s'%tid) return HTTPBadRequest(str(exc))
def handler(self, request): matchdict = request.matchdict # lookup transport tid = matchdict['transport'] if tid not in handlers or tid in self.disable_transports: return HTTPNotFound() create, transport = handlers[tid] # session manager = self.session_manager sid = matchdict['session'] if not sid or '.' in sid or '.' in matchdict['server']: return HTTPNotFound() if self.per_user: sid = (authenticated_userid(request), sid) try: session = manager.get(sid, create, request=request) except KeyError: return HTTPNotFound(headers=(session_cookie(request), )) request.environ['wsgi.sockjs_session'] = session # websocket if tid == 'websocket': if 'HTTP_SEC_WEBSOCKET_VERSION' in request.environ: res = init_websocket(request) elif 'HTTP_ORIGIN' in request.environ: res = init_websocket_hixie(request) else: res = init_websocket(request) if res is not None: return res try: return transport(session, request) except Exception as exc: session.release() log.exception('Exception in transport: %s' % tid) return HTTPBadRequest(str(exc))