]> jfr.im git - erebus.git/commitdiff
urls - dont indicate a content-length mismatch if we just didnt bother reading
authorJohn Runyon <redacted>
Sat, 2 Mar 2024 16:17:20 +0000 (09:17 -0700)
committerJohn Runyon <redacted>
Sat, 2 Mar 2024 16:17:20 +0000 (09:17 -0700)
modules/urls.py

index 441e38912ecae17ad976d651d0eaf04ae9b6da57..98e2bf0220c431253a197816a4fcb6ac35ccde3c 100644 (file)
@@ -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)