mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
changed the null check for 'data' parameter to be more explicit.
removed the superfluous encode from the testcase.
This commit is contained in:
+1
-1
@@ -414,7 +414,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
content_type = None
|
||||
length = None
|
||||
|
||||
if not data and json is not None:
|
||||
if data == {} and json is not None:
|
||||
content_type = 'application/json'
|
||||
body = complexjson.dumps(json)
|
||||
|
||||
|
||||
+1
-1
@@ -1065,7 +1065,7 @@ class RequestsTestCase(unittest.TestCase):
|
||||
def test_json_param_post_should_not_override_data_param(self):
|
||||
r = requests.Request(method='POST', url='http://httpbin.org/post',
|
||||
data={'stuff'.encode('utf-8'): 'elixr'},
|
||||
json={'music'.encode('utf-8'): 'flute'})
|
||||
json={'music': 'flute'})
|
||||
prep = r.prepare()
|
||||
assert 'stuff=elixr' == prep.body
|
||||
|
||||
|
||||
Reference in New Issue
Block a user