Skip to content
Myr

Only pass unicode fieldnames to urllib3.

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

authored by Ib Lundgren · committed by Ib Lundgren · parent 1621015 · Browse files · 2 files+11 added−1 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−1 removed

  • other:+11 added−1 removed

2 files+11 added−1 removed

modified:requests/models.py+1 added-1 removed
103 unmodified lines
104 val = [val]105 for v in val:106 if v is not None:107 new_fields.append(108 (field.encode('utf-8') if isinstance(field, str) else field,108 (field.decode('utf-8') if isinstance(field, bytes) else field,109 v.encode('utf-8') if isinstance(v, str) else v))110111 for (k, v) in files:112 # support for explicit filename
574 unmodified lines
modified:test_requests.py+10 added
340 unmodified lines
341 data={'stuff': 'elixr'.encode('utf-8')},342 files={'file': ('test_requests.py', open(__file__, 'rb'))})343 self.assertEqual(r.status_code, 200)344345 def test_unicode_multipart_post_fieldnames(self):346 r = requests.Request(method='POST',347 url=httpbin('post'),348 data={'stuff'.encode('utf-8'): 'elixr'},349 files={'file': ('test_requests.py',350 open(__file__, 'rb'))})351 prep = r.prepare()352 self.assertTrue(b'name="stuff"' in prep.body)353 self.assertFalse(b'name="b\'stuff\'"' in prep.body)354355 def test_custom_content_type(self):356 r = requests.post(httpbin('post'),357 data={'stuff': json.dumps({'a': 123})},358 files={'file1': ('test_requests.py', open(__file__, 'rb')),
345 unmodified lines