def lineLengthExceeded(self, buffer):
"""
Drop the connection when a server response exceeds the maximum line
length (L{LineOnlyReceiver.MAX_LENGTH}).
@type buffer: L{bytes}
@param buffer: A received line which exceeds the maximum line length.
"""
# XXX - We need to be smarter about this
if self._waiting is not None:
waiting, self._waiting = self._waiting, None
waiting.errback(LineTooLong())
self.transport.loseConnection()
# POP3 Client state logic - don't touch this.
python类LineOnlyReceiver()的实例源码
def sendLine(self, msg):
basic.LineOnlyReceiver.sendLine(self, msg+'\r')
def failResponse(self, message=''):
self.sendLine('-ERR ' + str(message))
# def sendLine(self, line):
# print 'S:', repr(line)
# basic.LineOnlyReceiver.sendLine(self, line)
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
def failResponse(self, message=''):
self.sendLine('-ERR ' + str(message))
# def sendLine(self, line):
# print 'S:', repr(line)
# basic.LineOnlyReceiver.sendLine(self, line)
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
def sendLine(self, msg):
basic.LineOnlyReceiver.sendLine(self, msg+'\r')
def test_lineReceivedNotImplemented(self):
"""
When L{LineOnlyReceiver.lineReceived} is not overridden in a subclass,
calling it raises C{NotImplementedError}.
"""
proto = basic.LineOnlyReceiver()
self.assertRaises(NotImplementedError, proto.lineReceived, 'foo')