Merge local changes.
This commit is contained in:
commit
3696e5296d
4 changed files with 16 additions and 6 deletions
src/common
test/integration
|
@ -462,7 +462,10 @@ class XMPPDispatcher(PlugIn):
|
|||
# we have released dispatcher, so self._owner has no methods
|
||||
if not res:
|
||||
return
|
||||
self._owner.remove_timeout()
|
||||
if 'remove_timeout' in self._owner.__dict__:
|
||||
# When we receive data after we started disconnecting, Transport may
|
||||
# already be plugged out
|
||||
self._owner.remove_timeout()
|
||||
for (_id, _iq) in self._expected.items():
|
||||
if _iq is None:
|
||||
# If the expected Stanza would have arrived, ProcessNonBlocking
|
||||
|
|
|
@ -648,7 +648,8 @@ class NonBlockingHTTP(NonBlockingTCP):
|
|||
|
||||
# append currently received data to HTTP msg in buffer
|
||||
self.recvbuff = '%s%s' % (self.recvbuff or '', data)
|
||||
statusline, headers, httpbody, self.recvbuff = self.parse_http_message(self.recvbuff)
|
||||
statusline, headers, httpbody, buffer_rest = self.parse_http_message(
|
||||
self.recvbuff)
|
||||
|
||||
if not (statusline and headers and httpbody):
|
||||
log.debug('Received incomplete HTTP response')
|
||||
|
@ -668,6 +669,10 @@ class NonBlockingHTTP(NonBlockingTCP):
|
|||
log.info('not enough bytes in HTTP response - %d expected, %d got' %
|
||||
(self.expected_length, len(self.recvbuff)))
|
||||
else:
|
||||
# First part of buffer has been extraced and is going to be handled,
|
||||
# remove it from buffer
|
||||
self.recvbuff = buffer_rest
|
||||
|
||||
# everything was received
|
||||
self.expected_length = 0
|
||||
|
||||
|
@ -702,7 +707,7 @@ class NonBlockingHTTP(NonBlockingTCP):
|
|||
headers.append('Connection: Keep-Alive')
|
||||
headers.append('\r\n')
|
||||
headers = '\r\n'.join(headers)
|
||||
return('%s%s\r\n' % (headers, httpbody))
|
||||
return('%s%s' % (headers, httpbody))
|
||||
|
||||
def parse_http_message(self, message):
|
||||
'''
|
||||
|
@ -711,6 +716,7 @@ class NonBlockingHTTP(NonBlockingTCP):
|
|||
headers - dictionary of headers e.g. {'Content-Length': '604',
|
||||
'Content-Type': 'text/xml; charset=utf-8'},
|
||||
httpbody - string with http body)
|
||||
http_rest - what is left in the message after a full HTTP header + body
|
||||
'''
|
||||
message = message.replace('\r','')
|
||||
splitted = message.split('\n\n')
|
||||
|
|
|
@ -494,7 +494,7 @@ class P2PConnection(IdleObject, PlugIn):
|
|||
self.disconnect()
|
||||
return True
|
||||
|
||||
def disconnect(self):
|
||||
def disconnect(self, message=''):
|
||||
''' Closes the socket. '''
|
||||
gajim.idlequeue.remove_timeout(self.fd)
|
||||
gajim.idlequeue.unplug_idle(self.fd)
|
||||
|
|
|
@ -262,9 +262,10 @@ class TestNonBlockingHTTP(AbstractTransportTest):
|
|||
% payload
|
||||
message = "%s%s" % (header, body)
|
||||
|
||||
chunk1, chunk2, chunk3 = message[:20], message[20:73], message[73:]
|
||||
chunk1, chunk2, chunk3, chunk4 = message[:20], message[20:73], \
|
||||
message[73:85], message[85:]
|
||||
nextmessage_chunk = "\r\n\r\nHTTP/1.1 200 OK\r\nContent-Type: text/x"
|
||||
chunks = (chunk1, chunk2, chunk3, nextmessage_chunk)
|
||||
chunks = (chunk1, chunk2, chunk3, chunk4, nextmessage_chunk)
|
||||
|
||||
transport.onreceive(self.expect_receive(body, msg='Failed: In chunks'))
|
||||
for chunk in chunks:
|
||||
|
|
Loading…
Add table
Reference in a new issue