[rh:urllib] Do not read after close (#15049)

Fix regression introduced in 5767fb4ab1

Closes #15017
Authored by: bashonly
This commit is contained in:
bashonly 2025-11-16 13:07:48 -06:00 committed by GitHub
parent 23f1ab3469
commit 6ee6a6fc58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 1 deletions

View file

@ -305,6 +305,8 @@ class UrllibResponseAdapter(Response):
status=getattr(res, 'status', None) or res.getcode(), reason=getattr(res, 'reason', None))
def read(self, amt=None):
if self.closed:
return b''
try:
data = self.fp.read(amt)
underlying = getattr(self.fp, 'fp', None)