Skip to content
Myr

This should take care of #1266

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

We were sending 'None' as the Content-Length on requests where the body was a generator. This commit should prevent that entirely.

authored by Ian Cordasco · committed by Ian Cordasco · parent 478d490 · Browse files · 1 file+5 added−3 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−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:requests/models.py+5 added-3 removed
347 unmodified lines
348 not isinstance(data, dict)349 ])350351 try:352 length = str(super_len(data))352 length = super_len(data)353 except (TypeError, AttributeError):354 length = False355356 if is_stream:
2 unmodified lines
359 if files:360 raise NotImplementedError('Streamed bodies and files are mutually exclusive.')361362 if length:363 self.headers['Content-Length'] = length363 self.headers['Content-Length'] = str(length)364 else:365 self.headers['Transfer-Encoding'] = 'chunked'366 # Check if file, fo, generator, iterator.367 # If not, run through normal process.
23 unmodified lines
391 body.seek(0, 2)392 self.headers['Content-Length'] = str(body.tell())393 body.seek(0, 0)394 elif body is not None:395 l = super_len(body)396 if l:395 self.headers['Content-Length'] = str(len(body))397 self.headers['Content-Length'] = super_len(l)398 elif self.method not in ('GET', 'HEAD'):399 self.headers['Content-Length'] = '0'400401 def prepare_auth(self, auth, url=''):
272 unmodified lines