fix receiving long messages in several parts with BOSH. see #5401

This commit is contained in:
Yann Leboulanger 2009-11-12 22:13:11 +01:00
parent ae9f7ca410
commit 2061dd2118
1 changed files with 7 additions and 1 deletions

View File

@ -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')