ó
    ½Rjà  ã                   ó˜   • S SK r S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S S	KJr   " S
 S\5      r " S S\5      rg)é    N)Úurlparse)Úsettings)ÚPermissionDenied)Úmail_managers)ÚHttpResponsePermanentRedirect)Úis_valid_path)ÚMiddlewareMixin)Úescape_leading_slashesc                   ó4   • \ rS rSrSr\rS rS rS r	S r
Srg)	ÚCommonMiddlewareé   aÛ  
"Common" middleware for taking care of some basic operations:

    - Forbid access to User-Agents in settings.DISALLOWED_USER_AGENTS

    - URL rewriting: Based on the APPEND_SLASH and PREPEND_WWW settings,
      append missing slashes and/or prepends missing "www."s.

        - If APPEND_SLASH is set and the initial URL doesn't end with a
          slash, and it is not found in urlpatterns, form a new URL by
          appending a slash at the end. If this new URL is found in
          urlpatterns, return an HTTP redirect to this new URL; otherwise
          process the initial URL as usual.

      This behavior can be customized by subclassing CommonMiddleware and
      overriding the response_redirect_class attribute.
c                 óì  • UR                   R                  S5      nUb8  [        R                   H$  nUR	                  U5      (       d  M  [        S5      e   UR                  5       n[        R                  (       ay  U(       aq  UR                  S5      (       dZ  U R                  U5      (       a  U R                  U5      nOUR                  5       nU R                  UR                   SU U 35      $ ggg)zj
Check for denied User-Agents and rewrite the URL based on
settings.APPEND_SLASH and settings.PREPEND_WWW
ÚHTTP_USER_AGENTNzForbidden user agentzwww.z://www.)ÚMETAÚgetr   ÚDISALLOWED_USER_AGENTSÚsearchr   Úget_hostÚPREPEND_WWWÚ
startswithÚshould_redirect_with_slashÚget_full_path_with_slashÚget_full_pathÚresponse_redirect_classÚscheme)ÚselfÚrequestÚ
user_agentÚuser_agent_regexÚhostÚpaths         ÚDD:\diplom_project\venv\Lib\site-packages\django/middleware/common.pyÚprocess_requestÚ CommonMiddleware.process_request"   sÙ   € ð —\‘\×%Ñ%Ð&7Ó8ˆ
ØÑ!Ü$,×$CÔ$CÐ Ø#×*Ñ*¨:×6Ó6Ü*Ð+AÓBÐBñ %Dð
 ×ÑÓ!ˆä××¦D°·±À×1HÑ1Hð
 ×.Ñ.¨w×7Ñ7Ø×4Ñ4°WÓ=‘à×,Ñ,Ó.�à×/Ñ/°7·>±>Ð2BÀ'È$ÈÐPTÈvÐ0VÓWÐWð 2I DÐó    c                 ó0  • [         R                  (       a�  UR                  R                  S5      (       da  [	        USS5      n[        UR                  U5      (       d9  [        SUR                  -  U5      nU(       a  UR                  n[	        USS5      $ g)z€
Return True if settings.APPEND_SLASH is True and appending a slash to
the request path turns an invalid path into a valid one.
Ú/ÚurlconfNz%s/Úshould_append_slashTF)r   ÚAPPEND_SLASHÚ	path_infoÚendswithÚgetattrr   Úfunc)r   r   r(   ÚmatchÚviews        r"   r   Ú+CommonMiddleware.should_redirect_with_slash>   sz   € ô
 × × ¨×):Ñ):×)CÑ)CÀC×)HÑ)HÜ˜g y°$Ó7ˆGÜ  ×!2Ñ!2°G×<Ñ<Ü% e¨g×.?Ñ.?Ñ&?ÀÓI�ÞØ Ÿ:™:�DÜ" 4Ð)>ÀÓEÐEØr%   c                 óÜ   • UR                  SS9n[        U5      n[        R                  (       a<  UR                  S;   a,  [        SUR                  UR                  5       U-   S.-  5      eU$ )z 
Return the full path of the request with a trailing slash appended.

Raise a RuntimeError if settings.DEBUG is True and request.method is
POST, PUT, or PATCH.
T)Úforce_append_slash)ÚPOSTÚPUTÚPATCHa"  You called this URL via %(method)s, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining %(method)s data. Change your form to point to %(url)s (note the trailing slash), or set APPEND_SLASH=False in your Django settings.)ÚmethodÚurl)r   r
   r   ÚDEBUGr7   ÚRuntimeErrorr   )r   r   Únew_paths      r"   r   Ú)CommonMiddleware.get_full_path_with_slashL   sr   € ð ×(Ñ(¸DÐ(ÐAˆä)¨(Ó3ˆÜ�>�>˜gŸn™nÐ0HÓHÜðMð &Ÿn™nØ"×+Ñ+Ó-°Ñ8ññó
ð 
ð ˆr%   c                 ó6  • UR                   S:X  a6  U R                  U5      (       a   U R                  U R                  U5      5      $ UR                  (       dA  UR                  S5      (       d+  [        [        UR                  5      5      UR                  S'   U$ )z�
When the status code of the response is 404, it may redirect to a path
with an appended slash if should_redirect_with_slash() returns True.
é”  zContent-Length)
Ústatus_coder   r   r   Ú	streamingÚ
has_headerÚstrÚlenÚcontentÚheaders)r   r   Úresponses      r"   Úprocess_responseÚ!CommonMiddleware.process_responsed   s€   € ð ×Ñ 3Ó&¨4×+JÑ+JÈ7×+SÑ+SØ×/Ñ/°×0MÑ0MÈgÓ0VÓWÐWð ×!×!¨(×*=Ñ*=Ð>N×*OÑ*OÜ14´S¸×9IÑ9IÓ5JÓ1KˆH×ÑÐ-Ñ.àˆr%   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r#   r   r   rG   Ú__static_attributes__rI   r%   r"   r   r      s$   † ñð$ <ÐòXò8òõ0r%   r   c                   ó&   • \ rS rSrS rS rS rSrg)ÚBrokenLinkEmailsMiddlewareév   c                 óÞ  • UR                   S:X  aÜ  [        R                  (       dÇ  UR                  5       nUR	                  5       nUR
                  R                  SS5      nU R                  XX55      (       dt  UR
                  R                  SS5      nUR
                  R                  SS5      n[        SU R                  X55      (       a  SOS< S	U< 3S
U< SU< SU< SU< S3	SS9  U$ )z=Send broken link emails for relevant 404 NOT FOUND responses.r>   ÚHTTP_REFERERÚ r   z<none>ÚREMOTE_ADDRzBroken z	INTERNAL zlink on z
Referrer: z
Requested URL: z
User agent: z
IP address: Ú
T)Úfail_silently)
r?   r   r9   r   r   r   r   Úis_ignorable_requestr   Úis_internal_request)r   r   rF   Údomainr!   ÚrefererÚuaÚips           r"   rG   Ú+BrokenLinkEmailsMiddleware.process_responsew   sÕ   € à×Ñ 3Ó&¬x¯~¯~Ø×%Ñ%Ó'ˆFØ×(Ñ(Ó*ˆDØ—l‘l×&Ñ& ~°rÓ:ˆGà×,Ñ,¨W¸F×LÑLØ—\‘\×%Ñ%Ð&7¸ÓB�Ø—\‘\×%Ñ% m°XÓ>�Ýð
  $×7Ñ7¸×HÑHñ (à!#ò$ò ñó +2³4»»RðAà"&òð ˆr%   c                 óp   • [        [        R                  " S[        R                  " U5      -  U5      5      $ )zM
Return True if the referring URL is the same domain as the current
request.
z^https?://%s/)ÚboolÚrer/   Úescape)r   r[   r\   s      r"   rZ   Ú.BrokenLinkEmailsMiddleware.is_internal_request‘   s(   € ô ”B—H’H˜_¬r¯yªy¸Ó/@Ñ@À'ÓJÓKÐKr%   c                 óZ  ^• U(       d  g[         R                  (       a   TR                  S5      (       a
  UTSS :X  a  gU R                  X45      (       d  SU;   a  g[	        U5      nUR
                  SU4;   a  UR                  T:X  a  g[        U4S j[         R                   5       5      $ )z—
Return True if the given request *shouldn't* notify the site managers
according to project settings or in situations outlined by the inline
comments.
Tr'   NéÿÿÿÿÚ?rU   c              3   óD   >#   • U  H  oR                  T5      v •  M     g 7f)N)r   )Ú.0ÚpatternÚuris     €r"   Ú	<genexpr>ÚBBrokenLinkEmailsMiddleware.is_ignorable_request.<locals>.<genexpr>²   s   øé € ÐRÒ6Q¨7—>‘> #×&Ð&Ò6Qùs   ƒ )	r   r*   r,   rZ   r   Únetlocr!   ÚanyÚIGNORABLE_404_URLS)r   r   rk   r[   r\   Úparsed_referers     `   r"   rY   Ú/BrokenLinkEmailsMiddleware.is_ignorable_request™   s•   ø€ ö Øô × ×  S§\¡\°#×%6Ñ%6¸7ÀcÈ#È2ÀhÓ;NØð ×'Ñ'¨×8Ñ8¸SÀG»^Øô " 'Ó*ˆØ× Ñ  R¨ LÓ0°^×5HÑ5HÈCÓ5OØäÔR´h×6QÒ6QÓRÓRÐRr%   rI   N)rJ   rK   rL   rM   rG   rZ   rY   rO   rI   r%   r"   rQ   rQ   v   s   † òò4LõSr%   rQ   )rb   Úurllib.parser   Údjango.confr   Údjango.core.exceptionsr   Údjango.core.mailr   Údjango.httpr   Údjango.urlsr   Údjango.utils.deprecationr	   Údjango.utils.httpr
   r   rQ   rI   r%   r"   Ú<module>r{      s=   ðÛ 	Ý !å  Ý 3Ý *Ý 5Ý %Ý 4Ý 4ôf�ô fôR<S õ <Sr%   