fix receiving long messages in several parts with BOSH. see #5401
This commit is contained in:
parent
ae9f7ca410
commit
2061dd2118
1 changed files with 7 additions and 1 deletions
|
@ -648,7 +648,8 @@ class NonBlockingHTTP(NonBlockingTCP):
|
||||||
|
|
||||||
# append currently received data to HTTP msg in buffer
|
# append currently received data to HTTP msg in buffer
|
||||||
self.recvbuff = '%s%s' % (self.recvbuff or '', data)
|
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):
|
if not (statusline and headers and httpbody):
|
||||||
log.debug('Received incomplete HTTP response')
|
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' %
|
log.info('not enough bytes in HTTP response - %d expected, %d got' %
|
||||||
(self.expected_length, len(self.recvbuff)))
|
(self.expected_length, len(self.recvbuff)))
|
||||||
else:
|
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
|
# everything was received
|
||||||
self.expected_length = 0
|
self.expected_length = 0
|
||||||
|
|
||||||
|
@ -711,6 +716,7 @@ class NonBlockingHTTP(NonBlockingTCP):
|
||||||
headers - dictionary of headers e.g. {'Content-Length': '604',
|
headers - dictionary of headers e.g. {'Content-Length': '604',
|
||||||
'Content-Type': 'text/xml; charset=utf-8'},
|
'Content-Type': 'text/xml; charset=utf-8'},
|
||||||
httpbody - string with http body)
|
httpbody - string with http body)
|
||||||
|
http_rest - what is left in the message after a full HTTP header + body
|
||||||
'''
|
'''
|
||||||
message = message.replace('\r','')
|
message = message.replace('\r','')
|
||||||
splitted = message.split('\n\n')
|
splitted = message.split('\n\n')
|
||||||
|
|
Loading…
Add table
Reference in a new issue