From: John Runyon Date: Sat, 2 Mar 2024 16:17:20 +0000 (-0700) Subject: urls - dont indicate a content-length mismatch if we just didnt bother reading X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/46ab933c8885fa079659893f16a402b4428e7952?hp=f4e28c0e3c397f5a445be36575f0d6adaf42b4d3 urls - dont indicate a content-length mismatch if we just didnt bother reading --- diff --git a/modules/urls.py b/modules/urls.py index 441e389..98e2bf0 100644 --- a/modules/urls.py +++ b/modules/urls.py @@ -332,9 +332,12 @@ def goturl(url): 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)