本文整理汇总了Python中twisted.web.http.HTTPChannel.dataReceived方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPChannel.dataReceived方法的具体用法?Python HTTPChannel.dataReceived怎么用?Python HTTPChannel.dataReceived使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.http.HTTPChannel
的用法示例。
在下文中一共展示了HTTPChannel.dataReceived方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: YaybuChannel
# 需要导入模块: from twisted.web.http import HTTPChannel [as 别名]
# 或者: from twisted.web.http.HTTPChannel import dataReceived [as 别名]
class YaybuChannel(channel.SSHChannel):
name = 'session'
def __init__(self, task):
channel.SSHChannel.__init__(self)
self.protocol = HTTPChannel()
self.protocol.requestFactory = self.request_factory
self.protocol.transport = self
self.disconnecting = False
self.task = task
def request_factory(self):
return YaybuRequest(self.task)
def openFailed(self, reason):
print 'echo failed', reason
def channelOpen(self, ignoredData):
self.data = ''
d = self.conn.sendRequest(self, 'exec', common.NS('yaybu --remote -'), wantReply = 1)
#d.addCallback(self._cbRequest)
def _cbRequest(self, ignored):
#self.write('hello conch\n')
#self.conn.sendEOF(self)
pass
def dataReceived(self, data):
self.protocol.dataReceived(data)
def closed(self):
self.loseConnection()
reactor.stop()
示例2: dataReceived
# 需要导入模块: from twisted.web.http import HTTPChannel [as 别名]
# 或者: from twisted.web.http.HTTPChannel import dataReceived [as 别名]
def dataReceived(self, data):
if data.startswith("<policy-file-request/>"):
policy = (
'<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM '
'"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">'
'<cross-domain-policy><allow-access-from domain="*" '
'to-ports="*" /></cross-domain-policy>')
self.transport.write(policy)
self.transport.loseConnection()
else:
return HTTPChannel.dataReceived(self, data)