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

This commit is contained in:
David Black
2020-06-16 20:53:07 +10:00
parent 737dd0c3c6
commit 71a05cf289
+5 -5
View File
@@ -473,12 +473,12 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
not isinstance(data, (basestring, list, tuple, Mapping))
])
try:
length = super_len(data)
except (TypeError, AttributeError, UnsupportedOperation):
length = None
if is_stream:
try:
length = super_len(data)
except (TypeError, AttributeError, UnsupportedOperation):
length = None
body = data
if getattr(body, 'tell', None) is not None: