Merge branch 'auth-digest-multi-thread' of https://github.com/exvito/requests into proposed/2.8.0

This commit is contained in:
Ian Cordasco
2015-07-18 10:38:58 -05:00
2 changed files with 58 additions and 27 deletions
+20
View File
@@ -33,6 +33,11 @@ try:
except ImportError:
import io as StringIO
try:
from multiprocessing.pool import ThreadPool
except ImportError:
ThreadPool = None
if is_py3:
def u(s):
return s
@@ -412,6 +417,21 @@ class RequestsTestCase(unittest.TestCase):
r = requests.get(url, auth=auth)
assert '"auth"' in r.request.headers['Authorization']
def test_DIGESTAUTH_THREADED(self):
auth = HTTPDigestAuth('user', 'pass')
url = httpbin('digest-auth', 'auth', 'user', 'pass')
session = requests.Session()
session.auth=auth
def do_request(i):
r = session.get(url)
assert '"auth"' in r.request.headers['Authorization']
return 1
if ThreadPool is not None:
pool = ThreadPool(processes=50)
pool.map(do_request, range(100))
def test_POSTBIN_GET_POST_FILES(self):
url = httpbin('post')