From: Ian Cordasco Date: Sun, 28 Jul 2013 03:08:46 +0000 (-0400) Subject: Take advantage of the new copy method X-Git-Tag: v2.0~5^2~14^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=286ddb672d3ff39b1807402a7d9ca569a86516d6;p=services%2Fpython-requests.git Take advantage of the new copy method --- diff --git a/requests/auth.py b/requests/auth.py index 43b3bec..81a3d93 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -145,7 +145,6 @@ class HTTPDigestAuth(AuthBase): def handle_401(self, r, **kwargs): """Takes the given response and tries digest-auth, if needed.""" - from .models import PreparedRequest num_401_calls = getattr(self, 'num_401_calls', 1) s_auth = r.headers.get('www-authenticate', '') @@ -159,12 +158,7 @@ class HTTPDigestAuth(AuthBase): # to allow our new request to reuse the same one. r.content r.raw.release_conn() - prep = PreparedRequest() - prep.method = r.request.method - prep.url = r.request.url - prep.body = r.request.body - prep.headers = r.request.headers.copy() - prep.hooks = r.request.hooks + prep = r.request.copy() prep.prepare_cookies(r.cookies) prep.headers['Authorization'] = self.build_digest_header( diff --git a/requests/sessions.py b/requests/sessions.py index ca7e217..11a90f2 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -74,10 +74,7 @@ class SessionRedirectMixin(object): # ((resp.status_code is codes.see_other)) while (('location' in resp.headers and resp.status_code in REDIRECT_STATI)): - prepared_request = PreparedRequest() - prepared_request.body = req.body - prepared_request.headers = req.headers.copy() - prepared_request.hooks = req.hooks + prepared_request = req.copy() resp.content # Consume socket so it can be released