Digest auth: case insensitive replacement of 'digest ' string with '' from WWW-Authen...
authorOvidiu Negrut <ovidiu@rohost.com>
Mon, 11 Mar 2013 08:28:37 +0000 (10:28 +0200)
committerOvidiu Negrut <ovidiu@rohost.com>
Mon, 11 Mar 2013 08:28:37 +0000 (10:28 +0200)
requests/auth.py

index 805f240..16546f2 100644 (file)
@@ -8,6 +8,7 @@ This module contains the authentication handlers for Requests.
 """
 
 import os
+import re
 import time
 import hashlib
 import logging
@@ -151,7 +152,7 @@ class HTTPDigestAuth(AuthBase):
         if 'digest' in s_auth.lower() and num_401_calls < 2:
 
             setattr(self, 'num_401_calls', num_401_calls + 1)
-            self.chal = parse_dict_header(s_auth.replace('Digest ', ''))
+            self.chal = parse_dict_header(re.sub(r'digest ', '', s_auth, flags=re.IGNORECASE))
 
             # Consume content and release the original connection
             # to allow our new request to reuse the same one.