Skip to content
Myr

Merge pull request #2763 from ravipra/json_supersedes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixed issue #2756

authored by Cory Benfield · committed by Cory Benfield · parents 8963e15, 1f48a4c · Browse files · 2 files+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−2 removed

  • other:+9 added−2 removed

2 files+9 added−2 removed

modified:requests/models.py+2 added-2 removed
412 unmodified lines
413 body = None414 content_type = None415 length = None416417 if json is not None:417 if data == {} and json is not None:418 content_type = 'application/json'419 body = complexjson.dumps(json)420421 is_stream = all([
20 unmodified lines
442 # Multi-part file uploads.443 if files:444 (body, content_type) = self._encode_files(files, data)445 else:446 if data and json is None:446 if data:447 body = self._encode_params(data)448 if isinstance(data, basestring) or hasattr(data, 'read'):449 content_type = None450 else:
398 unmodified lines
modified:test_requests.py+7 added
1080 unmodified lines
1081 assert r.status_code == 2001082 assert 'application/json' in r.request.headers['Content-Type']1083 assert {'life': 42} == r.json()['json']10841085 def test_json_param_post_should_not_override_data_param(self):1086 r = requests.Request(method='POST', url='http://httpbin.org/post',1087 data={'stuff': 'elixr'},1088 json={'music': 'flute'})1089 prep = r.prepare()1090 assert 'stuff=elixr' == prep.body10911092 def test_response_iter_lines(self):1093 r = requests.get(httpbin('stream/4'), stream=True)1094 assert r.status_code == 2001095
619 unmodified lines