Adds review changes
authorCarol Willing <carolcode@willingconsulting.com>
Thu, 28 Aug 2014 23:45:24 +0000 (16:45 -0700)
committerCarol Willing <carolcode@willingconsulting.com>
Thu, 28 Aug 2014 23:45:24 +0000 (16:45 -0700)
requests/models.py
test_requests.py

index b6ef9190077e1415f0c9816e68dbcda1179c3f3a..1b110b49f0cf62bc47e5225fe114e2673ff25a72 100644 (file)
@@ -301,7 +301,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
         self.prepare_url(url, params)
         self.prepare_headers(headers)
         self.prepare_cookies(cookies)
-        self.prepare_body(data, files)
+        self.prepare_body(data, files, json)
         self.prepare_auth(auth, url)
         # Note that prepare_auth must be last to enable authentication schemes
         # such as OAuth to work on a fully prepared request.
@@ -442,7 +442,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
             if files:
                 (body, content_type) = self._encode_files(files, data)
             else:
-                if data:
+                if data and not _json:
                     body = self._encode_params(data)
                     if not _json:
                         if isinstance(data, basestring) or hasattr(data, 'read'):
index 2e98cb91f3c2ef8ef94d1a4c493b9f150107956b..af2723558ef62e2c2f8629e2750a4f0269bd193c 100755 (executable)
@@ -992,7 +992,8 @@ class RequestsTestCase(unittest.TestCase):
             json={'life': 42}
         )
         assert r.status_code == 200
-        assert 'application/json' in r.headers['Content-Type']
+        assert 'application/json' in r.request.headers['Content-Type']
+        #assert {'life': 42} == r.json()['json']
 
 
 class TestContentEncodingDetection(unittest.TestCase):