Skip to content
Myr

Avoid an unnecessary computation of the length of data for non-stream requests (which determines content-length based upon body content).

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

authored by David Black · committed by David Black · parent 737dd0c · Browse files · 1 file+5 added−5 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+5 added−5 removed

  • other:+5 added−5 removed

1 file+5 added−5 removed

modified:requests/models.py+5 added-5 removed
471 unmodified lines
472 hasattr(data, '__iter__'),473 not isinstance(data, (basestring, list, tuple, Mapping))474 ])475476 try:477 length = super_len(data)478 except (TypeError, AttributeError, UnsupportedOperation):479 length = None480476 if is_stream:477 try:478 length = super_len(data)479 except (TypeError, AttributeError, UnsupportedOperation):480 length = None481482 body = data483484 if getattr(body, 'tell', None) is not None:485 # Record the current file position before reading.
469 unmodified lines