mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #884 from everbird/develop
Support CJK parameters when post files
This commit is contained in:
@@ -114,3 +114,4 @@ Patches and Suggestions
|
||||
- Ian Cordasco <graffatcolmingov@gmail.com> @sigmavirus24
|
||||
- Rhys Elsmore
|
||||
- André Graf (dergraf)
|
||||
- Stephen Zhuang (everbird)
|
||||
|
||||
+2
-2
@@ -360,9 +360,9 @@ class Request(object):
|
||||
for field, val in fields:
|
||||
if isinstance(val, list):
|
||||
for v in val:
|
||||
new_fields.append((field, str(v)))
|
||||
new_fields.append((field, builtin_str(v)))
|
||||
else:
|
||||
new_fields.append((field, str(val)))
|
||||
new_fields.append((field, builtin_str(val)))
|
||||
|
||||
for (k, v) in files:
|
||||
# support for explicit filename
|
||||
|
||||
+16
-5
@@ -338,12 +338,23 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):
|
||||
|
||||
with open(__file__) as f:
|
||||
url = service('post')
|
||||
post1 = post(url,
|
||||
files={'some': f},
|
||||
data={'some': 'data'})
|
||||
post1 = post(url, data={'some': 'data'}, files={'some': f})
|
||||
post2 = post(url, data={'some': 'data'}, files=[('some', f)])
|
||||
post3 = post(url, data=[('some', 'data')],
|
||||
files=[('some', f)])
|
||||
post3 = post(url, data=[('some', 'data')], files=[('some', f)])
|
||||
|
||||
self.assertEqual(post1.status_code, 200)
|
||||
self.assertEqual(post2.status_code, 200)
|
||||
self.assertEqual(post3.status_code, 200)
|
||||
|
||||
def test_POSTBIN_GET_POST_FILES_WITH_CJK_PARAMS(self):
|
||||
|
||||
for service in SERVICES:
|
||||
|
||||
with open(__file__) as f:
|
||||
url = service('post')
|
||||
post1 = post(url, data={'some': '中文'}, files={'some': f})
|
||||
post2 = post(url, data={'some': '日本語'}, files=[('some', f)])
|
||||
post3 = post(url, data=[('some', '한국의')], files=[('some', f)])
|
||||
|
||||
self.assertEqual(post1.status_code, 200)
|
||||
self.assertEqual(post2.status_code, 200)
|
||||
|
||||
Reference in New Issue
Block a user