From ae9f7ca4104f3c28ada49602689dcbcb4180b099 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 12 Nov 2009 21:42:20 +0100 Subject: [PATCH 1/5] prevent a traceback when we disconnect a zeroconf socket wil a message attribute. Fixes #5049 --- src/common/zeroconf/client_zeroconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index d9158c568..730eb3ec3 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -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) From 2061dd21188620d5e980509baa1378aa314e613e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 12 Nov 2009 22:13:11 +0100 Subject: [PATCH 2/5] fix receiving long messages in several parts with BOSH. see #5401 --- src/common/xmpp/transports_nb.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index aafc57dfb..28fd64bdc 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -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 @@ -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') From 697d2a73246b7acfec2487e8ae4703fcd5262ed2 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 6 Nov 2009 17:58:14 +0100 Subject: [PATCH 3/5] fix BOSH connection with ejabberd. Fixes #5401 --- src/common/xmpp/transports_nb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index 28fd64bdc..704cad170 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -707,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): ''' From 11f01f1c1c54600a3ec4896b69bacd152a2885c5 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 6 Nov 2009 17:58:39 +0100 Subject: [PATCH 4/5] fix traceback when disconnecting from BOSH. --- src/common/xmpp/dispatcher_nb.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py index 98ca5be7a..8f4746f68 100644 --- a/src/common/xmpp/dispatcher_nb.py +++ b/src/common/xmpp/dispatcher_nb.py @@ -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 From 45533ae134a1352d80724eb47bbb1119ff44944f Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 12 Nov 2009 22:25:00 +0100 Subject: [PATCH 5/5] Test body received in several part --- test/integration/test_xmpp_transports_nb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/test_xmpp_transports_nb.py b/test/integration/test_xmpp_transports_nb.py index 0e42ab855..6e56ddf94 100644 --- a/test/integration/test_xmpp_transports_nb.py +++ b/test/integration/test_xmpp_transports_nb.py @@ -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: