[networking] Ensure underlying file object is closed when fully read (#14935)
Fixes https://github.com/yt-dlp/yt-dlp/issues/14891 Authored by: coletdjnz
This commit is contained in:
parent
73fd850d17
commit
5767fb4ab1
5 changed files with 124 additions and 16 deletions
|
|
@ -96,7 +96,10 @@ class CurlCFFIResponseAdapter(Response):
|
|||
|
||||
def read(self, amt=None):
|
||||
try:
|
||||
return self.fp.read(amt)
|
||||
res = self.fp.read(amt)
|
||||
if self.fp.closed:
|
||||
self.close()
|
||||
return res
|
||||
except curl_cffi.requests.errors.RequestsError as e:
|
||||
if e.code == CurlECode.PARTIAL_FILE:
|
||||
content_length = e.response and int_or_none(e.response.headers.get('Content-Length'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue