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 b73426a, aa08f33 · Browse files · 17 files+60 added−40 removed
This commit

State

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

Diff stats

17 files+60 added−40 removed

  • tests:+35 added−16 removed
  • other:+25 added−24 removed

17 files+60 added−40 removed

modified:docs/_themes/README.rst+5 added-5 removed
9 unmodified lines
10 you can also use git submodules to check out the contents there.11122. add this to your conf.py: ::1314 sys.path.append(os.path.abspath('_themes'))15 html_theme_path = ['_themes']16 html_theme = 'flask'14 sys.path.append(os.path.abspath('_themes'))15 html_theme_path = ['_themes']16 html_theme = 'flask'1718The following themes exist:1920**kr**21 the standard flask documentation theme for large projects21 the standard flask documentation theme for large projects2223**kr_small**24 small one-page theme. Intended to be used by very small addon libraries.24 small one-page theme. Intended to be used by very small addon libraries.25
modified:docs/community/support.rst+1 added-1 removed
32 unmodified lines
3334The official Freenode channel for Requests is35`#python-requests <irc://irc.freenode.net/python-requests>`_3637I'm also available as **kennethreitz** on Freenode.37I'm also available as **kennethreitz** on Freenode.
modified:docs/dev/authors.rst+1 added-1 removed
1Authors2=======345.. include:: ../../AUTHORS.rst5.. include:: ../../AUTHORS.rst
modified:docs/user/install.rst+3 added-3 removed
23 unmodified lines
2425Cheeseshop Mirror26-----------------2728If the Cheeseshop is down, you can also install Requests from Kenneth Reitz's29personal `Cheeseshop mirror <http://pip.kennethreitz.com/>`_::28If the Cheeseshop is down, you can also install Requests from one of the29mirrors. `Crate.io <http://crate.io>`_ is one of them::3031 $ pip install -i http://pip.kennethreitz.com/simple requests31 $ pip install -i http://simple.crate.io/ requests323334Get the Code35------------
21 unmodified lines
modified:docs/conf.py+1 added-1 removed
239 unmodified lines
240texinfo_appendices = []241242sys.path.append(os.path.abspath('_themes'))243html_theme_path = ['_themes']244html_theme = 'kr'244html_theme = 'kr'
modified:requests/auth.py+1 added-1 removed
92 unmodified lines
93 # be empty (cant add paras to body if multipart) and we wish94 # to preserve body.95 r.url, r.headers, _ = self.client.sign(96 unicode(r.full_url), unicode(r.method), None, r.headers)97 elif decoded_body != None and contenttype in (CONTENT_TYPE_FORM_URLENCODED, ''):97 elif decoded_body is not None and contenttype in (CONTENT_TYPE_FORM_URLENCODED, ''):98 # Normal signing99 if not contenttype:100 r.headers['Content-Type'] = CONTENT_TYPE_FORM_URLENCODED101 r.url, r.headers, r.data = self.client.sign(
281 unmodified lines
modified:requests/compat.py+1 added-1 removed
113 unmodified lines
114115 builtin_str = str116 str = str117 bytes = bytes118 basestring = (str,bytes)118 basestring = (str, bytes)119 numeric_types = (int, float)
modified:requests/cookies.py+4 added-6 removed
233 unmodified lines
234 """Takes as an argument an optional domain and path and returns a plain old235 Python dict of name-value pairs of cookies that meet the requirements."""236 dictionary = {}237 for cookie in iter(self):238 if (domain == None or cookie.domain == domain) and (path == None238 if (domain is None or cookie.domain == domain) and (path is None239 or cookie.path == path):240 dictionary[cookie.name] = cookie.value241 return dictionary242
35 unmodified lines
278 for cookie in iter(self):279 if cookie.name == name:280 if domain is None or cookie.domain == domain:281 if path is None or cookie.path == path:282 if toReturn != None: # if there are multiple cookies that meet passed in criteria282 if toReturn is not None: # if there are multiple cookies that meet passed in criteria283 raise CookieConflictError('There are multiple cookies with name, %r' % (name))284 toReturn = cookie.value # we will eventually return this as long as no cookie conflict285286 if toReturn:
36 unmodified lines
323 discard=True,324 comment=None,325 comment_url=None,326 rest={'HttpOnly': None},327 rfc2109=False,328 )327 rfc2109=False,)328329 badargs = set(kwargs) - set(result)330 if badargs:331 err = 'create_cookie() got unexpected keyword arguments: %s'
26 unmodified lines
358 discard=False,359 comment=morsel['comment'],360 comment_url=bool(morsel['comment']),361 rest={'HttpOnly': morsel['httponly']},363 rfc2109=False,364 )362 rfc2109=False,)363 return c364365366def cookiejar_from_dict(cookie_dict, cookiejar=None):
11 unmodified lines
modified:requests/hooks.py-1 removed
43 unmodified lines
44 _hook_data = hook(hook_data)45 if _hook_data is not None:46 hook_data = _hook_data474848 return hook_data
modified:requests/models.py+3 added-3 removed
109 unmodified lines
110111 # Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})112 self.proxies = dict(proxies or [])113114 for proxy_type,uri_ref in list(self.proxies.items()):114 for proxy_type, uri_ref in list(self.proxies.items()):115 if not uri_ref:116 del self.proxies[proxy_type]117118 # If no proxies are given, allow configuration by environment variables
240 unmodified lines
359360 for field, val in fields:361 if isinstance(val, list):362 for v in val:363 new_fields.append((field, str(v)))363 new_fields.append((field, builtin_str(v)))364 else:365 new_fields.append((field, str(val)))365 new_fields.append((field, builtin_str(val)))366367 for (k, v) in files:368 # support for explicit filename369 if isinstance(v, (tuple, list)):
523 unmodified lines
modified:requests/utils.py+4 added-1 removed
376 unmodified lines
377 rv = decoder.decode('', final=True)378 if rv:379 yield rv380381382def iter_slices(string, slice_length):383 """Iterate over slices of a string."""384 pos = 0385 while pos < len(string):385 yield string[pos:pos+slice_length]386 yield string[pos:pos + slice_length]387 pos += slice_length388389390def get_unicode_from_response(r):391 """Returns the requested content back in unicode.392393 :param r: Response object to get unicode content from.
150 unmodified lines
544 '%s/%s' % (_implementation, _implementation_version),545 '%s/%s' % (platform.system(), platform.release()),546 ])547548549def parse_header_links(value):550 """Return a dict of parsed link headers proxies.551552 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
28 unmodified lines
modified:tests/informal/test_leaked_connections.py+5 added-1 removed
2 unmodified lines
3it verifies that Requests does not leak connections when4the body of the request is not read.5"""67import gc, os, subprocess, requests, sys7import gc8import os9import requests10import subprocess11import sys121314def main():15 gc.disable()
16 unmodified lines
modified:tests/test_proxies.py+7 added-5 removed
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34import sys, os, unittest4import os5import sys6import unittest78# Path hack.9sys.path.insert(0, os.path.abspath('..'))10import requests
4 unmodified lines
1516 smoke_url = "https://github.com"1718 def test_empty_https_proxy(self):17 proxy = {"https" : "" }18 result = requests.get(self.smoke_url, verify=False, proxies = proxy)19 proxy = {"https": ""}20 result = requests.get(self.smoke_url, verify=False, proxies=proxy)21 self.assertEqual(result.status_code, 200)2223 def test_empty_http_proxy(self):22 proxy = {"http" : "" }23 result = requests.get(self.smoke_url, proxies = proxy)24 proxy = {"http": ""}25 result = requests.get(self.smoke_url, proxies=proxy)26 self.assertEqual(result.status_code, 200)2728if __name__ == '__main__':29 unittest.main()
modified:tests/test_requests_ext.py+2 added-1 removed
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34# Path hack.5import sys, os5import os6import sys7sys.path.insert(0, os.path.abspath('..'))89import unittest10
114 unmodified lines
modified:tests/test_requests_https.py+2 added-2 removed
1#!/usr/bin/env python2# -*- coding: utf-8 -*-34import sys, os5import json4import os5import sys6import unittest78# Path hack.9sys.path.insert(0, os.path.abspath('..'))
23 unmodified lines
modified:tests/test_requests.py+19 added-7 removed
49 unmodified lines
50 # c = envoy.connect('httpbin %s' % (PORT))51 # time.sleep(1)52 _httpbin = True535455class TestBaseMixin(object):5657 def assertCookieHas(self, cookie, **kwargs):58 """Assert that a cookie has various specified properties."""
1 unmodified line
60 cookie_attr = getattr(cookie, attr)61 message = 'Failed comparison for %s: %s != %s' % (attr, cookie_attr, expected_value)62 self.assertEqual(cookie_attr, expected_value, message)636465class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):66 """Requests test cases."""6768 def test_entry_points(self):
268 unmodified lines
337 for service in SERVICES:338339 with open(__file__) as f:340 url = service('post')339 post1 = post(url,340 files={'some': f},341 data={'some': 'data'})341 post1 = post(url, data={'some': 'data'}, files={'some': f})342 post2 = post(url, data={'some': 'data'}, files=[('some', f)])343 post3 = post(url, data=[('some', 'data')],344 files=[('some', f)])343 post3 = post(url, data=[('some', 'data')], files=[('some', f)])344345 self.assertEqual(post1.status_code, 200)346 self.assertEqual(post2.status_code, 200)347 self.assertEqual(post3.status_code, 200)348349 def test_POSTBIN_GET_POST_FILES_WITH_CJK_PARAMS(self):350351 for service in SERVICES:352353 with open(__file__) as f:354 url = service('post')355 post1 = post(url, data={'some': '中文'}, files={'some': f})356 post2 = post(url, data={'some': '日本語'}, files=[('some', f)])357 post3 = post(url, data=[('some', '한국의')], files=[('some', f)])358359 self.assertEqual(post1.status_code, 200)360 self.assertEqual(post2.status_code, 200)361 self.assertEqual(post3.status_code, 200)362363 def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):364365 for service in SERVICES:366
548 unmodified lines
915916 def test_connection_error_with_safe_mode(self):917 config = {'safe_mode': True}918 r = get('http://localhost:1/nope', allow_redirects=False, config=config)906 assert r.content == None919 assert r.content is None920921 # def test_invalid_content(self):922 # # WARNING: if you're using a terrible DNS provider (comcast),923 # # this will fail.
126 unmodified lines
1050 s = requests.session()1051 s.config['danger_mode'] = True1052 s.get(httpbin('redirect', '4'))105310411054 def test_empty_response(self):1055 r = requests.get(httpbin('status', '404'))1056 r.text1057
138 unmodified lines
modified:AUTHORS.rst+1 added
112 unmodified lines
113- Jakub Roztocil <jakub@roztocil.name>114- Ian Cordasco <graffatcolmingov@gmail.com> @sigmavirus24115- Rhys Elsmore116- André Graf (dergraf)117- Stephen Zhuang (everbird)