From: Carol Willing Date: Thu, 28 Aug 2014 23:45:24 +0000 (-0700) Subject: Adds review changes X-Git-Tag: v2.4.2~4^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b34a496649667b9324caa634cb17e726e0cce1a5;p=services%2Fpython-requests.git Adds review changes --- diff --git a/requests/models.py b/requests/models.py index b6ef919..1b110b4 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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'): diff --git a/test_requests.py b/test_requests.py index 2e98cb9..af27235 100755 --- a/test_requests.py +++ b/test_requests.py @@ -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):