本文整理汇总了Python中twisted.web.http.HTTPChannel.site方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPChannel.site方法的具体用法?Python HTTPChannel.site怎么用?Python HTTPChannel.site使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.http.HTTPChannel
的用法示例。
在下文中一共展示了HTTPChannel.site方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dataReceived
# 需要导入模块: from twisted.web.http import HTTPChannel [as 别名]
# 或者: from twisted.web.http.HTTPChannel import site [as 别名]
def dataReceived(self, data):
if self.protocol:
# Pass the data off to the real protocol
return self.protocol.dataReceived(data)
# Try to determine the protocol requested
if self.data:
data = self.data + data
self.data = data
self.log.debug("Received %r", data)
if len(data) >= 4:
if "\0" in data:
# Binary data; use DCSP
self.switchProtocol(DaideServerProtocol())
self.transport.setTcpKeepAlive(True)
elif data.startswith("DPP/"):
self.switchProtocol(DppProtocol())
self.transport.setTcpKeepAlive(True)
else:
# Probably text; switch to HTTP
proto = HTTPChannel()
# Simulate Site.buildProtocol()
site = self.factory.site
proto.site = site
proto.requestFactory = site.requestFactory
proto.timeOut = site.timeOut
self.switchProtocol(proto)