ó
¬tPc           @`  sŠ   d  Z  d d l m Z m Z d d l m Z d d l m Z m Z d „  Z	 d e f d „  ƒ  YZ
 e d e f d	 „  ƒ  Yƒ Z d g Z d
 S(   s2   
An API for storing HTTP header names and values.
i    (   t   divisiont   absolute_import(   t   MutableMapping(   t
   comparablet   cmpc         C`  s/   d j  g  |  j d ƒ D] } | j ƒ  ^ q ƒ S(   s  
    Return a byte string which is capitalized using '-' as a word separator.

    @param name: The name of the header to capitalize.
    @type name: C{bytes}

    @return: The given header capitalized using '-' as a word separator.
    @rtype: C{bytes}
    t   -(   t   joint   splitt
   capitalize(   t   namet   word(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   _dashCapitalize   s    
t   _DictHeadersc           B`  sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s8  
    A C{dict}-like wrapper around L{Headers} to provide backwards compatibility
    for L{twisted.web.http.Request.received_headers} and
    L{twisted.web.http.Request.headers} which used to be plain C{dict}
    instances.

    @type _headers: L{Headers}
    @ivar _headers: The real header storage object.
    c         C`  s   | |  _  d  S(   N(   t   _headers(   t   selft   headers(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __init__(   s    c         C`  s6   |  j  j | ƒ r& |  j  j | ƒ d St | ƒ ‚ d S(   s=   
        Return the last value for header of C{key}.
        iÿÿÿÿN(   R   t	   hasHeadert   getRawHeaderst   KeyError(   R   t   key(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __getitem__,   s    c         C`  s   |  j  j | | g ƒ d S(   s'   
        Set the given header.
        N(   R   t   setRawHeaders(   R   R   t   value(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __setitem__5   s    c         C`  s5   |  j  j | ƒ r% |  j  j | ƒ n t | ƒ ‚ d S(   s*   
        Delete the given header.
        N(   R   R   t   removeHeaderR   (   R   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __delitem__<   s    c         c`  s/   x( |  j  j ƒ  D] \ } } | j ƒ  Vq Wd S(   sR   
        Return an iterator of the lowercase name of each header present.
        N(   R   t   getAllRawHeaderst   lower(   R   t   kt   v(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __iter__F   s    c         C`  s   t  |  j j ƒ S(   s@   
        Return the number of distinct headers present.
        (   t   lenR   t   _rawHeaders(   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __len__N   s    c         C`  s   t  |  j ƒ  ƒ S(   sk   
        Return a C{dict} mapping each header name to the last corresponding
        header value.
        (   t   dictt   items(   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   copyW   s    c         C`  s
   | |  k S(   sf   
        Return C{True} if C{key} is a header in this collection, C{False}
        otherwise.
        (    (   R   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   has_key_   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R"   R%   R&   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR      s   						
				t   Headersc           B`  s®   e  Z d  Z i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d d „ Z d „  Z d „  Z RS(   s‡  
    This class stores the HTTP headers as both a parsed representation
    and the raw string representation. It converts between the two on
    demand.

    @cvar _caseMappings: A C{dict} that maps lowercase header names
        to their canonicalized representation.

    @ivar _rawHeaders: A C{dict} mapping header names as C{bytes} to C{lists} of
        header values as C{bytes}.
    s   Content-MD5s   content-md5t   DNTt   dntt   ETagt   etagt   P3Pt   p3pt   TEt   tes   WWW-Authenticates   www-authenticates   X-XSS-Protections   x-xss-protectionc         C`  sJ   i  |  _  | d  k	 rF x. | j ƒ  D] \ } } |  j | | ƒ q" Wn  d  S(   N(   R!   t   NoneR$   R   (   R   t
   rawHeadersR	   t   values(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR   ~   s    	c         C`  s   d |  j  j |  j f S(   sR   
        Return a string fully describing the headers set on this object.
        s   %s(%r)(   t	   __class__R'   R!   (   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __repr__…   s    c         C`  s>   t  | t ƒ r: t t |  j j ƒ  ƒ t | j j ƒ  ƒ ƒ St S(   su   
        Define L{Headers} instances as being equal to each other if they have
        the same raw headers.
        (   t
   isinstanceR*   R   t   sortedR!   R$   t   NotImplemented(   R   t   other(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   __cmp__Œ   s
    c         C`  s   |  j  |  j ƒ S(   sD   
        Return a copy of itself with the same headers set.
        (   R6   R!   (   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR%   ˜   s    c         C`  s   | j  ƒ  |  j k S(   sõ   
        Check for the existence of a given header.

        @type name: C{bytes}
        @param name: The name of the HTTP header to check for.

        @rtype: C{bool}
        @return: C{True} if the header exists, otherwise C{False}.
        (   R   R!   (   R   R	   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR   Ÿ   s    
c         C`  s   |  j  j | j ƒ  d ƒ d S(   s¶   
        Remove the named header from this header object.

        @type name: C{bytes}
        @param name: The name of the HTTP header to remove.

        @return: C{None}
        N(   R!   t   popR   R3   (   R   R	   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR   ¬   s    	c         C`  sE   t  | t ƒ s. t d | t | ƒ f ƒ ‚ n  | |  j | j ƒ  <d S(   sG  
        Sets the raw representation of the given header.

        @type name: C{bytes}
        @param name: The name of the HTTP header to set the values for.

        @type values: C{list}
        @param values: A list of strings each one being a header value of
            the given name.

        @return: C{None}
        s?   Header entry %r should be list but found instance of %r insteadN(   R8   t   listt	   TypeErrort   typeR!   R   (   R   R	   R5   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR   ¸   s    c         C`  sB   |  j  | ƒ } | d k r1 |  j | | g ƒ n | j | ƒ d S(   sý   
        Add a new raw value for the given header.

        @type name: C{bytes}
        @param name: The name of the header for which to set the value.

        @type value: C{bytes}
        @param value: The value to set for the named header.
        N(   R   R3   R   t   append(   R   R	   R   R5   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   addRawHeaderË   s    
c         C`  s   |  j  j | j ƒ  | ƒ S(   s‚  
        Returns a list of headers matching the given name as the raw string
        given.

        @type name: C{bytes}
        @param name: The name of the HTTP header to get the values of.

        @param default: The value to return if no header with the given C{name}
            exists.

        @rtype: C{list}
        @return: A C{list} of values for the given header.
        (   R!   t   getR   (   R   R	   t   default(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR   Ü   s    c         c`  s8   x1 |  j  j ƒ  D]  \ } } |  j | ƒ | f Vq Wd S(   s´   
        Return an iterator of key, value pairs of all headers contained in this
        object, as strings.  The keys are capitalized in canonical
        capitalization.
        N(   R!   R$   t   _canonicalNameCaps(   R   R   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR   í   s    c         C`  s   |  j  j | t | ƒ ƒ S(   s  
        Return the canonical name for the given header.

        @type name: C{bytes}
        @param name: The all-lowercase header name to capitalize in its
            canonical form.

        @rtype: C{bytes}
        @return: The canonical name of the header.
        (   t   _caseMappingsRC   R   (   R   R	   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyRE   ÷   s    N(   R'   R(   R)   RF   R3   R   R7   R<   R%   R   R   R   RB   R   R   RE   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyR*   h   s(   
								
N(   R)   t
   __future__R    R   t   collectionsR   t   twisted.python.compatR   R   R   R   t   objectR*   t   __all__(    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/web/http_headers.pyt   <module>   s   	Jœ