except Exception as e:
output.append('Error reading response body: %s %r' % (type(e).__name__, e.args))
else:
- if c_len is not None and len(responsebody) != int(c_len):
- output.append("[actual %s; Content-Length %s] " % (_humanize_bytes(len(responsebody)), _humanize_bytes(c_len)))
- else:
+ if c_len is not None and len(responsebody) != int(c_len): # did we read a different amount than Content-Length?
+ if response.read(1): # there's more data, we just aren't reading it
+ output.append("[read %s; Content-Length %s] " % (_humanize_bytes(len(responsebody)), _humanize_bytes(c_len)))
+ else:
+ output.append("[actual %s; Content-Length %s] " % (_humanize_bytes(len(responsebody)), _humanize_bytes(c_len)))
+ else: # Content-Length = amount read
output.append("[%s] " % (_humanize_bytes(len(responsebody))))
try:
soup = BeautifulSoup(responsebody, from_encoding=c_charset)