
    3 d                     h    d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ  G d d	          ZdS )
zc
HTTP basic auth downloader middleware

See documentation in docs/topics/downloader-middleware.rst
    N)basic_auth_header)signals)ScrapyDeprecationWarning)urlparse_cached)url_is_from_any_domainc                   4    e Zd ZdZed             Zd Zd ZdS )HttpAuthMiddlewarezYSet Basic HTTP Authorization header
    (http_user and http_pass spider class attributes)c                 p     |             }|j                             |j        t           j                   |S )N)signal)r   connectspider_opened)clscrawleros      Elib/python3.11/site-packages/scrapy/downloadermiddlewares/httpauth.pyfrom_crawlerzHttpAuthMiddleware.from_crawler   s2    CEE8MNNN    c                    t          |dd          }t          |dd          }|s|r^t          ||          | _        t          |d          s$t	          j        dt                     d| _        d S |j        | _	        d| _        d S d S )	N	http_user 	http_passhttp_auth_domaina
  Using HttpAuthMiddleware without http_auth_domain is deprecated and can cause security problems if the spider makes requests to several different domains. http_auth_domain will be set to the domain of the first request, please set it to the correct value explicitly.)categoryTF)
getattrr   authhasattrwarningswarnr   domain_unsetr   domain)selfspiderusrpwds       r   r   z HttpAuthMiddleware.spider_opened   s    fk2..fk2.. 	*# 	*)#s33DI6#566 *" 6    %)!!!$5$)!!!	* 	*r   c                     t          | dd           }|r`d|j        vrYt          |          j        }| j        r|| _        d| _        | j        rt          |j        | j        g          r||j        d<   d S d S d S d S )Nr   s   AuthorizationF)r   headersr   hostnamer   r    r   url)r!   requestr"   r   r    s        r   process_requestz"HttpAuthMiddleware.process_request,   s    tVT** 	9$GO; 	9$W--6F  *$$)!; 9"8t{m"T"T 948 0111	9 	9 	9 	9
9 9r   N)__name__
__module____qualname____doc__classmethodr   r   r*    r   r   r	   r	      sW        9 9   [
* * *$9 9 9 9 9r   r	   )r.   r   
w3lib.httpr   scrapyr   scrapy.exceptionsr   scrapy.utils.httpobjr   scrapy.utils.urlr   r	   r0   r   r   <module>r6      s    
  ( ( ( ( ( (       6 6 6 6 6 6 0 0 0 0 0 0 3 3 3 3 3 3$9 $9 $9 $9 $9 $9 $9 $9 $9 $9r   