Skip to content
Myr

Only switch to chunked if we don't know the length of a file like object. This fixes the case of trying to upload a 0-length file - chunked upload was being forced. Services like S3 that disallow chunked upload will fail.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jeff Mancuso · committed by Jeff Mancuso · parent 00ab8fb · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:requests/models.py+2 added-2 removed
362 unmodified lines
363364 try:365 length = super_len(data)366 except (TypeError, AttributeError):367 length = False367 length = None368369 if is_stream:370 body = data371372 if files:373 raise NotImplementedError('Streamed bodies and files are mutually exclusive.')374375 if length:375 if length is not None:376 self.headers['Content-Length'] = str(length)377 else:378 self.headers['Transfer-Encoding'] = 'chunked'379 # Check if file, fo, generator, iterator.
307 unmodified lines