Skip to content
Myr

Merge branch 'master' of git://github.com/kennethreitz/requests

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

Conflicts: test_requests.py

authored by sprt · committed by sprt · parents 1cfe592, beec48c · Browse files · 2 files+12 added−11 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+12 added−11 removed

  • other:+12 added−11 removed

2 files+12 added−11 removed

modified:requests/models.py+7 added-4 removed
601 unmodified lines
602 content = str(self.content, errors='replace')603604 return content605606 def json(self):607 """Returns the json-encoded content of a response, if any."""606 def json(self, **kwargs):607 """Returns the json-encoded content of a response, if any.608609 :param \*\*kwargs: Optional arguments that ``json.loads`` takes.610 """611612 if not self.encoding and len(self.content) > 3:613 # No encoding set. JSON RFC 4627 section 3 states we should expect614 # UTF-8, -16 or -32. Detect which one to use; If the detection or615 # decoding fails, fall back to `self.text` (using chardet to make616 # a best guess).617 encoding = guess_json_utf(self.content)618 if encoding is not None:616 return json.loads(self.content.decode(encoding))617 return json.loads(self.text or self.content)619 return json.loads(self.content.decode(encoding), **kwargs)620 return json.loads(self.text or self.content, **kwargs)621622 @property623 def links(self):624 """Returns the parsed header links of the response, if any."""
33 unmodified lines
modified:test_requests.py+5 added-7 removed
32 unmodified lines
33 def tearDown(self):34 """Teardown."""35 pass3637 def test_assertion(self):38 assert 13937 def test_entry_points(self):3839 requests.session40 requests.session().get
31 unmodified lines
72 "http://example.com/path?key=value#fragment", params={"a": "b"}).prepare()73 self.assertEqual(request.url,74 "http://example.com/path?key=value&a=b#fragment")7579 def test_HTTP_200_OK_GET(self):80 r = requests.get(httpbin('get'))81 self.assertEqual(r.status_code, 200)8276 def test_HTTP_200_OK_GET_ALTERNATIVE(self):77 r = requests.Request('GET', httpbin('get'))78 s = requests.Session()79
193 unmodified lines
273 resp = s.send(prep)274275 self.assertTrue(hasattr(resp, 'hook_working'))276277 def test_links(self):278 url = 'https://api.github.com/users/kennethreitz/repos?page=1&per_page=10'279 r = requests.head(url=url)280 self.assertEqual(r.links['next']['rel'], 'next')281282283if __name__ == '__main__':284 unittest.main()