Avoid an unnecessary computation of the length of data for non-stream requests (which determines content-length based upon body content).
@@ -473,12 +473,12 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
not isinstance(data, (basestring, list, tuple, Mapping))
])
+ if is_stream:
try:
length = super_len(data)
except (TypeError, AttributeError, UnsupportedOperation):
length = None
- if is_stream:
body = data
if getattr(body, 'tell', None) is not None:
