浏览代码

[downloader/http] Finish downloading once received data length matches expected

Always do this if possible, i.e. if Content-Length or expected length is known, not only in test.
This will save unnecessary last extra loop trying to read 0 bytes.
Sergey M․ 5 年之前
父节点
当前提交
f7b42518dc
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      youtube_dl/downloader/http.py

+ 1 - 1
youtube_dl/downloader/http.py

@@ -299,7 +299,7 @@ class HttpFD(FileDownloader):
                     'elapsed': now - ctx.start_time,
                 })
 
-                if is_test and byte_counter == data_len:
+                if data_len is not None and byte_counter == data_len:
                     break
 
             if not is_test and ctx.chunk_size and ctx.data_len is not None and byte_counter < ctx.data_len: