Merge remote-tracking branch 'origin/develop' into develop
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parents 284deaa, 5087771 · Browse files · 8 files·+71 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+71 added−7 removed
- tests:+24 added−0 removed
- other:+47 added−7 removed
Provenance
- Commit
59dea18- Tree
b387a13- Author
Kenneth Reitz <kreitz@Kenneths-MacBook-Pro.local>- Committer
Kenneth Reitz <kreitz@Kenneths-MacBook-Pro.local>- Parent 1
284deaa- Parent 2
5087771
8 files changed+71 added−7 removed
modified:docs/api.rst+3 added
36 unmodified lines37 -----------------38 39 .. autofunction:: session40 41+.. autoclass:: Session42+ :inherited-members:43 44 45+46 Exceptions47 ~~~~~~~~~~48 49 .. module:: requests98 unmodified linesmodified:requests/models.py+5 added-3 removed
33 unmodified lines34 to_key_val_list, DEFAULT_CA_BUNDLE_PATH, parse_header_links, iter_slices,35 guess_json_utf)36 from .compat import (37 cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,38- StringIO, is_py2, chardet, json, builtin_str, urldefrag)38+ StringIO, is_py2, chardet, json, builtin_str, urldefrag, basestring)39 40 REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)41 CONTENT_CHUNK_SIZE = 10 * 102442 53 unmodified lines96 #: Dictionary, bytes or file stream of request body data to attach to the97 #: :class:`Request <Request>`.98 self.data = None99 100- #: Dictionary or byte of querystring data to attach to the100+ #: Dictionary of querystring data to attach to the101 #: :class:`Request <Request>`. The dictionary values can be lists for representing102 #: multivalued query parameters.103 self.params = None104 228 unmodified lines333 return data334 elif hasattr(data, '__iter__'):335 result = []336 for k, vs in to_key_val_list(data):337- for v in isinstance(vs, list) and vs or [vs]:337+ if isinstance(vs, basestring) or not hasattr(vs, '__iter__'):338+ vs = [vs]339+ for v in vs:340 if v is not None:341 result.append(342 (k.encode('utf-8') if isinstance(k, str) else k,343 v.encode('utf-8') if isinstance(v, str) else v))566 unmodified linesmodified:requests/sessions.py+27 added
71 unmodified lines72 prefetch=True,73 verify=True,74 cert=None):75 76+ #: A case-insensitive dictionary of headers to be sent on each77+ #: :class:`Request <Request>` sent from this78+ #: :class:`Session <Session>`.79 self.headers = from_key_val_list(headers or [])80+81+ #: Authentication tuple or object to attach to82+ #: :class:`Request <Request>`.83 self.auth = auth84+85+ #: Float describing the timeout of the each :class:`Request <Request>`.86 self.timeout = timeout87+88+ #: Dictionary mapping protocol to the URL of the proxy (e.g.89+ #: {'http': 'foo.bar:3128'}) to be used on each90+ #: :class:`Request <Request>`.91 self.proxies = from_key_val_list(proxies or [])92+93+ #: Event-handling hooks.94 self.hooks = from_key_val_list(hooks or {})95+96+ #: Dictionary of querystring data to attach to each97+ #: :class:`Request <Request>`. The dictionary values may be lists for98+ #: representing multivalued query parameters.99 self.params = from_key_val_list(params or [])100+101+ #: Dictionary of configuration parameters for this102+ #: :class:`Session <Session>`.103 self.config = from_key_val_list(config or {})104+105+ #: Prefetch response content.106 self.prefetch = prefetch107+108+ #: SSL Verification.109 self.verify = verify110+111+ #: SSL certificate.112 self.cert = cert113 114 for (k, v) in list(defaults.items()):115 self.config.setdefault(k, deepcopy(v))240 unmodified linesmodified:requests/status_codes.py+2 added-2 removed
8 unmodified lines9 101: ('switching_protocols',),10 102: ('processing',),11 103: ('checkpoint',),12 122: ('uri_too_long', 'request_uri_too_long'),13- 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/'),13+ 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'),14 201: ('created',),15 202: ('accepted',),16 203: ('non_authoritative_info', 'non_authoritative_information'),17 204: ('no_content',),46 unmodified lines64 450: ('blocked_by_windows_parental_controls', 'parental_controls'),65 499: ('client_closed_request',),66 67 # Server Error.68- 500: ('internal_server_error', 'server_error', '/o\\'),68+ 500: ('internal_server_error', 'server_error', '/o\\', '✗'),69 501: ('not_implemented',),70 502: ('bad_gateway',),71 503: ('service_unavailable', 'unavailable'),72 504: ('gateway_timeout',),14 unmodified linesmodified:requests/utils.py+8 added-1 removed
537 unmodified lines538 elif _implementation == 'IronPython':539 _implementation_version = platform.python_version() # Complete Guess540 else:541 _implementation_version = 'Unknown'542+ 543+ try:544+ p_system = platform.system()545+ p_release = platform.release()546+ except IOError:547+ p_system = 'Unknown'548+ p_release = 'Unknown'549 550 return " ".join([551 'python-requests/%s' % __version__,552 '%s/%s' % (_implementation, _implementation_version),546- '%s/%s' % (platform.system(), platform.release()),553+ '%s/%s' % (p_system, p_release),554 ])555 556 557 def parse_header_links(value):66 unmodified linesmodified:tests/test_requests.py+24 added
645 unmodified lines646 rbody = json.loads(r.text)647 self.assertEqual(rbody.get('form'), dict(test2='foobar', test3=['foo', 'baz']))648 self.assertEqual(rbody.get('data'), '')649 650+ def test_multivalued_data_encoding(self):651+ """652+ Make sure data encoding works on a value that is an iterable but not653+ a list654+ """655+ for service in SERVICES:656+ # Can't have unicode literals in Python3, so avoid them.657+ # TODO: fixup when moving to Python 3.3658+ if (sys.version_info[0] == 2):659+ nonascii = '\xc3\xa9'.decode('utf-8')660+ else:661+ nonascii = '\xe9'662+663+ r = post(664+ service('post'),665+ data=dict(test=('foo', nonascii)))666+667+ self.assertEqual(r.status_code, 200)668+ self.assertEqual(r.headers['content-type'], 'application/json')669+670+ rbody = json.loads(r.text)671+ self.assertEqual(rbody.get('form'),672+ dict(test=['foo', nonascii]))673+674 def test_GET_no_redirect(self):675 676 for service in SERVICES:677 543 unmodified linesmodified:MANIFEST.in+1 added-1 removed
1-include README.rst LICENSE NOTICE HISTORY.rst tests/*. requests/cacert.pem1+include README.rst LICENSE NOTICE HISTORY.rst tests/* requests/cacert.pemmodified:setup.py+1 added
52 unmodified lines53 package_dir={'requests': 'requests'},54 include_package_data=True,55 install_requires=requires,56 license=open('LICENSE').read(),57+ zip_safe=False,58 classifiers=(59 'Development Status :: 5 - Production/Stable',60 'Intended Audience :: Developers',61 'Natural Language :: English',13 unmodified lines