ϪfGdZddlmZddlmZmZGddej ZGddejZ Gdd ejZ Gd d ejZ y ) z& I am a virtual hosts implementation. )roots)pagesresourcecFeZdZdZej ZdZdZdZ dZ dZ y)VirtualHostCollectionzWWrapper for virtual hosts collection. This exists for configuration purposes. c||_yN)nvh)selfr s 3/usr/lib/python3/dist-packages/twisted/web/vhost.py__init__zVirtualHostCollection.__init__s cJ|jjjSr )r hostsitemsr s r listStaticEntitiesz(VirtualHostCollection.listStaticEntitiessxx~~##%%rcL|jjj|Sr )r rgetr names r getStaticEntityz%VirtualHostCollection.getStaticEntitysxx~~!!$''rc<|jj||yr )r addHost)r rentitys r reallyPutEntityz%VirtualHostCollection.reallyPutEntity s v&rc:|jj|yr )r removeHostrs r delEntityzVirtualHostCollection.delEntity#s D!rN) __name__ __module__ __qualname____doc__rResource entityTyper rrrrrr rrs- ""J&('"rrcDeZdZdZdZdZdZdZdZdZ dZ d Z d Z y) NameVirtualHostz5I am a resource which represents named virtual hosts.NcPtjj|i|_y)z Initialize.N)rr$r rrs r r zNameVirtualHost.__init__,s""4( rc^tjj|dt|fgzSNz Virtual Hosts)rr$rrrs r rz"NameVirtualHost.listStaticEntities1s3  33D9 3D9 :=   rcb|dk(r t|Stjj||Sr+)rrr$rrs r rzNameVirtualHost.getStaticEntity6s. ? "(. .$$44T4@ @rc"||j|<y)aAdd 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) Nr)r rresrcs r rzNameVirtualHost.addHost<s! 4rc|j|=y)zRemove a host.Nr.rs r rzNameVirtualHost.removeHostIs JJt rcV|jd}|"|jxstjS|j j ddd}|j j||jxs*tjdd|jddd S) z;(Internal) Get the appropriate resource for the given host.shost:rz Not Foundzhost asciireplacez not in vhost map) getHeaderdefaultrnotFoundlowersplitrrdecode)r request hostHeaderhosts r _getResourceForRequestz&NameVirtualHost._getResourceForRequestMs&&w/  <<35>>#3 3##%++D!4Q7Dzz~~dDLL1 U^^ DKK366G H6  rcF|j|}|j|S)z4Implementation of resource.Resource's render method.)r?render)r r<r/s r rAzNameVirtualHost.renderYs!++G4||G$$rc|j|}|jr7|jjd|jj d|S|j ||S)z6Implementation of resource.Resource's getChild method.r)r?isLeafpostpathinsertprepathpopgetChildWithDefault)r pathr<r/s r getChildzNameVirtualHost.getChild^sV++G4 <<    # #Aw':':2'> ?L,,T7; ;r) r r!r"r#r7r rrrrr?rArKr&rr r(r('s3?G  A !  % port prefixLens r rKz_HostResource.getChildis 4<D!,JD$t9Dr$Dd#((**Q.T:SQSAT=UU dii(8(899 kk)*- OOBQB ||**733rN)r r!r"rKr&rr rMrMhs 4rrMceZdZdZdZy)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|_tS|dk(rd|_tS)Nshttpcy)Nrr&r&rr z/VHostMonsterResource.getChild..rshttpscy)Nr3r&r&rr rbz/VHostMonsterResource.getChild..rcr)rVrM)r rJr<s r rKzVHostMonsterResource.getChilds5 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 rhs[  !'"E,,"0>