Skip to content
Myr

Merge pull request #1689 from Lukasa/unicode

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

Use builtin_str for all auto-set header values.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 52fe3f7, 8a42d5f · Browse files · 2 files+11 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

2 files+11 added−3 removed

  • other:+11 added−3 removed

2 files+11 added−3 removed

modified:requests/models.py+3 added-3 removed
406 unmodified lines
407 if files:408 raise NotImplementedError('Streamed bodies and files are mutually exclusive.')409410 if length is not None:411 self.headers['Content-Length'] = str(length)411 self.headers['Content-Length'] = builtin_str(length)412 else:413 self.headers['Transfer-Encoding'] = 'chunked'414 else:415 # Multi-part file uploads.
17 unmodified lines
433434 def prepare_content_length(self, body):435 if hasattr(body, 'seek') and hasattr(body, 'tell'):436 body.seek(0, 2)437 self.headers['Content-Length'] = str(body.tell())437 self.headers['Content-Length'] = builtin_str(body.tell())438 body.seek(0, 0)439 elif body is not None:440 l = super_len(body)441 if l:442 self.headers['Content-Length'] = str(l)442 self.headers['Content-Length'] = builtin_str(l)443 elif self.method not in ('GET', 'HEAD'):444 self.headers['Content-Length'] = '0'445446 def prepare_auth(self, auth, url=''):
288 unmodified lines
modified:test_requests.py+8 added
682 unmodified lines
683 p = r.prepare()684685 self.assertTrue('multipart/form-data' in p.headers['Content-Type'])686687 def test_autoset_header_values_are_native(self):688 data = 'this is a string'689 length = '16'690 req = requests.Request('POST', httpbin('post'), data=data)691 p = req.prepare()692693 self.assertEqual(p.headers['Content-Length'], length)694695696class TestContentEncodingDetection(unittest.TestCase):697698 def test_none(self):699 encodings = requests.utils.get_encodings_from_content('')
207 unmodified lines