Ñò
—ã=Pc           @   s°   d  Z  d d k Z d d k Z d d k Z d d k Td d k l Z d d k l Z d d k	 l
 Z
 d d k l Z e e ƒ Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   sF   
Contains transport interface (classes) and reference implementation.
iÿÿÿÿN(   t   *(   t   Unskin(   t   urlparse(   t	   CookieJar(   t	   getLoggert   HttpTransportc           B   sY   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 h  d „ Z
 RS(	   s„   
    HTTP transport using urllib2.  Provided basic http transport
    that provides for cookies, proxies but no authentication.
    c         K   s<   t  i |  ƒ t |  i ƒ i | ƒ t ƒ  |  _ d |  _ d S(   s&  
        @param kwargs: Keyword arguments.
            - B{proxy} - An http proxy to be specified on requests.
                 The proxy is defined as {protocol:proxy,}
                    - type: I{dict}
                    - default: {}
            - B{timeout} - Set the url open timeout (seconds).
                    - type: I{float}
                    - default: 90
            - B{cache} - The http I{transport} cache.  May be set (None) for no caching.
                    - type: L{Cache}
                    - default: L{NoCache}
        N(	   t	   Transportt   __init__R   t   optionst   updateR   t	   cookiejart   Nonet	   urlopener(   t   selft   kwargs(    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyR   '   s    c         C   sÕ   y˜ | i  } |  i i } | i | ƒ } | d  j	 o t i d | ƒ | St i d | ƒ t i | ƒ } |  i	 | | ƒ |  i
 | ƒ } | i | | ƒ SWn6 t i j
 o' } t t | ƒ | i | i ƒ ‚ n Xd  S(   Ns   opening (%s), cacheds   opening (%s)(   t   urlR   t   cachet   getR   t   logt   debugt   u2t   Requestt   _HttpTransport__setproxyt   _HttpTransport__opent   putt	   HTTPErrort   TransportErrort   strt   codet   fp(   R   t   requestR   R   R   t	   u2requestt   e(    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   open:   s    	c   	      C   s  d  } | i } | i } | i } y¦ t i | | | ƒ } |  i | ƒ |  i | | ƒ | i i | i ƒ t	 i
 d | ƒ |  i | ƒ } |  i | | ƒ t d | i i | i ƒ  ƒ } t	 i
 d | ƒ WnM t i j
 o> } | i d j o
 d  } qt | i | i | i ƒ ‚ n X| S(   Ns   sending:
%siÈ   s   received:
%siÊ   iÌ   (   iÊ   iÌ   (   R   R   t   messaget   headersR   R   t   _HttpTransport__addcookiesR   R	   R   R   R   t   _HttpTransport__getcookiest   Replyt   dictt   readR   R   R   t   msgR   (	   R   R   t   resultR   R)   R#   R   R   R    (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   sendJ   s&    			
 c         C   s   |  i  i | ƒ d  S(   N(   R
   t   add_cookie_header(   R   R   (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __addcookies`   s    c         C   s   |  i  i | | ƒ d  S(   N(   R
   t   extract_cookies(   R   R   R   (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __getcookiesc   s    c         C   sE   t  i |  i i ƒ |  i d  j o t i | ƒ S|  i i | ƒ Sd  S(   N(	   t   sockett   setdefaulttimeoutR   t   timeoutR   R   R   t   urlopenR!   (   R   R   (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __openf   s    c         C   sW   t  | ƒ d } |  i i i | d  ƒ } | d  j o d  S| i } | i | | ƒ d  S(   Ni    (   R   R   t   proxyR   R   t   typet	   set_proxy(   R   R   R   t   protocolR5   (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt
   __setproxym   s    	c         C   s;   |  i  ƒ  } t |  i ƒ } t | i ƒ } | i | ƒ | S(   N(   t	   __class__R   R   R	   (   R   t   memot   clonet   pt   cp(    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __deepcopy__u   s
    (   t   __name__t
   __module__t   __doc__R   R!   R+   R$   R%   R   R   R?   (    (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyR   !   s   							t   HttpAuthenticatedc           B   s    e  Z d  Z d „  Z d „  Z RS(   sõ   
    Provides basic http authentication for servers that don't follow
    the specified challenge / response model.  This implementation
    appends the I{Authorization} http header with base64 encoded
    credentials on every http request.
    c         C   s`   |  i  ƒ  } d  | j o7 t i d i | ƒ ƒ } d | d  } | | i d <n t i |  | ƒ S(   Nt   :s   Basic %siÿÿÿÿt   Authorization(   t   credentialsR   t   base64t   encodestringt   joinR#   R   R+   (   R   R   RF   t   encodedt   basic(    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyR+   …   s    c         C   s   |  i  i |  i  i f S(   N(   R   t   usernamet   password(   R   (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyRF      s    (   R@   RA   RB   R+   RF   (    (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyRC   }   s   	(   RB   t   urllib2R   RG   R0   t   suds.transportt   suds.propertiesR   R   t	   cookielibR   t   loggingR   R@   R   R   R   RC   (    (    (    sR   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/transport/http.pyt   <module>   s   
\