mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Fixing bug #227562 by calling URLopener.http_error_default when
an invalid 401 request is being handled.
This commit is contained in:
		
							parent
							
								
									be77cf7d57
								
							
						
					
					
						commit
						e99bd17ed6
					
				
					 1 changed files with 18 additions and 12 deletions
				
			
		|  | @ -560,13 +560,19 @@ def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): | |||
|         """Error 401 -- authentication required. | ||||
|         See this URL for a description of the basic authentication scheme: | ||||
|         http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt""" | ||||
|         if headers.has_key('www-authenticate'): | ||||
|         if not headers.has_key('www-authenticate'): | ||||
|             URLopener.http_error_default(self, url, fp,  | ||||
|                                          errmsg, headers) | ||||
|         stuff = headers['www-authenticate'] | ||||
|         import re | ||||
|         match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff) | ||||
|             if match: | ||||
|         if not match: | ||||
|             URLopener.http_error_default(self, url, fp,  | ||||
|                                          errcode, errmsg, headers) | ||||
|         scheme, realm = match.groups() | ||||
|                 if scheme.lower() == 'basic': | ||||
|         if scheme.lower() != 'basic': | ||||
|             URLopener.http_error_default(self, url, fp,  | ||||
|                                          errcode, errmsg, headers) | ||||
|         name = 'retry_' + self.type + '_basic_auth' | ||||
|         if data is None: | ||||
|             return getattr(self,name)(url, realm) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Moshe Zadka
						Moshe Zadka