
    g                         S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
r
S SKr
S SKJr  S SKJrJr  S SKJr  S SKJrJrJr  S SKJrJrJr  \R6                  \S	4   r " S
 S\5      r " S S5      rg)    )annotationsN)	parsedate)get_route_path)URLHeaders)HTTPException)FileResponseRedirectResponseResponse)ReceiveScopeSendzos.PathLike[str]c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )NotModifiedResponse   )zcache-controlzcontent-locationdateetagexpiresvaryc           	        > [         TU ]  SUR                  5        VVs0 s H  u  p#X R                  ;   d  M  X#_M     snnS9  g s  snnf )Ni0  )status_codeheaders)super__init__itemsNOT_MODIFIED_HEADERS)selfr   namevalue	__class__s       N/home/matz/Project1/venv/lib/python3.13/site-packages/starlette/staticfiles.pyr   NotModifiedResponse.__init__    sD    4;MMOiO[TtOhOhGh[T[Oi 	 	
is
   AA )r   r   )__name__
__module____qualname____firstlineno__r   r   __static_attributes____classcell__)r    s   @r!   r   r      s    
 
    r   c                      \ rS rSrSSSSSS.           SS jjr  S     SS jjrSS jrSS	 jrSS
 jrSS jr	 S         SS jjr
SS jrSS jrSrg)StaticFiles'   NFT)	directorypackageshtml	check_dirfollow_symlinkc                   Xl         X l        U R                  X5      U l        X0l        SU l        XPl        U(       a8  Ub4  [        R                  R                  U5      (       d  [        SU S35      eg g g )NFDirectory 'z' does not exist)r.   r/   get_directoriesall_directoriesr0   config_checkedr2   ospathisdirRuntimeError)r   r.   r/   r0   r1   r2   s         r!   r   StaticFiles.__init__(   sn     # #33IH	#,.rww}}Y7O7OYK7GHII 8P.9r*   c                6   / nUb  UR                  U5        U=(       d    /  H  n[        U[        5      (       a  Uu  pEOSn[        R                  R                  U5      nUc   SU< S35       eUR                  c   SU< S35       e[        R                  R                  [        R                  R                  UR                  SU5      5      n[        R                  R                  U5      (       d   SU< SU< S35       eUR                  U5        M     U$ )z
Given `directory` and `packages` arguments, return a list of all the
directories that should be used for serving static files from.
staticszPackage z could not be found.z..r4   z' in package )append
isinstancetuple	importlibutil	find_specoriginr8   r9   normpathjoinr:   )r   r.   r/   directoriespackagestatics_dirspecpackage_directorys           r!   r5   StaticFiles.get_directories:   s     y)~2~G'5))'.$'>>++G4D#Ox{:N%OO#;;*VhwkAU,VV* " 0 0dkk4Q\1] ^77==!  Y[O=CWXY  01 & r*   c                  #    US   S:X  d   eU R                   (       d  U R                  5       I Sh  vN   SU l         U R                  U5      nU R                  XA5      I Sh  vN nU" XU5      I Sh  vN   g NG N N	7f)z
The ASGI entry point.
typehttpNT)r7   check_configget_pathget_response)r   scopereceivesendr9   responses         r!   __call__StaticFiles.__call__W   sz      V}&&&""##%%%"&D}}U#**477ut,,, & 8,s3   0B A:0B #A<$B 4A>5B <B >B c                    [        U5      n[        R                  R                  [        R                  R                  " UR                  S5      6 5      $ )z
Given the ASGI scope, return the `path` string to serve up,
with OS specific path separators, and any '..', '.' components removed.
/)r   r8   r9   rF   rG   split)r   rT   
route_paths      r!   rR   StaticFiles.get_pathe   s;    
 $E*
wwj.>.>s.C DEEr*   c                  #    US   S;  a	  [        SS9e [        R                  R                  U R                  U5      I Sh  vN u  p4U(       a7  [        R                  " UR                  5      (       a  U R                  X4U5      $ U(       Ga  [        R                  " UR                  5      (       a  U R                  (       a  [        R                   R#                  US5      n[        R                  R                  U R                  U5      I Sh  vN u  p4Ub~  [        R                  " UR                  5      (       aY  US	   R%                  S
5      (       d.  ['        US9nUR)                  UR                   S
-   S9n[+        US9$ U R                  X4U5      $ U R                  (       aj  [        R                  R                  U R                  S5      I Sh  vN u  p4U(       a/  [        R                  " UR                  5      (       a
  [-        X4SS9$ [        SS9e GN! [
         a
    [        SS9e[         a.  nUR                  [        R                  :X  a	  [        SS9eUeSnAff = f GN\ N7f)zP
Returns an HTTP response, given the incoming path, method and request headers.
method)GETHEADi  )r   Ni  i  z
index.htmlr9   r[   rT   )r9   )urlz404.html)stat_resultr   )r   anyio	to_threadrun_synclookup_pathPermissionErrorOSErrorerrnoENAMETOOLONGstatS_ISREGst_modefile_responseS_ISDIRr0   r8   r9   rG   endswithr   replacer
   r	   )r   r9   rT   	full_pathre   exc
index_pathrd   s           r!   rS   StaticFiles.get_responsem   s     ?/1C00		+0??+C+CDDTDTVZ+[%["I 4<<(;(;<<%%ieDDT\\+*=*=>>499 dL9J+0??+C+CDDTDTV`+a%a"I&4<<8K8K+L+LV}--c22E*C++388c>+:C+44)))%HH99+0??+C+CDDTDTV`+a%a"It||K,?,?@@#ITWXX,,A &\ 	1C00 	yyE...#44I	 &b &bs[   I4-H" HH" 
C	I4I/CI4I2AI4H" "I,>)I''I,,I42I4c                   U R                    H  n[        R                  R                  X!5      nU R                  (       a   [        R                  R                  U5      nO>[        R                  R                  U5      n[        R                  R                  U5      n[        R                  R                  XB/5      [        U5      :w  a  M   U[        R                  " U5      4s  $    g! [        [        4 a     M  f = f)N) N)r6   r8   r9   rG   r2   abspathrealpath
commonpathstrrn   FileNotFoundErrorNotADirectoryError)r   r9   r.   joined_pathru   s        r!   ri   StaticFiles.lookup_path   s    --I'',,y7K""GGOOK8	GG,,[9	GG,,Y7	ww!!9"89S^K "'')"444 .  &'9: s   C++C?>C?c                    [        US9n[        XUS9nU R                  UR                  U5      (       a  [	        UR                  5      $ U$ )Nrc   )r   re   )r   r	   is_not_modifiedr   r   )r   ru   re   rT   r   request_headersrW   s          r!   rq   StaticFiles.file_response   sJ     ".	P[\ 0 0/BB&x'7'788r*   c                  #    U R                   c  g [        R                  R                  [        R
                  U R                   5      I Sh  vN n[
        R                  " UR                  5      (       d?  [
        R                  " UR                  5      (       d  [        SU R                    S35      egg Ni! [         a    [        SU R                    S35      ef = f7f)z
Perform a one-off configuration check that StaticFiles is actually
pointed at a directory, so that we can raise loud errors rather than
just returning 404 responses.
NzStaticFiles directory 'z' does not exist.zStaticFiles path 'z' is not a directory.)r.   rf   rg   rh   r8   rn   r   r;   rr   rp   S_ISLNK)r   re   s     r!   rQ   StaticFiles.check_config   s      >>!	\ % 8 8$.. QQK [0011T\\+BUBU5V5V!3DNN3CCXYZZ 6W1 R  	\!88HHYZ[[	\s/   C ;B9 B7B9 A%C 7B9 9$CC c                     US   nUS   nXCR                  S5       Vs/ s H  oUR                  S5      PM     sn;   a  g  [        US   5      n[        US   5      nUb	  Ub  Xg:  a  ggs  snf ! [         a     N;f = f! [         a     gf = f)	zu
Given the request and response headers, return `True` if an HTTP
"Not Modified" response could be returned instead.
zif-none-matchr   ,z W/Tzif-modified-sincezlast-modifiedF)r\   stripKeyErrorr   )r   response_headersr   if_none_matchr   tagif_modified_sincelast_modifieds           r!   r   StaticFiles.is_not_modified   s    
	+O<M#F+D4G4G4LM4LS		%(4LMM N
	 )/:M*N O%&6&GHM ,1JO`Oq  N 		  		s3   A0 A+A0 'B  +A0 0
A=<A= 
BB)r6   r7   r.   r2   r0   r/   )r.   PathLike | Noner/   "list[str | tuple[str, str]] | Noner0   boolr1   r   r2   r   returnNone)NN)r.   r   r/   r   r   zlist[PathLike])rT   r   rU   r   rV   r   r   r   )rT   r   r   r~   )r9   r~   rT   r   r   r   )r9   r~   r   z!tuple[str, os.stat_result | None])   )
ru   PathLikere   zos.stat_resultrT   r   r   intr   r   )r   r   )r   r   r   r   r   r   )r$   r%   r&   r'   r   r5   rX   rR   rS   ri   rq   rQ   r   r(   r#   r*   r!   r,   r,   '   s     &*7;$J #J 5	J
 J J J 
J( &*7;" 5 
	:-F(-T,  $ 	
  
[ r*   r,   ) 
__future__r   rl   importlib.utilrB   r8   rn   typingemail.utilsr   rf   anyio.to_threadstarlette._utilsr   starlette.datastructuresr   r   starlette.exceptionsr   starlette.responsesr	   r
   r   starlette.typesr   r   r   Unionr~   r   r   r,   r#   r*   r!   <module>r      sa    "   	   !   + 1 . H H 0 0<<//0
( 
"t tr*   