mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Raise an error if body is not null, has not length and is not streamable.
This commit is contained in:
committed by
Nate Prewitt
parent
bfb202527d
commit
033dfc165d
@@ -526,6 +526,8 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
self.headers['Content-Length'] = builtin_str(length)
|
||||
elif is_stream and not length:
|
||||
self.headers['Transfer-Encoding'] = 'chunked'
|
||||
else:
|
||||
assert False, "If body is not null, it must either have a length or be streamable"
|
||||
elif (self.method not in ('GET', 'HEAD')) and (self.headers.get('Content-Length') is None):
|
||||
self.headers['Content-Length'] = '0'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user