Ë
    ¹2ÚiÜ  ã                   ól   — d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	  G d„ de«      Z
 G d„ d	e
«      Zy)
é    N)Úsettings)ÚImproperlyConfigured)ÚNoRedirectionMatchÚProxiedDownloadMiddleware)ÚXAccelRedirectResponsec                   ó<   ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 dˆ fd„	Zd„ Zˆ xZS )ÚXAccelRedirectMiddlewareaS  Configurable middleware, for use in decorators or in global middlewares.

    Standard Django middlewares are configured globally via settings. Instances
    of this class are to be configured individually. It makes it possible to
    use this class as the factory in
    :py:class:`django_downloadview.decorators.DownloadDecorator`.

    c
                 óP  •— |	�9t        j                  d| j                  j                  z  t        «       |€|	}n|}n|}|�9t        j                  d| j                  j                  z  t        «       |€|}n|}n|}t
        t        | �  ||||«       || _        || _	        || _
        y)zConstructor.Nz@%s ``media_url`` is deprecated. Use ``destination_url`` instead.z<%s ``media_root`` is deprecated. Use ``source_dir`` instead.)ÚwarningsÚwarnÚ	__class__Ú__name__ÚDeprecationWarningÚsuperr	   Ú__init__ÚexpiresÚwith_bufferingÚ
limit_rate)ÚselfÚget_responseÚ
source_dirÚ
source_urlÚdestination_urlr   r   r   Ú
media_rootÚ	media_urlr   s             €ú\/var/www/html/acx/venv/lib/python3.12/site-packages/django_downloadview/nginx/middlewares.pyr   z!XAccelRedirectMiddleware.__init__   s¾   ø€ ð Ð Ü�M‰Mð/Ø15·±×1HÑ1HñIä"ôð
 Ð&Ø"+‘à"1‘à-ˆOØÐ!Ü�M‰Mð*Ø,0¯N©N×,CÑ,CñDä"ôð
 Ð!Ø'‘
à'‘
à#ˆJäÔ&¨Ñ6Ø˜* j°/ô	
ð ˆŒØ,ˆÔØ$ˆ�ó    c           	      ó0  — 	 | j                  |«      }| j                  r| j                  }n	 |j                  }t	        ||d   |j
                  || j                  | j                  |j                  ¬«      S # t        $ r |cY S w xY w# t        $ r d}Y Œ[w xY w)zAReplace DownloadResponse instances by NginxDownloadResponse ones.NzContent-Type)Úredirect_urlÚcontent_typeÚbasenamer   r   r   Ú
attachment)	Úget_redirect_urlr   r   ÚAttributeErrorr   r!   r   r   r"   )r   ÚrequestÚresponser   r   s        r   Úprocess_download_responsez2XAccelRedirectMiddleware.process_download_responseE   s£   € ð	Ø×0Ñ0°Ó:ˆLð �<Š<Ø—l‘l‰GðØ"×*Ñ*�ô &Ø%Ø! .Ñ1Ø×&Ñ&ØØ×.Ñ.Ø—‘Ø×*Ñ*ô
ð 	
øô "ò 	ØŠOð	ûô "ò Ø’ðús"   ‚A6 ­B Á6BÂBÂBÂB)	NNNNNNNNN)r   Ú
__module__Ú__qualname__Ú__doc__r   r'   Ú__classcell__©r   s   @r   r	   r	      s0   ø„ ñð ØØØØØØØØõ,%ö\
r   r	   c                   ó$   ‡ — e Zd ZdZdˆ fd„	Zˆ xZS )ÚSingleXAccelRedirectMiddlewarea—  Apply X-Accel-Redirect globally, via Django settings.

    Available settings are:

    NGINX_DOWNLOAD_MIDDLEWARE_SOURCE_URL:
      The string at the beginning of URLs to replace with
      ``NGINX_DOWNLOAD_MIDDLEWARE_DESTINATION_URL``.
      If ``None``, then URLs aren't captured.
      Defaults to ``settings.MEDIA_URL``.

    NGINX_DOWNLOAD_MIDDLEWARE_SOURCE_DIR:
      The string at the beginning of filenames (path) to replace with
      ``NGINX_DOWNLOAD_MIDDLEWARE_DESTINATION_URL``.
      If ``None``, then filenames aren't captured.
      Defaults to ``settings.MEDIA_ROOT``.

    NGINX_DOWNLOAD_MIDDLEWARE_DESTINATION_URL:
      The base URL where requests are proxied to.
      If ``None`` an ImproperlyConfigured exception is raised.

    .. note::

       The following settings are deprecated since version 1.1.
       URLs can be used as redirection source since 1.1, and then "MEDIA_ROOT"
       and "MEDIA_URL" became too confuse.

       NGINX_DOWNLOAD_MIDDLEWARE_MEDIA_ROOT:
         Replaced by ``NGINX_DOWNLOAD_MIDDLEWARE_SOURCE_DIR``.

       NGINX_DOWNLOAD_MIDDLEWARE_MEDIA_URL:
         Replaced by ``NGINX_DOWNLOAD_MIDDLEWARE_DESTINATION_URL``.

    c           	      óF  •— t         j                  €"t        d| j                  j                  z  «      ‚t
        t        | �  |t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  ¬«       y)z%Use Django settings as configuration.NzOsettings.NGINX_DOWNLOAD_MIDDLEWARE_DESTINATION_URL is required by %s middleware)r   r   r   r   r   r   r   )r   Ú)NGINX_DOWNLOAD_MIDDLEWARE_DESTINATION_URLr   r   r   r   r.   r   Ú$NGINX_DOWNLOAD_MIDDLEWARE_SOURCE_DIRÚ$NGINX_DOWNLOAD_MIDDLEWARE_SOURCE_URLÚ!NGINX_DOWNLOAD_MIDDLEWARE_EXPIRESÚ(NGINX_DOWNLOAD_MIDDLEWARE_WITH_BUFFERINGÚ$NGINX_DOWNLOAD_MIDDLEWARE_LIMIT_RATE)r   r   r   s     €r   r   z'SingleXAccelRedirectMiddleware.__init__€   s„   ø€ ä×=Ñ=ÐEÜ&ð,Ø.2¯n©n×.EÑ.EñFóð ô 	Ô,¨dÑ<Ø%Ü×DÑDÜ×DÑDÜ$×NÑNÜ×>Ñ>Ü#×LÑLÜ×DÑDð 	=õ 	
r   )N)r   r(   r)   r*   r   r+   r,   s   @r   r.   r.   ]   s   ø„ ñ ÷D
ñ 
r   r.   )r   Údjango.confr   Údjango.core.exceptionsr   Údjango_downloadview.middlewaresr   r   Ú"django_downloadview.nginx.responser   r	   r.   © r   r   ú<module>r;      s6   ðÛ å  Ý 7÷õ FôM
Ð8ô M
ô`2
Ð%=õ 2
r   