Ë
    "ïàjs"  ã                   óz   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 dZ
 ej                  e«      Z G d„ de«      Zy	)
a¹  
WSGI middleware that finds the registered mapped DAV-Provider, creates a new
RequestServer instance, and dispatches the request.

.. warning::
   The following documentation was taken over from PyFileServer and is outdated.

WsgiDAV file sharing
--------------------

WsgiDAV allows the user to specify in wsgidav.conf a number of
realms, and a number of users for each realm.

Realms
   Each realm corresponds to a filestructure on disk to be stored,
   for example::

      addShare('pubshare','/home/public/share')

   would allow the users to access using WebDAV the directory/file
   structure at /home/public/share from the url
   http://<servername:port>/<approot>/pubshare

   The realm name is set as '/pubshare'

   e.g. /home/public/share/WsgiDAV/LICENSE becomes accessible as
   http://<servername:port>/<approot>/pubshare/WsgiDAV/LICENSE

Users
   A number of user_name/password pairs can be set for each realm::

      adduser('pubshare', 'user_name', 'password', 'description/unused')

   would add a user_name/password pair to realm /pubshare.

Note: if developers wish to maintain a separate users database, you can
write your own domain controller for the HTTPAuthenticator. See
http_authenticator.py and domain_controller.py for more details.


Request Resolver
----------------

WSGI middleware for resolving Realm and Paths for the WsgiDAV
application.

Usage::
   It *must* be configured as the last item on `middleware_stack` list.

   from wsgidav.request_resolver import RequestResolver
   config = {
        ...,
        'middleware_stack': [
            ...,
            RequestResolver,
        ],
    }

The RequestResolver resolves the requested URL to the following values
placed in the environ dictionary. First it resolves the corresponding
realm::

   url: http://<servername:port>/<approot>/pubshare/WsgiDAV/LICENSE
   environ['wsgidav.mappedrealm'] = /pubshare

Based on the configuration given, the resource abstraction layer for the
realm is determined. if no configured abstraction layer is found, the
default abstraction layer fileabstractionlayer.FilesystemAbstractionLayer()
is used::

   environ['wsgidav.resourceAL'] = fileabstractionlayer.MyOwnFilesystemAbstractionLayer()

The path identifiers for the requested url are then resolved using the
resource abstraction layer::

   environ['wsgidav.mappedpath'] = /home/public/share/WsgiDAV/LICENSE
   environ['wsgidav.mappedURI'] = /pubshare/WsgiDAV/LICENSE

in this case, FilesystemAbstractionLayer resolves any relative paths
to its canonical absolute path

The RequestResolver also resolves any value in the Destination request
header, if present, to::

   Destination: http://<servername:port>/<approot>/pubshare/WsgiDAV/LICENSE-dest
   environ['wsgidav.destrealm'] = /pubshare
   environ['wsgidav.destpath'] = /home/public/share/WsgiDAV/LICENSE-dest
   environ['wsgidav.destURI'] = /pubshare/WsgiDAV/LICENSE
   environ['wsgidav.destresourceAL'] = fileabstractionlayer.MyOwnFilesystemAbstractionLayer()

é    )Úutil)ÚHTTP_NOT_FOUNDÚDAVError)ÚBaseMiddleware)ÚRequestServerÚreStructuredTextc                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚRequestResolverc                 ó(   •— t         ‰| �  |||«       y )N)ÚsuperÚ__init__)ÚselfÚwsgidav_appÚnext_appÚconfigÚ	__class__s       €úG/srv/dav/.venv/lib/python3.12/site-packages/wsgidav/request_resolver.pyr   zRequestResolver.__init__Ÿ   s   ø€ Ü‰Ñ˜ h°Õ7ó    c              #   ób  K  — |d   }|d   }|d   }t        j                  |dd¬«      }|d   dk(  xr |d	k(  }|d
k(  r+|j                  d«      }|rd}nt        j	                  d«       |rrd}	|�|j                  «       s|j                  €d}	ddd|	fdt        j                  «       fg}
|d   j                  dd«      r|
j                  d«        |d|
«       d–— y |€t        t        d|›�«      ‚t        |«      } |||«      }|E d {  –—†  t        |d«      r|j                  «        y 7 Œ!­w)NÚ	PATH_INFOzwsgidav.providerzwsgidav.configÚhotfixesT)Úas_dictÚREQUEST_METHODÚOPTIONSÚ*ú/Útreat_root_options_as_asteriskzGot OPTIONS '/' requestz1,2Ú1)zContent-Typeztext/html; charset=utf-8)zContent-LengthÚ0ÚDAVÚDateÚadd_header_MS_Author_ViaF)zMS-Author-Viar    z200 OKr   z%Could not find resource provider for Úclose)r   Úget_dict_valueÚgetÚ_loggerÚinfoÚis_readonlyÚlock_managerÚget_rfc1123_timeÚappendr   r   r   Úhasattrr#   )r   ÚenvironÚstart_responseÚpathÚproviderr   r   Úis_asterisk_optionsÚtreat_as_asteriskÚdav_compliance_levelÚheadersÚappÚapp_iters                r   Ú__call__zRequestResolver.__call__¢   ss  è ø€ Ø�{Ñ#ˆð
 Ð-Ñ.ˆØÐ)Ñ*ˆÜ×&Ñ& v¨zÀ4ÔHˆà%Ð&6Ñ7¸9ÑDÒTÈÐQTÉÐØ�3Š;à (§¡Ð-MÓ NÐÙ Ø&*Ñ#ä—‘Ð6Ô7áð $)Ð ð Ð Ø×'Ñ'Ô)Ø×(Ñ(Ð0à'*Ð$ð =Ø'ØÐ,Ð-Øœ×.Ñ.Ó0Ð1ð	ˆGð Ð'Ñ(×,Ñ,Ð-GÈÔOØ—‘Ð7Ô8á˜8 WÔ-ØŠIØàÐÜÜÐ"GÈÀxÐ Póð ô ˜HÓ%ˆÙ�w Ó/ˆà×Ðä�8˜WÔ%Ø�N‰NÔØð	 	ús   ‚D	D/ÄD-Ä"D/)Ú__name__Ú
__module__Ú__qualname__r   r7   Ú__classcell__)r   s   @r   r
   r
   ž   s   ø„ ô8öCr   r
   N)Ú__doc__Úwsgidavr   Úwsgidav.dav_errorr   r   Úwsgidav.mw.base_mwr   Úwsgidav.request_serverr   Ú__docformat__Úget_module_loggerr8   r&   r
   © r   r   ú<module>rD      s@   ðñ
Zõx ß 6Ý -Ý 0à"€à
 ˆ$×
 Ñ
  Ó
*€ôlG�nõ Gr   