本文整理汇总了Python中twisted.web.server.Request.process方法的典型用法代码示例。如果您正苦于以下问题:Python Request.process方法的具体用法?Python Request.process怎么用?Python Request.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.server.Request
的用法示例。
在下文中一共展示了Request.process方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
self.setHeader("Content-Security-Policy", self.HEADER_VALUES)
self.setHeader("X-Content-Security-Policy", self.HEADER_VALUES)
self.setHeader("X-Webkit-CSP", self.HEADER_VALUES)
if self.isSecure():
self.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
Request.process(self)
示例2: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]
if not connection or "upgrade" not in connection.lower():
return Request.process(self)
if not upgrade or upgrade.lower() != "websocket":
return Request.process(self)
return self.processWebSocket()
示例3: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]
if not connection or "Upgrade" not in connection:
return Request.process(self)
if upgrade not in ("WebSocket", "websocket"):
return Request.process(self)
return self.processWebSocket()
示例4: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
upgrade = self.requestHeaders.getRawHeaders("Upgrade")
if not upgrade or upgrade[0] not in ("WebSocket", "websocket"):
return Request.process(self)
connection = self.requestHeaders.getRawHeaders("Connection")
if not connection or "Upgrade" not in [
c.lstrip() for c in connection[0].split(',')]:
return Request.process(self)
return self.processWebSocket()
示例5: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
self.setHeader('Content-Security-Policy', self.CSP_HEADER_VALUES)
self.setHeader('X-Content-Security-Policy', self.CSP_HEADER_VALUES)
self.setHeader('X-Webkit-CSP', self.CSP_HEADER_VALUES)
self.setHeader('X-Frame-Options', 'SAMEORIGIN')
self.setHeader('X-XSS-Protection', '1; mode=block')
self.setHeader('X-Content-Type-Options', 'nosniff')
if self.isSecure():
self.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
Request.process(self)
示例6: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
if self.requestHeaders.getRawHeaders("Upgrade") == ["WebSocket"] and self.requestHeaders.getRawHeaders(
"Connection"
) == ["Upgrade"]:
return self.processWebSocket()
else:
return Request.process(self)
示例7: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
connection = self.requestHeaders.getRawHeaders("Connection", [None])[0]
upgrade = self.requestHeaders.getRawHeaders("Upgrade", [None])[0]
if not connection or "Upgrade" not in connection:
return Request.process(self)
if upgrade not in ("WebSocket", "websocket"):
return Request.process(self)
origin = self.requestHeaders.getRawHeaders('origin', [None])[0]
secOrigin = self.requestHeaders.getRawHeaders('Sec-WebSocket-Origin', [None])[0]
if not origin and not secOrigin:
log.msg('Refusing connection because no origin is set.')
return self.channel.transport.loseConnection()
parsed_origin = urlparse((origin or secOrigin).strip())
if parsed_origin.hostname and '.'.join(parsed_origin.hostname.split('.')[-2:]) in TRUSTED_DOMAINS:
log.msg('Accepting connection from [%s]' % origin)
else:
log.msg('Refusing connection from [%s]' % origin)
return self.channel.transport.loseConnection()
return self.processWebSocket()
示例8: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
# get upgrade headers and switch them to lower case
upgrade_headers = self.requestHeaders.getRawHeaders("Upgrade") or []
upgrade_headers = [h.lower() for h in upgrade_headers]
connection_headers = self.requestHeaders.getRawHeaders("Connection") or []
# get all connection_headers, split each at ',',
# join into a single list and switch them to lower case
connection_headers = itertools.chain(*[re.split(r',\s*', h) for h in connection_headers])
connection_headers = [h.lower() for h in connection_headers]
if ("websocket" in upgrade_headers and "upgrade" in connection_headers):
return self.processWebSocket()
else:
return Request.process(self)
示例9: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
if self._fallbackToBuffered:
return Request.process(self)
# streaming mode
# pause producing on channel until we know what resource
# we deal with
self.channel.transport.pauseProducing()
self.site = self.channel.site
self.setHeader('server', version)
self.setHeader('date', datetimeToString())
self.prepath = []
self.postpath = map(unquote, string.split(self.path[1:], '/'))
try:
self.processResource(self.site.getResourceFor(self))
except:
self.processingFailed(failure.Failure())
示例10: _continue_request
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def _continue_request():
CORE.info('Dispatch request ...')
Request.process(self)
示例11: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
self.setHeader("Content-Security-Policy", self.HEADER_VALUES)
self.setHeader("X-Content-Security-Policy", self.HEADER_VALUES)
self.setHeader("X-Webkit-CSP", self.HEADER_VALUES)
Request.process(self)
示例12: process
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import process [as 别名]
def process(self):
if self.requestHeaders.getRawHeaders('Upgrade') == ['PTTH/1.0'] and self.requestHeaders.getRawHeaders('Connection') == ['Upgrade']:
return self.processWebSocket()
else:
return Request.process(self)