mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Fall back to streaming
This commit is contained in:
committed by
Nate Prewitt
parent
d4965a4ec6
commit
8873a09097
+5
-1
@@ -83,7 +83,8 @@ def super_len(o):
|
||||
# is actually a special file descriptor like stdin. In this
|
||||
# instance, we don't know what the length is, so set it to zero and
|
||||
# let requests chunk it instead.
|
||||
current_position = total_length
|
||||
if total_length is not None:
|
||||
current_position = total_length
|
||||
|
||||
if hasattr(o, 'seek') and total_length is None:
|
||||
# StringIO has a notimplemented fileno
|
||||
@@ -98,6 +99,9 @@ def super_len(o):
|
||||
# seek back to current position to support partially read file-like
|
||||
o.seek(current_position or 0)
|
||||
|
||||
if total_length is None:
|
||||
total_length = 0
|
||||
|
||||
return max(0, total_length - current_position)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user