
mNc           @   sx  d  d l  m Z d Z d Z d d d d d d	 d
 g Z d Z d Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z	 d  d l Z	 d  d l Z	 d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z y d  d l m Z m Z Wn; e k
 rrd  d l Z d  d l Z e j  Z e j  Z n Xd  d l! Z! d  d l" m" Z# d  d l$ Z$ y d  d l% m& Z& Wn e k
 re' Z& n Xy" d  d l( Z( e( j) Z* d   Z+ Wn& e, e f k
 re' Z* d   Z+ n Xe j- d d f k r<d  d l. m. Z. n	 d   Z. d   Z/ d d d d d d d d d  d! d" g Z0 d# Z1 e j- d d$ f k  rd%   Z2 n  d&   Z3 e4 e j5 d'  re3 e j5 _6 n  d e7 f d(     YZ8 d) e8 f d*     YZ9 d e9 f d+     YZ: d e9 f d,     YZ; d e9 f d-     YZ< d e9 f d.     YZ= d  e9 f d/     YZ> d0 e8 f d1     YZ? d2 e8 f d3     YZ@ d4 e8 f d5     YZA d" e8 f d6     YZB d7 e8 f d8     YZC d9 e8 f d:     YZD d; eD f d<     YZE d= ZF e jG jH e jG jI e jG jJ eK   d>  ZL d? d@ dA dB dC dD dE dF g ZM dG   ZN e jO dH  ZP dI   ZQ dJ   ZR e jO dK  ZS e jO dL  ZT dM   ZU e jO dN  ZV dO   ZW dP   ZX d# ZY e jO dQ  ZZ e jO dR  Z[ e jO dS  Z\ dT dU  Z] dV   Z^ dW   Z_ dX   Z` dY   Za dZ   Zb d[ ec f d\     YZd d] ed f d^     YZe d_ ed f d`     YZf da ed f db     YZg dc ed f dd     YZh de ed f df     YZi i ee dg 6eh dh 6ef di 6eg dj 6ei dk 6Zj dj dk di dh dg g Zk dl ec f dm     YZl dn ec f do     YZm dp em f dq     YZn d ec f dr     YZo ds e jp f dt     YZq du e jr f dv     YZs i eq dw 6es dx 6Zt y d  dy lu mv Zv d  dz lu mw Zw d  d{ lu mx Zx d  d| lu my Zy d  d} lu mz Zz d~ e{ f d     YZ| d ec f d     YZ} d e} f d     YZ~ i e} dw 6e~ dx 6Zt Wn e k
 rGn Xd ec f d     YZ d e{ f d     YZ d S(   i(   t
   generatorss!   Joe Gregorio (joe@bitworking.org)s   Copyright 2006, Joe Gregorios!   Thomas Broyer (t.broyer@ltgt.net)s   James Antills   Xavier Verges Farreros   Jonathan Feinbergs   Blair Zajacs   Sam Rubys   Louis Nyffeneggert   MITs   0.7.0N(   t   sha1t   md5(   t   gettext(   t   socksc      
   C   s@   | r t  j } n	 t  j } t  j |  d | d | d | d | S(   Nt   keyfilet   certfilet	   cert_reqst   ca_certs(   t   sslt	   CERT_NONEt   CERT_REQUIREDt   wrap_socket(   t   sockt   key_filet	   cert_filet   disable_validationR	   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _ssl_wrap_socketB   s
    	c         C   s:   | s t  d   n  t j |  | |  } t j |  |  S(   Ns   SSL certificate validation is not supported without the ssl module installed. To avoid this error, install the ssl module, or explicity disable validation.(   t    CertificateValidationUnsupportedt   socketR
   t   httplibt
   FakeSocket(   R   R   R   R   R	   t   ssl_sock(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR   O   s
    i   i   (   t   iri2uric         C   s   |  S(   N(    (   t   uri(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR   ]   s    c         C   s2   t  t d  r( |  d  k	 o' |  t j k	 S|  d  k	 S(   Nt   _GLOBAL_DEFAULT_TIMEOUT(   t   hasattrR   t   NoneR   (   t   timeout(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   has_timeout`   s    t   Httpt   Responset	   ProxyInfot   HttpLib2Errort   RedirectMissingLocationt   RedirectLimitt   FailedToDecompressContentt"   UnimplementedDigestAuthOptionErrort&   UnimplementedHmacDigestAuthOptionErrort
   debuglevelt   ProxiesUnavailableErrori    i   c         C   s   |  j    |  S(   N(   t   sort(   t   seq(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   sortedq   s    
c         C   s+   |  j  d k r t j    n  |  j  j   S(   s&   Return list of (header, value) tuples.N(   t   msgR   R   t   ResponseNotReadyt   items(   t   self(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   HTTPResponse__getheadersv   s    t
   getheadersc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR"      s    t   HttpLib2ErrorWithResponsec           B   s   e  Z d    Z RS(   c         C   s&   | |  _  | |  _ t j |  |  d  S(   N(   t   responset   contentR"   t   __init__(   R0   t   descR6   R7   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8      s    		(   R3   R4   R8   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR5      s   c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR#      s    c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR$      s    c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR%      s    c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR&      s    c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR'      s    t   MalformedHeaderc           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR:      s    t   RelativeURIErrorc           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR;      s    t   ServerNotFoundErrorc           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR<      s    c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR)      s    R   c           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR      s    t   SSLHandshakeErrorc           B   s   e  Z RS(    (   R3   R4   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR=      s    t   CertificateHostnameMismatchc           B   s   e  Z d    Z RS(   c         C   s&   t  j |  |  | |  _ | |  _ d  S(   N(   R"   R8   t   hostt   cert(   R0   R9   R?   R@   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8      s    	(   R3   R4   R8   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR>      s   i   s   cacerts.txtt
   connections
   keep-alives   proxy-authenticates   proxy-authorizationt   tet   trailerss   transfer-encodingt   upgradec         C   sp   t  t  } | j g  |  j d d  j d  D] } | j   ^ q.  g  |  j   D] } | | k rT | ^ qT S(   NRA   t    t   ,(   t   listt
   HOP_BY_HOPt   extendt   gett   splitt   stript   keys(   R6   t   hopbyhopt   xt   header(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _get_end2end_headers   s    ;s9   ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?c         C   s<   t  j |   j   } | d | d | d | d | d f S(   s   Parses a URI using the regex given in Appendix B of RFC 3986.

        (scheme, authority, path, query, fragment) = parse_uri(uri)
    i   i   i   i   i   (   t   URIt   matcht   groups(   R   RT   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt	   parse_uri   s    c         C   s   t  |   \ } } } } } | s) | r< t d |    n  | j   } | j   } | sc d } n  | r~ d j | | g  p | } | j   } | d | | } | | | | f S(   Ns(   Only absolute URIs are allowed. uri = %st   /t   ?s   ://(   RU   R;   t   lowert   join(   R   t   schemet	   authorityt   patht   queryt   fragmentt   request_urit
   defrag_uri(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   urlnorm   s    	!s   ^\w+://s   [?/:|]+c         C   s   yU t  j |   rT t |  t  rB |  j d  }  |  j d  }  qT |  j d  }  n  Wn t k
 rh n Xt |  t  r |  j d  }  n  t |   j	   } t  j
 d |   }  t j
 d |   }  t |   d k r |  d  }  n  d j |  | f  S(   s   Return a filename suitable for the cache.

    Strips dangerous and common characters to create a filename we
    can use to store the cache in.
    s   utf-8t   idnaRE   RF   i   (   t   re_url_schemeRS   t
   isinstancet   strt   decodet   encodet   UnicodeErrort   unicodet   _md5t	   hexdigestt   subt   re_slasht   lenRY   (   t   filenamet   filemd5(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   safename   s     s   (?:\r\n)?[ \t]+c         C   sG   t  g  |  j   D]0 \ } } | j   t j | d  j   f ^ q  S(   Nt    (   t   dictt	   iteritemsRX   t   NORMALIZE_SPACERl   RL   (   t   headerst   keyt   value(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _normalize_headers   s    c         C   s   i  } |  j  d  r |  d j d  } g  | D]R } d | j d  k r/ t g  | j d d  D] } | j   j   ^ q`  ^ q/ } g  | D]3 } d | j d  k r | j   j   d f ^ q } t | |  } n  | S(   Ns   cache-controlRF   it   =i   (   t   has_keyRK   t   findt   tupleRL   RX   Rs   (   Rv   t   retvalt   partst   partRO   t   parts_with_argst   namet   parts_wo_args(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _parse_cache_control   s    _@s   ^(?:\s*(?:,\s*)?([^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+)\s*=\s*\"?((?<=\")(?:[^\0-\x08\x0A-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?(?=\")|(?<!\")[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+(?!\"))\"?)(.*)$sk   ^(?:\s*(?:,\s*)?([^ \t\r\n=]+)\s*=\s*\"?((?<=\")(?:[^\\\"]|\\.)*?(?=\")|(?<!\")[^ \t\r\n,]+(?!\"))\"?)(.*)$s   \\(.)s   www-authenticatec         C   sB  i  } |  j  |  r>y|  | j   } t r4 t p7 t } x | r| d k r_ d | } } n | j d d  \ } } | j |  } i  } xk | r | r t | j    d k r | j   \ }	 }
 } t	 j
 d |
  | |	 j   <n  | j |  } q W| | | j   <| j   } q= WWq>t k
 r:t d   q>Xn  | S(   sC   Returns a dictionary of dictionaries, one dict
    per auth_scheme.s   authentication-infot   digestRr   i   i   s   \1s   WWW-Authenticate(   R{   RL   t   USE_WWW_AUTH_STRICT_PARSINGt   WWW_AUTH_STRICTt   WWW_AUTH_RELAXEDRK   t   searchRn   RT   t   UNQUOTE_PAIRSRl   RX   t
   ValueErrorR:   (   Rv   t
   headernameR~   t   authenticatet   www_autht   auth_schemet   the_restRS   t   auth_paramsRw   Rx   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _parse_www_authenticate  s*    		c         C   sH  d } t  |  } t  |   } | j d  rn | d j   j d  d k rn d } d | k rDd | d <qDn| j d  r d } n| j d  r d } n| j d  r d } n|  j d	  rDt j t j j |  d	   } t	 j	   } t
 d
 | |  } | j d  rCy t | d  } Wqt k
 r?d
 } qXn_ |  j d  rt j j |  d  }	 d |	 k r}d
 } qt
 d
 t j |	  |  } n d
 } | j d  ry t | d  } Wqt k
 rd
 } qXn  | j d  r,y t | d  }
 Wn t k
 rd
 }
 n X| |
 7} n  | | k rDd } qDn  | S(   s  Determine freshness from the Date, Expires and Cache-Control headers.

    We don't handle the following:

    1. Cache-Control: max-stale
    2. Age: headers are not used in the calculations.

    Not that this algorithm is simpler than you might think
    because we are operating as a private (non-shared) cache.
    This lets us ignore 's-maxage'. We can also ignore
    'proxy-invalidate' since we aren't a proxy.
    We will never return a stale document as
    fresh as a design decision, and thus the non-implementation
    of 'max-stale'. This also lets us safely ignore 'must-revalidate'
    since we operate as if every server has sent 'must-revalidate'.
    Since we are private we get to ignore both 'public' and
    'private' parameters. We also ignore 'no-transform' since
    we don't do any transformations.
    The 'no-store' parameter is handled at a higher level.
    So the only Cache-Control parameters we look at are:

    no-cache
    only-if-cached
    max-age
    min-fresh
    t   STALEt   pragmas   no-cacheit   TRANSPARENTs   cache-controls   only-if-cachedt   FRESHt   datei    s   max-aget   expiress	   min-freshN(   R   R{   RX   R|   t   calendart   timegmt   emailt   Utilst   parsedate_tzt   timet   maxt   intR   R   (   t   response_headerst   request_headersR~   t   cct   cc_responseR   t   nowt   current_aget   freshness_lifetimeR   t	   min_fresh(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _entry_disposition0  sT    .				
c         C   s   | } y |  j  d d   } | d	 k r | d k rW t j d t j |   j   } n  | d k ru t j |  } n  t t	 |   |  d <|  d |  d <|  d =n  Wn< t
 k
 r d } t t d  |  j  d  |  |   n X| S(
   Ns   content-encodingt   gzipt   deflatet   fileobjs   content-lengths   -content-encodingRE   sD   Content purported to be compressed with %s but failed to decompress.(   s   gzipR   (   RJ   R   R   t   GzipFilet   StringIOt   readt   zlibt
   decompressRe   Rn   t   IOErrorR%   t   _(   R6   t   new_contentR7   t   encoding(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _decompressContentz  s    $)c         C   s  | rt  |   } t  |  } | j d  s< | j d  rL | j |  qt j j   } x3 | j   D]% \ } }	 | d k rh |	 | | <qh qh W| j d d   }
 |
 r|
 j   j	 d d  j
 d  } xA | D]6 } d	 | } y |  | | | <Wq t k
 rq Xq Wn  | j } | d
 k r,d } n  d | } | j   } t j d d |  } d j | | | g  } | j | |  n  d  S(   Ns   no-storet   statuss   content-encodings   transfer-encodingt   varyRr   RE   RF   s
   -varied-%si0  i   s   status: %d
s   (?!
)|(?<!)
s   
(   s   statuss   content-encodings   transfer-encoding(   R   R{   t   deleteR   t   MessageRt   RJ   R   RX   t   replaceRK   t   KeyErrorR   t	   as_stringt   reRl   RY   t   set(   R   R   R7   t   cachet   cachekeyR   R   t   infoRw   Rx   R   t   vary_headersRP   R   t   status_headert
   header_strt   text(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _updateCache  s4    !
		
c       	   C   sS   t  d t j   g  t d  D] }  d t j d d  ^ q f  j   } | d  S(   Ns   %s:%si   t
   0123456789i    i	   i   (   Rj   R   t   ctimet   ranget   randomt	   randrangeRk   (   t   it   dig(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _cnonce  s    Kc         C   s,   t  j t d |  | | f  j    j   S(   Ns   %s%s%s(   t   base64t	   b64encodet   _shaR   RL   (   t   cnoncet   iso_nowt   password(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _wsse_username_token  s    t   Authenticationc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   sC   t  |  \ } }	 }
 } } |
 |  _ | |  _ | |  _ | |  _ d  S(   N(   RU   R\   R?   t   credentialst   http(   R0   R   R?   R_   Rv   R6   R7   R   RZ   R[   R\   R]   R^   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s
    			c         C   s5   t  |  \ } } } } } | t |  j  j d  S(   NRV   (   RU   Rn   R\   t   count(   R0   R_   RZ   R[   R\   R]   R^   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   depth  s    c         C   s:   t  |  \ } } } } } | |  j k o9 | j |  j  S(   N(   RU   R?   t
   startswithR\   (   R0   R?   R_   RZ   R[   R\   R]   R^   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   inscope  s    c         C   s   d S(   sn   Modify the request headers to add the appropriate
        Authorization header. Over-rise this in sub-classes.N(    (   R0   t   methodR_   Rv   R7   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   request  s    c         C   s   t  S(   s  Gives us a chance to update with new nonces
        or such returned from the last authorized response.
        Over-rise this in sub-classes if necessary.

        Return TRUE is the request is to be retried, for
        example Digest may return stale=true.
        (   t   False(   R0   R6   R7   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR6     s    (   R3   R4   R8   R   R   R   R6   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s
   				t   BasicAuthenticationc           B   s   e  Z d    Z d   Z RS(   c      	   C   s&   t  j |  | | | | | | |  d  S(   N(   R   R8   (   R0   R   R?   R_   Rv   R6   R7   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    c         C   s(   d t  j d |  j  j   | d <d S(   sO   Modify the request headers to add the appropriate
        Authorization header.s   Basic s   %s:%st   authorizationN(   R   R   R   RL   (   R0   R   R_   Rv   R7   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    (   R3   R4   R8   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s   	t   DigestAuthenticationc           B   s,   e  Z d  Z d   Z d d  Z d   Z RS(   sM   Only do qop='auth' and MD5, since that
    is all Apache currently implementsc      	   C   sY  t  j |  | | | | | | |  t | d  } | d |  _ |  j j d d  }	 d g  |	 j   D] }
 |
 j   ^ qc k r d p d  |  j d <|  j d d  k r t t	 d |	    n  |  j j d d  j
   |  j d <|  j d d k rt t	 d |  j d    n  d	 j |  j d
 d |  j d d |  j d g  |  _ d |  j d <d  S(   Ns   www-authenticateR   t   qopt   auths   Unsupported value for qop: %s.t	   algorithmt   MD5s$   Unsupported value for algorithm: %s.RE   i    t   :t   realmi   t   nc(   R   R8   R   t	   challengeRJ   RK   RL   R   R&   R   t   upperRY   R   t   A1(   R0   R   R?   R_   Rv   R6   R7   R   R   R   RO   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    ">" 6c   	         s  d       f d   } d j  | d | g  } | p< t   |  j d <d |   |  j  d |  j d d	 |  j d
 |  j d |  j d   |  f  } d |  j d |  j d |  j d | |  j d | |  j d |  j d
 |  j d f	 | d <|  j d
 c d 7<d S(   s   Modify the request headersc         S   s   t  |   j   S(   N(   Rj   Rk   (   RO   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   <lambda>   s    c            s     d |  | f  S(   Ns   %s:%s(    (   t   st   d(   t   H(    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    RE   R   R   s   "%s"s   %s:%s:%s:%s:%st   nonces   %08xR   R   so   Digest username="%s", realm="%s", nonce="%s", uri="%s", algorithm=%s, response=%s, qop=%s, nc=%08x, cnonce="%s"i    R   R   R   i   N(   RY   R   R   R   R   (	   R0   R   R_   Rv   R7   R   t   KDt   A2t   request_digest(    (   R   s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s&    	






c         C   s   | j  d  sd t | d  j d i   } d | j d  k r | d |  j d <d |  j d <t SnK t | d  j d i   } | j  d	  r | d	 |  j d <d |  j d <n  t S(
   Ns   authentication-infos   www-authenticateR   t   truet   staleR   i   R   t	   nextnonce(   R{   R   RJ   R   t   TrueR   (   R0   R6   R7   R   t   updated_challenge(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR6     s    N(   R3   R4   t   __doc__R8   R   R   R6   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s   	t   HmacDigestAuthenticationc           B   s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   s@   Adapted from Robert Sayre's code and DigestAuthentication above.s!   Thomas Broyer (t.broyer@ltgt.net)c   	   	   C   s:  t  j |  | | | | | | |  t | d  } | d |  _ |  j j d d  |  j d <|  j d d k r} d |  j d <n  |  j j d d  |  j d <|  j j d  s t t d	    n  |  j j d
 d  |  j d
 <|  j d
 d k rt t d |  j d
    n  |  j j d d  |  j d <|  j d d k r^t t d |  j d    n  |  j d
 d k r}t |  _ n	 t	 |  _ |  j d d k rt |  _
 n	 t	 |  _
 d j |  j d d |  j
 j d j |  j d |  j d g   j   j   d |  j d g  |  _ |  j
 j |  j  j   j   |  _ d  S(   Ns   www-authenticatet
   hmacdigestt   reasont   unauthorizedt	   integrityt   saltRE   t   snoncesC   The challenge doesn't contain a server nonce, or this one is empty.R   s
   HMAC-SHA-1s   HMAC-MD5s$   Unsupported value for algorithm: %s.s   pw-algorithms   SHA-1R   s'   Unsupported value for pw-algorithm: %s.i    R   i   R   (   R   R   (   s
   HMAC-SHA-1s   HMAC-MD5(   s   SHA-1s   MD5(   R   R8   R   R   RJ   R'   R   Rj   t   hashmodR   t	   pwhashmodRY   R   t   newRk   RX   Rw   (	   R0   R   R?   R_   Rv   R6   R7   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8   *  s2    "  		8c      	   C   s   t  |  } d j g  | D] } d | ^ q  } d j g  | D] } | | ^ q?  } t j d t j    }	 t   }
 d | | |
 |  j d | f } t j |  j	 | |  j
  j   j   } d |  j d |  j d |  j d |
 | |	 | | f | d	 <d
 S(   s   Modify the request headersRE   s   %s s   %Y-%m-%dT%H:%M:%SZs   %s:%s:%s:%s:%sR  ss   HMACDigest username="%s", realm="%s", snonce="%s", cnonce="%s", uri="%s", created="%s", response="%s", headers="%s"i    R   R   N(   RQ   RY   R   t   strftimet   gmtimeR   R   t   hmacR  Rw   R  Rk   RX   R   (   R0   R   R_   Rv   R7   RM   t   kt   keylistt   headers_valt   createdR   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR   I  s     &&	 '


c         C   s8   t  | d  j d i   } | j d  d k r4 t St S(   Ns   www-authenticateR   R   R   R   (   s	   integritys   stale(   R   RJ   R   R   (   R0   R6   R7   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR6   ]  s    (   R3   R4   R   t
   __author__R8   R   R6   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR   &  s
   		t   WsseAuthenticationc           B   s    e  Z d  Z d   Z d   Z RS(   s  This is thinly tested and should not be relied upon.
    At this time there isn't any third party server to test against.
    Blogger and TypePad implemented this algorithm at one point
    but Blogger has since switched to Basic over HTTPS and
    TypePad has implemented it wrong, by never issuing a 401
    challenge but instead requiring your client to telepathically know that
    their endpoint is expecting WSSE profile="UsernameToken".c      	   C   s&   t  j |  | | | | | | |  d  S(   N(   R   R8   (   R0   R   R?   R_   Rv   R6   R7   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8   l  s    c         C   si   d | d <t  j d t  j    } t   } t | | |  j d  } d |  j d | | | f | d <d S(	   sO   Modify the request headers to add the appropriate
        Authorization header.s   WSSE profile="UsernameToken"R   s   %Y-%m-%dT%H:%M:%SZi   sJ   UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"i    s   X-WSSEN(   R   R  R  R   R   R   (   R0   R   R_   Rv   R7   R   R   t   password_digest(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR   o  s    
	
(   R3   R4   R   R8   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR  d  s   	t   GoogleLoginAuthenticationc           B   s   e  Z d    Z d   Z RS(   c         C   sW  d d l  m } t j |  | | | | | | |  t | d  }	 |	 d j d d  }
 |
 d k r | j d  d k r d	 }
 n  t d
 | d d | d d |
 d | d  } |  j j	 d d d d | |  d i d d 6\ } } | j
 d  } t g  | D]$ } | r t | j
 d d   ^ q  } | j d k rFd |  _ n | d |  _ d  S(   Ni(   t	   urlencodes   www-authenticatet   googlelogint   servicet   xapiR   i    t   clt   Emailt   Passwdi   t   sources
   user-agents+   https://www.google.com/accounts/ClientLoginR   t   POSTt   bodyRv   s!   application/x-www-form-urlencodeds   Content-Types   
Rz   i  RE   t   Auth(   t   urllibR  R   R8   R   RJ   R|   Rs   R   R   RK   R}   R   R  (   R0   R   R?   R_   Rv   R6   R7   R   R  R   R  R   t   respt   linest   lineR   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8   }  s    "!	-77c         C   s   d |  j  | d <d S(   sO   Modify the request headers to add the appropriate
        Authorization header.s   GoogleLogin Auth=R   N(   R  (   R0   R   R_   Rv   R7   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    (   R3   R4   R8   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR  |  s   	t   basict   wsseR   R   R  t	   FileCachec           B   s5   e  Z d  Z e d  Z d   Z d   Z d   Z RS(   s   Uses a local directory as a store for cached files.
    Not really safe to use if multiple threads or processes are going to
    be running on the same cache.
    c         C   s;   | |  _  | |  _ t j j |  s7 t j |  j   n  d  S(   N(   R   t   safet   osR\   t   existst   makedirs(   R0   R   R#  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    		c         C   sh   d  } t j j |  j |  j |   } y) t | d  } | j   } | j   Wn t	 k
 rc n X| S(   Nt   rb(
   R   R$  R\   RY   R   R#  t   fileR   t   closeR   (   R0   Rw   R~   t   cacheFullPatht   f(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRJ     s    !c         C   sK   t  j j |  j |  j |   } t | d  } | j |  | j   d  S(   Nt   wb(   R$  R\   RY   R   R#  R(  t   writeR)  (   R0   Rw   Rx   R*  R+  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    !c         C   sG   t  j j |  j |  j |   } t  j j |  rC t  j |  n  d  S(   N(   R$  R\   RY   R   R#  R%  t   remove(   R0   Rw   R*  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    !(   R3   R4   R   Rq   R8   RJ   R   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR"    s
   		t   Credentialsc           B   s/   e  Z d    Z d d  Z d   Z d   Z RS(   c         C   s   g  |  _  d  S(   N(   R   (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    RE   c         C   s#   |  j  j | j   | | f  d  S(   N(   R   t   appendRX   (   R0   R   R   t   domain(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   add  s    c         C   s   g  |  _  d  S(   N(   R   (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   clear  s    c         c   sG   x@ |  j  D]5 \ } } } | d k s1 | | k r
 | | f Vq
 q
 Wd  S(   NRE   (   R   (   R0   R1  t   cdomainR   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   iter  s    (   R3   R4   R8   R2  R3  R5  (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR/    s   		t   KeyCertsc           B   s   e  Z d  Z RS(   sN   Identical to Credentials except that
    name/password are mapped to key/cert.(   R3   R4   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR6    s   c           B   s2   e  Z d  Z d d d d  Z d   Z d   Z RS(   s,   Collect information required to use a proxy.c         C   s@   | | | | | | f \ |  _  |  _ |  _ |  _ |  _ |  _ d S(   s   The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
      constants. For example:

p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host='localhost', proxy_port=8000)
      N(   t
   proxy_typet
   proxy_hostt
   proxy_portt
   proxy_rdnst
   proxy_usert
   proxy_pass(   R0   R7  R8  R9  R:  R;  R<  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    c         C   s(   |  j  |  j |  j |  j |  j |  j f S(   N(   R7  R8  R9  R:  R;  R<  (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   astuple  s    c         C   s   |  j  d  k o |  j d  k S(   N(   R8  R   R9  (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   isgood  s    N(   R3   R4   R   R   R8   R=  R>  (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR!     s   	t   HTTPConnectionWithTimeoutc           B   s,   e  Z d  Z d d d d d  Z d   Z RS(   s8  
    HTTPConnection subclass that supports timeouts

    All timeouts are in seconds. If None is passed for timeout then
    Python's default timeout for sockets will be used. See for example
    the docs of socket.setdefaulttimeout():
    http://docs.python.org/library/socket.html#socket.setdefaulttimeout
    c         C   s/   t  j j |  | | |  | |  _ | |  _ d  S(   N(   R   t   HTTPConnectionR8   R   t
   proxy_info(   R0   R?   t   portt   strictR   RA  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    	c         C   s  |  j  r$ t d k r$ t d   n  d } xt j |  j |  j d t j  D]a} | \ } } } } } y |  j  r |  j  j	   r t j
 | | |  |  _ |  j j |  j  j     n4 t j | | |  |  _ |  j j t j t j d  t |  j  r|  j j |  j  n  |  j d k r6d |  j |  j f GHn  |  j j |  Wnb t j k
 r} |  j d k rd G|  j |  j f GHn  |  j r|  j j   n  d |  _ qL n XPqL W|  j st j |  n  d S(   s3   Connect to the host and port specified in __init__.s2   Proxy support missing but proxy use was requested!s!   getaddrinfo returns an empty listi    i   s   connect: (%s, %s)s   connect fail:N(   RA  R   R   R)   R   t   getaddrinfoR?   RB  t   SOCK_STREAMR>  t
   socksocketR   t   setproxyR=  t
   setsockoptt   IPPROTO_TCPt   TCP_NODELAYR   R   t
   settimeoutR(   t   connectt   errorR)  (   R0   R-   t   rest   aft   socktypet   protot	   canonnamet   sa(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRL    s8    			N(   R3   R4   R   R   R8   RL  (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR?    s   t   HTTPSConnectionWithTimeoutc        	   B   sJ   e  Z d  Z d d d d d d d e d  Z d   Z d   Z d   Z RS(   s2  
    This class allows communication via SSL.

    All timeouts are in seconds. If None is passed for timeout then
    Python's default timeout for sockets will be used. See for example
    the docs of socket.setdefaulttimeout():
    http://docs.python.org/library/socket.html#socket.setdefaulttimeout
    c
   
      C   sh   t  j j |  | d | d | d | d | | |  _ | |  _ | d  k rR t } n  | |  _ |	 |  _ d  S(   NRB  R   R   RC  (	   R   t   HTTPSConnectionR8   R   RA  R   t   CA_CERTSR	   t"   disable_ssl_certificate_validation(
   R0   R?   RB  R   R   RC  R   RA  R	   RW  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8   '  s    				c         C   s   d | k rA g  | d D]& } | d j    d k r | d ^ q Sg  | d D]. } | d d j    d k rL | d d ^ qL Sd S(   s   Returns a list of valid host globs for an SSL certificate.

        Args:
          cert: A dictionary representing an SSL certificate.
        Returns:
          list: A list of valid host globs.
        t   subjectAltNamei    t   dnsi   t   subjectt
   commonnameN(   RX   (   R0   R@   RO   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _GetValidHostsForCertH  s
    $c         C   se   |  j  |  } xO | D]G } | j d d  j d d  } t j d | f | t j  r t Sq Wt S(   s  Validates that a given hostname is valid for an SSL certificate.

        Args:
          cert: A dictionary representing an SSL certificate.
          hostname: The hostname to test.
        Returns:
          bool: Whether or not the hostname is valid for this certificate.
        t   .s   \.t   *s   [^.]*s   ^%s$(   R\  R   R   R   t   IR   R   (   R0   R@   t   hostnamet   hostsR?   t   host_re(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _ValidateCertificateHostnameW  s    	c         C   s  d } xt  j |  j |  j d t  j  D]k\ } } } } } yf|  j r |  j j   r t j | | |  } | j	 |  j j
     n. t  j  | | |  } | j t  j t  j d  t |  j  r | j |  j  n  | j |  j |  j f  t | |  j |  j |  j |  j  |  _ |  j d k r=d |  j |  j f GHn  |  j s|  j j   } |  j j d d  d }	 |  j | |	  st d |	 | f |	 |   qn  Wn t k
 r}
 | r| j   n  |  j r|  j j   n  d |  _ |
 j  t! j" k rt# |
   q  n t  j t  j$ f k
 r0  nb t  j% k
 r} |  j d k rid G|  j |  j f GHn  |  j r|  j j   n  d |  _ q( n XPq( W|  j st  j% |  n  d S(	   s(   Connect to a host on a given (SSL) port.s!   getaddrinfo returns an empty listi    i   s   connect: (%s, %s)R   s<   Server presented certificate that does not match host %s: %ss   connect fail:N(&   R   RD  R?   RB  RE  RA  R>  R   RF  RG  R=  RH  RI  RJ  R   R   RK  RL  R   R   R   RW  R	   R   R(   t   getpeercertRK   Rc  R>   t   ssl_SSLErrorR)  R   t   errnoR
   t   SSL_ERROR_SSLR=   t   gaierrorRM  (   R0   R-   t   familyRP  RQ  RR  t   sockaddrR   R@   R`  t   e(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRL  g  sZ    	.	 					N(	   R3   R4   R   R   R   R8   R\  Rc  RL  (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRT    s   				R   t   https(   t   fetch(   t   InvalidURLError(   t   DownloadError(   t   ResponseTooLargeError(   t   SSLCertificateErrort   ResponseDictc           B   s   e  Z d  Z d   Z RS(   sn   Is a dictionary that also has a read() method, so
    that it can pass itself off as an httlib.HTTPResponse().c         C   s   d  S(   N(    (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    (   R3   R4   R   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRr    s   t   AppEngineHttpConnectionc        	   B   s\   e  Z d  Z d d d d d d d e d  Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   s  Emulates an httplib.HTTPConnection object, but actually uses the Google
    App Engine urlfetch library. This allows the timeout to be properly used on
    Google App Engine, and avoids using httplib, which on Google App Engine is
    just another wrapper around urlfetch.
    c
   
      C   sh   | |  _  | |  _ | |  _ | s3 | s3 | s3 | r? t    n  d  |  _ d |  _ |	 |  _ t |  _	 d  S(   NR   (
   R?   RB  R   t   NotSupportedOnThisPlatformR   R6   RZ   t   validate_certificateR   R   (
   R0   R?   RB  R   R   RC  R   RA  R	   t   disable_certificate_validation(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    					
c            s  |  j  } |  j r+ d |  j  |  j f } n  d |  j | | f } y~ t | d | d | d | d t d t d |  j d	 |  j   t   j  |  _	   j
 |  j	 d
 <t |  j	 d   f d    WnE t k
 r t j d   n& t t t f k
 rt j    n Xd  S(   Ns   %s:%ss	   %s://%s%st   payloadR   Rv   t   allow_truncatedt   follow_redirectst   deadlineRu  R   R   c              s     j  S(   N(   R7   (    (   R6   (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s    RE   (   R?   RB  RZ   Rm  R   R   Ru  Rr  Rv   R6   t   status_codet   setattrRn  R   Rh  Ro  Rp  Rq  R   t   HTTPException(   R0   R   t   urlR  Rv   t   netloct   absolute_uri(    (   R6   s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s     			 c         C   s   |  j  S(   N(   R6   (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   getresponse  s    c         C   s   d  S(   N(    (   R0   t   level(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   set_debuglevel  s    c         C   s   d  S(   N(    (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRL    s    c         C   s   d  S(   N(    (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR)    s    N(   R3   R4   R   R   R   R8   R   R  R  RL  R)  (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs    s   					t   AppEngineHttpsConnectionc           B   s)   e  Z d  Z d d d d d d d  Z RS(   s4   Same as AppEngineHttpConnection, but for HTTPS URIs.c      	   C   s/   t  j |  | | | | | | |  d |  _ d  S(   NRl  (   Rs  R8   RZ   (   R0   R?   RB  R   R   RC  R   RA  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    N(   R3   R4   R   R   R8   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR    s   	c           B   s   e  Z d  Z d d d d e d  Z d   Z d d  Z d   Z d   Z	 d   Z
 d   Z d	   Z d
 d d e d d  Z RS(   s{   An HTTP client that handles:
- all methods
- caching
- ETags
- compression,
- HTTPS
- Basic
- Digest
- WSSE

and more.
    c         C   s   | |  _  | |  _ | |  _ i  |  _ | rK t | t  rK t |  |  _ n	 | |  _ t   |  _	 t
   |  _ g  |  _ t |  _ d d g |  _ t |  _ t |  _ t |  _ | |  _ d S(   s+  
        The value of proxy_info is a ProxyInfo instance.

        If 'cache' is a string then it is used as a directory name for
        a disk cache. Otherwise it must be an object that supports the
        same interface as FileCache.

        All timeouts are in seconds. If None is passed for timeout
        then Python's default timeout for sockets will be used. See
        for example the docs of socket.setdefaulttimeout():
        http://docs.python.org/library/socket.html#socket.setdefaulttimeout

        ca_certs is the path of a file containing root CA certificates for SSL
        server certificate validation.  By default, a CA cert file bundled with
        httplib2 is used.

        If disable_ssl_certificate_validation is true, SSL cert validation will
        not be performed.
        t   PUTt   PATCHN(   RA  R	   RW  t   connectionsRd   t
   basestringR"  R   R/  R   R6  t   certificatest   authorizationsR   Ry  t   optimistic_concurrency_methodsR   t   follow_all_redirectst   ignore_etagt   force_exception_to_status_codeR   (   R0   R   R   RA  R	   RW  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s     										c   	   
   c   st   t  | d  } x^ |  j j |  D]J } xA t D]9 } | j |  r/ t | | | | | | | |   Vq/ q/ Wq" Wd S(   sc   A generator that creates Authorization objects
           that can be applied to requests.
        s   www-authenticateN(   R   R   R5  t   AUTH_SCHEME_ORDERR{   t   AUTH_SCHEME_CLASSES(	   R0   R?   R_   Rv   R6   R7   t
   challengest   credRZ   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _auth_from_challengeE  s
    RE   c         C   s   |  j  j | | |  d S(   s]   Add a name and password that will be used
        any time a request requires authentication.N(   R   R2  (   R0   R   R   R1  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   add_credentialsO  s    c         C   s   |  j  j | | |  d S(   sX   Add a key and cert that will be used
        any time a request requires authentication.N(   R  R2  (   R0   Rw   R@   R1  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   add_certificateT  s    c         C   s   |  j  j   g  |  _ d S(   sK   Remove all the names and passwords
        that are used for authenticationN(   R   R3  R  (   R0   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   clear_credentialsY  s    c         C   sI  x<t  d  D].} y6 | j d  k r2 | j   n  | j | | | |  Wn@t j k
 rb   n*t j k
 r | j   t	 d | j
   n t k
 r | j     n t j k
 r} d } t | d  r t | d  d } n	 | j } | t j k r  qn t j k
 r| j d  k rb| d k rR| j   | j   q qb| j     n  | d k r| j   | j   q qn Xy | j   }	 WnF t j t j f k
 r| d k r| j   | j   q q:  nV Xd }
 | d k r|	 j   n |	 j   }
 t |	  }	 | d k r:t |	 |
  }
 n  Pq W|	 |
 f S(   Ni   s   Unable to find the server at %si    t   argsRE   t   HEAD(   R   R   R   RL  R   R   R   Rh  R)  R<   R?   Re  RM  R   t   getattrRf  t   ECONNREFUSEDR   R}  R  R   R    R   (   R0   t   connR_   R   R  Rv   R   Rk  t   errR6   R7   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _conn_request_  sd    

		






c
         C   s"  g  |  j  D]- }
 |
 j | |  r
 |
 j |  |
 f ^ q
 } | rW t |  d d pZ d }
 |
 r| |
 j | | | |  n  |  j | | | | |  \ } } |
 r |
 j | |  r |
 j | | | |  |  j | | | | |  \ } } d | _ q n  | j	 d k rx |  j
 | | | | |  D]p } | j | | | |  |  j | | | | |  \ } } | j	 d k r&|  j  j |  | j | |  Pq&q&Wn  |  j s| d k s| j	 d k r|  j r| j	 d k r| r| j d  r| j	 d k rt t d  | |   n  | j d  ru| d } t |  \ } } } } } | d k rut j | |  | d <qun  | j	 d k r| d k r| d | d <| j d  s| | d <n  t | | | |  j |	  n  | j d  r| d =n  | j d  r| d =n  | j d  r| d } t j |  } | j d  sL| | d <n  | } | j	 d k rpd } d } n  |  j | | d | d | d | d \ } } | | _ qqt d | |   q| j	 d k r| d k r| j d  s| | d <n  t | | | |  j |	  qn  | | f S(   sm   Do the actual request using the connection object
        and also follow one level of redirects if necessaryi    i   i  t   GETR  i/  i,  i-  i.  i3  t   locations:   Redirected but the response is missing a Location: header.s   -x-permanent-redirect-urls   content-locations   if-none-matchs   if-modified-sinceR  Rv   t   redirectionss3   Redirected more times than rediection_limit allows.i   i   N(   R  s   HEAD(   i,  i-  i.  i/  i3  (   R  s   HEAD(   i.  i/  (   i   i   (   R  s   HEAD(   R  R   R   R,   R   R   R  R6   t   _stale_digestR   R  R0  R  Ry  R{   R#   R   RU   t   urlparset   urljoinR   R   t   copyt   deepcopyt   previousR$   (   R0   R  R?   R  R_   R   R  Rv   R  R   R   t   authsR6   R7   R   R  RZ   R[   R\   R]   R^   t   old_responset   redirect_method(    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   _request  sl    = !!"!$



	.c         C   s
   t  |  S(   N(   Ry   (   R0   Rv   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyRy     s    R  c         C   s  y| d5 k r i  } n |  j |  } | j d  sG d t | d <n  t |  } t |  \ } } }	 }
 | j d  d d !} t |  d k r | d d k r | d k r d	 } | d } n  | d | } | |  j k r |  j | } n| st	 | } n  t
 |  j j |   } t | t  r| r| | d
 | d d d | d d d |  j d |  j d |  j d |  j } |  j | <q| | d |  j d |  j d |  j d |  j } |  j | <n) | | d |  j d |  j } |  j | <| j t  d | k r"d | k r"d | d <n  t j j   } d5 } |  j r|
 } |  j j |  } | ryM | j d d  \ } } t j j   } | j |  | j   } d5 | _ Wqt k
 r|  j j |  d5 } d5 } qXqn d5 } | |  j k r5|  j r5| j d  r5|  j  r5d | k r5| d | d <n  | d6 k rc|  j rc| rc|  j j |  n  | d7 k rd | k r| d } | j!   j" d d  j d  } xG | D]< } d | } | | } | j | d5  | k rd5 } PqqWn  | ri| d8 k ri|  j rid | k ri| j d  r| d k rGt# d i  d   n  |  j$ | d d d | d  | d \ } } t% |  | _& t' | j& _( n	t) | |  } | d! k r| sd" | d# <d } n  t% |  } | rt' | _( n  | | f S| d$ k r^| j d  r/|  j  r/d% | k r/| d | d% <n  | j d&  rmd& | k rm| d& | d' <qmn | d( k rmn  |  j* | | | |	 | | | | | 	 \ } } | j+ d) k r8| d k r8x" t, |  D] } | | | | <qWt% |  } t- | d*  r| j. | _. n  t/ | | | |  j |  | } d+ | _+ t' | _( q| j+ d+ k rP| } q|  j j |  | } ng t0 |  } | j d,  rd" | d# <t% |  } d } n- |  j* | | | |	 | | | | | 	 \ } } Wn t1 k
 r} |  j2 rt3 | t4  r(| j5 } | j6 } d- | _+ t7 |  | _8 qt3 | t9 j  rsd. } t% i d/ d0 6d1 d# 6t |  d2 6 } d. | _8 qt7 |  } t% i d/ d0 6d3 d# 6t |  d2 6 } d4 | _8 q  n X| | f S(9   s   Performs a single HTTP request.
The 'uri' is the URI of the HTTP resource and can begin
with either 'http' or 'https'. The value of 'uri' must be an absolute URI.

The 'method' is the HTTP method to perform, such as GET, POST, DELETE, etc.
There is no restriction on the methods allowed.

The 'body' is the entity body to be sent with the request. It is a string
object.

Any extra headers that are to be sent with the request should be provided in the
'headers' dictionary.

The maximum number of redirect to follow before raising an
exception is 'redirections. The default is 5.

The return value is a tuple of (response, content), the first
being and instance of the 'Response' class, the second being
a string that contains the response entity body.
        s
   user-agents   Python-httplib2/%s (gzip)R   i    i   i   t   443R   Rl  R   R   R   RA  R	   RW  R   s   accept-encodings   gzip, deflates   

t   etags   if-matchR  R  R   Rr   RE   RF   s
   -varied-%ss   -x-permanent-redirect-urls3   Redirected more times than rediection_limit allows.Rv   R  R   t   504R   R   s   if-none-matchs   last-modifieds   if-modified-sinceR   i0  R  i   s   only-if-cachedi  s   Request Timeouts
   text/plains   content-typet   408s   content-lengtht   400s   Bad RequestN(   s   GETs   HEAD(   s   GETs   HEAD(   s   GETs   HEAD(:   R   Ry   R{   t   __version__R   Ra   RK   Rn   R  t   SCHEME_TO_CONNECTIONRG   R  R5  t
   issubclassRT  R   RA  R	   RW  R  R(   R   R   R   RJ   t
   FeedParsert   feedR)  t   _parset
   IndexErrorR   R  R  RX   R   R$   R   R    R  R   t	   fromcacheR   R  R   RQ   R   R  R   R   t	   ExceptionR  Rd   R5   R6   R7   Re   R   R   (   R0   R   R   R  Rv   R  t   connection_typeRZ   R[   R_   R`   t   domain_portt   conn_keyR  t   certsR   t   cached_valueR   R7   t
   feedparserR   R   RP   Rw   Rx   R6   R   t   entry_dispositiont   merged_responseR   Rk  (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s
   	.					=
!

',

	
%-			
	1				N(   R3   R4   R   R   R   R8   R  R  R  R  R  R  Ry   t   DEFAULT_MAX_REDIRECTSR   (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR     s   	<	
			<	E	c           B   s>   e  Z d  Z e Z d Z d Z d Z d Z	 d   Z
 d   Z RS(   s<   An object more like email.Message than httplib.HTTPResponse.i   i   t   Okc         C   s  t  | t j  ry x* | j   D] \ } } | |  | j   <q W| j |  _ t |  j  |  d <| j |  _ | j |  _ n t  | t	 j
 j
  r x$ | j   D] \ } } | |  | <q Wt |  d  |  _ nE x$ | j   D] \ } } | |  | <q Wt |  j d |  j   |  _ d  S(   NR   (   Rd   R   t   HTTPResponseR2   RX   R   Re   R   t   versionR   R   R/   R   Rt   RJ   (   R0   R   Rw   Rx   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8     s    c         C   s   | d k r |  St  |  d  S(   NRs   (   t   AttributeError(   R0   R   (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   __getattr__  s    N(   R3   R4   R   R   R  R  R   R   R   R  R8   R  (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyR      s   	(   t
   __future__R    R  t   __copyright__t   __contributors__t   __license__R  R   t   sysR   t   email.Utilst   email.Messaget   email.FeedParserR   R   R   R   R  R   R$  R  R   R   R   Rf  t   hashlibR   R   R   Rj   t   ImportErrort   shaR  R  R   R   R   t   httplib2R   R   R
   t   SSLErrorRe  R   R  t   version_infoR   R   t   __all__R(   R,   R1   R   R  R2   R  R"   R5   R#   R$   R%   R&   R'   R:   R;   R<   R)   R   R=   R>   R  R\   RY   t   dirnamet   abspatht   __file__RV  RH   RQ   t   compileRR   RU   Ra   Rc   Rm   Rq   Ru   Ry   R   R   R   R   R   R   R   R   R   R   R   t   objectR   R   R   R   R  R  R  R  R"  R/  R6  R!   R@  R?  RU  RT  R  t   google.appengine.api.urlfetchRm  Rn  Ro  Rp  Rq  Rs   Rr  Rs  R  R   R    (    (    (    s5   /usr/lib/python2.7/dist-packages/httplib2/__init__.pyt   <module>   s  		
						$							J		%		"
9>
!3
5	 