HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/twisted/web/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/web/__pycache__/vhost.cpython-312.pyc
�

Ϫ�fG����dZddlmZddlmZmZGd�dej�ZGd�dej�Z	Gd�d	ej�Z
Gd
�dej�Zy)
z&
I am a virtual hosts implementation.
�)�roots)�pages�resourcec�F�eZdZdZej
Zd�Zd�Zd�Z	d�Z
d�Zy)�VirtualHostCollectionzWWrapper for virtual hosts collection.

    This exists for configuration purposes.
    c��||_y�N)�nvh)�selfr
s  �3/usr/lib/python3/dist-packages/twisted/web/vhost.py�__init__zVirtualHostCollection.__init__s	�����c�J�|jjj�Sr	)r
�hosts�items�rs r�listStaticEntitiesz(VirtualHostCollection.listStaticEntitiess���x�x�~�~�#�#�%�%rc�L�|jjj|�Sr	)r
r�get�r�names  r�getStaticEntityz%VirtualHostCollection.getStaticEntitys���x�x�~�~�!�!�$�'�'rc�<�|jj||�yr	)r
�addHost)rr�entitys   r�reallyPutEntityz%VirtualHostCollection.reallyPutEntity s��������v�&rc�:�|jj|�yr	)r
�
removeHostrs  r�	delEntityzVirtualHostCollection.delEntity#s�������D�!rN)�__name__�
__module__�__qualname__�__doc__r�Resource�
entityTyper
rrrr�rrrrs-���
�"�"�J��&�(�'�"rrc�D�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�NameVirtualHostz5I am a resource which represents named virtual hosts.Nc�P�tjj|�i|_y)zInitialize.N)rr$r
rrs rr
zNameVirtualHost.__init__,s�����"�"�4�(���
rc�^�tjj|�dt|�fgzS�Nz
Virtual Hosts)rr$rrrs rrz"NameVirtualHost.listStaticEntities1s3��� � �3�3�D�9�
�3�D�9�:�=
�
�	
rc�b�|dk(rt|�Stjj||�Sr+)rrr$rrs  rrzNameVirtualHost.getStaticEntity6s.���?�"�(��.�.��$�$�4�4�T�4�@�@rc�"�||j|<y)a�Add a host to this virtual host.

        This will take a host named `name', and map it to a resource
        `resrc'.  For example, a setup for our virtual hosts would be::

            nvh.addHost('divunal.com', divunalDirectory)
            nvh.addHost('www.divunal.com', divunalDirectory)
            nvh.addHost('twistedmatrix.com', twistedMatrixDirectory)
            nvh.addHost('www.twistedmatrix.com', twistedMatrixDirectory)
        N�r)rr�resrcs   rrzNameVirtualHost.addHost<s��!��
�
�4�rc��|j|=y)zRemove a host.Nr.rs  rrzNameVirtualHost.removeHostIs���J�J�t�rc�V�|jd�}|�"|jxstj�S|j	�jdd�d}|jj||j�xs*tjdd|jdd��d	��S)
z;(Internal) Get the appropriate resource for the given host.shost�:�rz	Not Foundzhost �ascii�replacez not in vhost map)	�	getHeader�defaultr�notFound�lower�splitrr�decode)r�request�
hostHeader�hosts    r�_getResourceForRequestz&NameVirtualHost._getResourceForRequestMs����&�&�w�/�
����<�<�3�5�>�>�#3�3��#�#�%�+�+�D�!�4�Q�7�D��z�z�~�~�d�D�L�L�1�
�U�^�^���D�K�K���3�6�6G�H�6
�	
rc�F�|j|�}|j|�S)z4Implementation of resource.Resource's render method.)r?�render)rr<r/s   rrAzNameVirtualHost.renderYs!���+�+�G�4���|�|�G�$�$rc���|j|�}|jr7|jjd|jjd��|S|j
||�S)z6Implementation of resource.Resource's getChild method.r���)r?�isLeaf�postpath�insert�prepath�pop�getChildWithDefault)r�pathr<r/s    r�getChildzNameVirtualHost.getChild^sV���+�+�G�4���<�<����#�#�A�w���':�':�2�'>�?��L��,�,�T�7�;�;r)
r r!r"r#r7r
rrrrr?rArKr&rrr(r('s3��?��G��

�
A�!��

�%�
<rr(c��eZdZd�Zy)�
_HostResourcec��d|vr!|jdd�\}}t|�}n|d}}|j||�d|j�zdzt	|�zt	|j
d�z}ddj
|j�z|_|j|d|_	|j
dd�=|jj|�S)Nr2r3�P������/)r:�int�setHost�isSecure�lenrG�joinrErJ�uri�site�getResourceFor)rrJr<r>�port�	prefixLens      rrKz_HostResource.getChildis����4�<����D�!�,�J�D�$��t�9�D��r�$�D�����d�#���(�(�*�*�Q�.��T��:�S����QS�AT�=U�U�	��d�i�i��(8�(8�9�9����k�k�)�*�-����O�O�B�Q�B���|�|�*�*�7�3�3rN)r r!r"rKr&rrrMrMhs��4rrMc��eZdZdZd�Zy)�VHostMonsterResourcea.
    Use this to be able to record the hostname and method (http vs. https)
    in the URL without disturbing your web site. If you put this resource
    in a URL http://foo.com/bar then requests to
    http://foo.com/bar/http/baz.com/something will be equivalent to
    http://foo.com/something, except that the hostname the request will
    appear to be accessing will be "baz.com". So if "baz.com" is redirecting
    all requests for to foo.com, while foo.com is inaccessible from the outside,
    then redirect and url generation will work correctly
    c�^�|dk(rd�|_t�S|dk(rd�|_t�S)Nshttpc��y)Nrr&r&rr�<lambda>z/VHostMonsterResource.getChild.<locals>.<lambda>���rshttpsc��y)Nr3r&r&rrrbz/VHostMonsterResource.getChild.<locals>.<lambda>�rcr)rVrM)rrJr<s   rrKzVHostMonsterResource.getChild�s5���7�?�(�G������X�
�(�G����rN)r r!r"r#rKr&rrr_r_ws��	�rr_N)r#�twisted.pythonr�twisted.webrr�
Homogenousrr$r(rMr_r&rr�<module>rhs[��
�!�'�"�E�,�,�"�0><�h�'�'�><�B4�H�%�%�4��8�,�,�r