Skip to content
Myr

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

8 files+71 added−7 removed

modified:docs/api.rst+3 added
36 unmodified lines
37-----------------3839.. autofunction:: session4041.. autoclass:: Session42 :inherited-members:43444546Exceptions47~~~~~~~~~~4849.. module:: requests
98 unmodified lines
modified:requests/models.py+5 added-3 removed
33 unmodified lines
34 to_key_val_list, DEFAULT_CA_BUNDLE_PATH, parse_header_links, iter_slices,35 guess_json_utf)36from .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)3940REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)41CONTENT_CHUNK_SIZE = 10 * 102442
53 unmodified lines
96 #: Dictionary, bytes or file stream of request body data to attach to the97 #: :class:`Request <Request>`.98 self.data = None99100 #: 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 lines
333 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 lines
modified:requests/sessions.py+27 added
71 unmodified lines
72 prefetch=True,73 verify=True,74 cert=None):7576 #: 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 [])8081 #: Authentication tuple or object to attach to82 #: :class:`Request <Request>`.83 self.auth = auth8485 #: Float describing the timeout of the each :class:`Request <Request>`.86 self.timeout = timeout8788 #: 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 [])9293 #: Event-handling hooks.94 self.hooks = from_key_val_list(hooks or {})9596 #: 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 [])100101 #: Dictionary of configuration parameters for this102 #: :class:`Session <Session>`.103 self.config = from_key_val_list(config or {})104105 #: Prefetch response content.106 self.prefetch = prefetch107108 #: SSL Verification.109 self.verify = verify110111 #: SSL certificate.112 self.cert = cert113114 for (k, v) in list(defaults.items()):115 self.config.setdefault(k, deepcopy(v))
240 unmodified lines
modified:requests/status_codes.py+2 added-2 removed
8 unmodified lines
9 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 lines
64 450: ('blocked_by_windows_parental_controls', 'parental_controls'),65 499: ('client_closed_request',),6667 # 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 lines
modified:requests/utils.py+8 added-1 removed
537 unmodified lines
538 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'549550 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 ])555556557def parse_header_links(value):
66 unmodified lines
modified:tests/test_requests.py+24 added
645 unmodified lines
646 rbody = json.loads(r.text)647 self.assertEqual(rbody.get('form'), dict(test2='foobar', test3=['foo', 'baz']))648 self.assertEqual(rbody.get('data'), '')649650 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'662663 r = post(664 service('post'),665 data=dict(test=('foo', nonascii)))666667 self.assertEqual(r.status_code, 200)668 self.assertEqual(r.headers['content-type'], 'application/json')669670 rbody = json.loads(r.text)671 self.assertEqual(rbody.get('form'),672 dict(test=['foo', nonascii]))673674 def test_GET_no_redirect(self):675676 for service in SERVICES:677
543 unmodified lines
modified:MANIFEST.in+1 added-1 removed
1include README.rst LICENSE NOTICE HISTORY.rst tests/*. requests/cacert.pem1include README.rst LICENSE NOTICE HISTORY.rst tests/* requests/cacert.pem
modified:setup.py+1 added
52 unmodified lines
53 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