mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Take advantage of the new copy method
This commit is contained in:
+1
-7
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user