Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/web/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/web/__pycache__/vhost.cpython-37.pyc

B

;��]o�@sxdZddlmZmZddlmZddlmZGdd�dej�Z	Gdd�dej
�ZGd	d
�d
ej
�ZGdd�dej
�Z
d
S)z&
I am a virtual hosts implementation.
�)�division�absolute_import)�roots)�resourcec@s>eZdZdZejZdd�Zdd�Zdd�Z	dd	�Z
d
d�ZdS)
�VirtualHostCollectionzWWrapper for virtual hosts collection.

    This exists for configuration purposes.
    cCs
||_dS)N)�nvh)�selfr�r	�D/opt/alt/python37/lib64/python3.7/site-packages/twisted/web/vhost.py�__init__szVirtualHostCollection.__init__cCs|jj��S)N)r�hosts�items)rr	r	r
�listStaticEntitiessz(VirtualHostCollection.listStaticEntitiescCs|jj�|�S)N)rr�get)r�namer	r	r
�getStaticEntitysz%VirtualHostCollection.getStaticEntitycCs|j�||�dS)N)r�addHost)rr�entityr	r	r
�reallyPutEntity sz%VirtualHostCollection.reallyPutEntitycCs|j�|�dS)N)r�
removeHost)rrr	r	r
�	delEntity#szVirtualHostCollection.delEntityN)�__name__�
__module__�__qualname__�__doc__r�ResourceZ
entityTyperrrrrr	r	r	r
rsrc@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�NameVirtualHostz:I am a resource which represents named virtual hosts.
    NcCstj�|�i|_dS)zInitialize.
        N)rrrr)rr	r	r
r-szNameVirtualHost.__init__cCstj�|�dt|�fgS)Nz
Virtual Hosts)rrrr)rr	r	r
r3sz"NameVirtualHost.listStaticEntitiescCs"|dkrt|�Stj�||�SdS)Nz
Virtual Hosts)rrrr)rrr	r	r
r6szNameVirtualHost.getStaticEntitycCs||j|<dS)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�resrcr	r	r
r<szNameVirtualHost.addHostcCs|j|=dS)zRemove a host.N)r)rrr	r	r
rIszNameVirtualHost.removeHostcCsV|�d�}|dkr |jpt��S|���dd�d}|j�||j�pTt�dt|��S)zD(Internal) Get the appropriate resource for the given host.
        shostN�:�rzhost %s not in vhost map)	Z	getHeader�defaultrZ
NoResource�lower�splitrr�repr)r�requestZ
hostHeader�hostr	r	r
�_getResourceForRequestMs
z&NameVirtualHost._getResourceForRequestcCs|�|�}|�|�S)z=Implementation of resource.Resource's render method.
        )r&�render)rr$rr	r	r
r'Xs
zNameVirtualHost.rendercCs:|�|�}|jr*|j�d|j�d��|S|�||�SdS)z?Implementation of resource.Resource's getChild method.
        r���N)r&ZisLeaf�postpath�insert�prepath�popZgetChildWithDefault)r�pathr$rr	r	r
�getChild^s

zNameVirtualHost.getChild)
rrrrr rrrrrr&r'r.r	r	r	r
r's
rc@seZdZdd�ZdS)�
_HostResourcecCs�d|kr"|�dd�\}}t|�}n
|d}}|�||�d|��dt|�t|jd�}dd�|j�|_|j	|d�|_	|jdd�=|j
�|�S)Nrr�P������/)r"�intZsetHost�isSecure�lenr+�joinr)r-Zuri�siteZgetResourceFor)rr-r$r%�portZ	prefixLenr	r	r
r.js

z_HostResource.getChildN)rrrr.r	r	r	r
r/hsr/c@seZdZdZdd�ZdS)�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
    cCs,|dkrdd�|_n|dkr&dd�|_t�S)NshttpcSsdS)Nrr	r	r	r	r
�<lambda>��z/VHostMonsterResource.getChild.<locals>.<lambda>shttpscSsdS)Nrr	r	r	r	r
r<�r=)r6r/)rr-r$r	r	r
r.�s

zVHostMonsterResource.getChildN)rrrrr.r	r	r	r
r;ysr;N)r�
__future__rrZtwisted.pythonrZtwisted.webrZ
Homogenousrrrr/r;r	r	r	r
�<module>sA