mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 23:00:18 +00:00
+1
-1
@@ -77,6 +77,7 @@ def json_safe(string, content_type='application/octet-stream'):
|
||||
URL scheme was chosen for its simplicity.
|
||||
"""
|
||||
try:
|
||||
string = string.decode('utf-8')
|
||||
_encoded = json.dumps(string)
|
||||
return string
|
||||
except (ValueError, TypeError):
|
||||
@@ -152,7 +153,6 @@ def get_dict(*keys, **extras):
|
||||
_keys = ('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json')
|
||||
|
||||
assert all(map(_keys.__contains__, keys))
|
||||
|
||||
data = request.data
|
||||
form = request.form
|
||||
form = semiflatten(request.form)
|
||||
|
||||
@@ -47,6 +47,10 @@ class HttpbinTestCase(unittest.TestCase):
|
||||
response = self.app.post('/post', data={"file": f.read()})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_post_body_unicode(self):
|
||||
response = self.app.post('/post', data=u'оживлённым'.encode('utf-8'))
|
||||
self.assertEqual(json.loads(response.data.decode('utf-8'))['data'], u'оживлённым')
|
||||
|
||||
def test_post_file_with_missing_content_type_header(self):
|
||||
# I built up the form data manually here because I couldn't find a way
|
||||
# to convince the werkzeug test client to send files without the
|
||||
|
||||
Reference in New Issue
Block a user