本文整理汇总了Python中twisted.internet.interfaces.ITransport方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.ITransport方法的具体用法?Python interfaces.ITransport怎么用?Python interfaces.ITransport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.interfaces
的用法示例。
在下文中一共展示了interfaces.ITransport方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _respondToBadRequestAndDisconnect
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def _respondToBadRequestAndDisconnect(self):
"""
This is a quick and dirty way of responding to bad requests.
As described by HTTP standard we should be patient and accept the
whole request from the client before sending a polite bad request
response, even in the case when clients send tons of data.
@param transport: Transport handling connection to the client.
@type transport: L{interfaces.ITransport}
"""
self.transport.write(b"HTTP/1.1 400 Bad Request\r\n\r\n")
self.loseConnection()
示例2: __init__
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def __init__(self, proto, stdin=0, stdout=1, reactor=None):
if reactor is None:
from twisted.internet import reactor
self.protocol = proto
self._writer = process.ProcessWriter(reactor, self, 'write', stdout)
self._reader = process.ProcessReader(reactor, self, 'read', stdin)
self._reader.startReading()
self.protocol.makeConnection(self)
# ITransport
# XXX Actually, see #3597.
示例3: test_verifyTransport
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def test_verifyTransport(self):
"""
L{_ProcessEndpointTransport}s provide L{ITransport}.
"""
verifyObject(ITransport, self.endpointTransport)
示例4: getPeer
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def getPeer(self):
# FIXME: https://twistedmatrix.com/trac/ticket/7820
# According to ITransport, this should return an IAddress!
return 'file', 'file'
示例5: getHost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def getHost(self):
# FIXME: https://twistedmatrix.com/trac/ticket/7820
# According to ITransport, this should return an IAddress!
return 'file'
示例6: write
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def write(self, data):
if not isinstance(data, bytes):
raise TypeError("Can only write bytes to ITransport")
self.q.put(data)
示例7: test_interface
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def test_interface(self):
"""
L{SSHChannel} instances provide L{interfaces.ITransport}.
"""
self.assertTrue(verifyObject(interfaces.ITransport, self.channel))
示例8: getPeer
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def getPeer(self):
"""
See: L{ITransport.getPeer}
@return: The remote address of this connection.
@rtype: L{SSHTransportAddress}.
"""
return self.conn.transport.getPeer()
示例9: getHost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def getHost(self):
"""
See: L{ITransport.getHost}
@return: An address describing this side of the connection.
@rtype: L{SSHTransportAddress}.
"""
return self.conn.transport.getHost()
示例10: make_framer
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def make_framer():
t = mock.Mock()
alsoProvides(t, ITransport)
f = _Framer(t, b"outbound_prologue\n", b"inbound_prologue\n")
return f, t
示例11: make_con
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def make_con(role, use_relay=False):
clock = Clock()
eq = EventualQueue(clock)
connector = mock.Mock()
alsoProvides(connector, IDilationConnector)
n = mock.Mock() # pretends to be a Noise object
n.write_message = mock.Mock(side_effect=[b"handshake"])
c = DilatedConnectionProtocol(eq, role, "desc", connector, n,
b"outbound_prologue\n", b"inbound_prologue\n")
if use_relay:
c.use_relay(b"relay_handshake\n")
t = mock.Mock()
alsoProvides(t, ITransport)
return c, n, connector, t, eq
示例12: getPeer
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def getPeer(self):
# XXX: According to ITransport, this should return an IAddress!
return 'file', 'file'
示例13: getHost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import ITransport [as 别名]
def getHost(self):
# XXX: According to ITransport, this should return an IAddress!
return 'file'