ó
—ã=Pc           @   s°   d  Z  d d l Z d d l Z d d l Z d d l Td d l m Z d d l m Z d d l	 m
 Z
 d d l m 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	 i  d „ Z
 RS(	   s„   
    HTTP transport using urllib2.  Provided basic http transport
    that provides for cookies, proxies but no authentication.
    c         K   s<   t  j |  ƒ t |  j ƒ j | ƒ 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(    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyR   '   s    c         C   sÑ   y– | j  } |  j j } | j | ƒ } | d  k	 rG t j d | ƒ | St j d | ƒ t j | ƒ } |  j	 | | ƒ |  j
 | ƒ } | j | | ƒ SWn4 t j k
 rÌ } t t | ƒ | j | j ƒ ‚ 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(    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt   open:   s    	c   	      C   s  d  } | j } | j } | j } y¦ t j | | | ƒ } |  j | ƒ |  j | | ƒ | j j | j ƒ t	 j
 d | ƒ |  j | ƒ } |  j | | ƒ t d | j j | j ƒ  ƒ } t	 j
 d | ƒ WnI t j k
 r} | j d k rô d  } qt | j | j | j ƒ ‚ 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    (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt   sendJ   s&    				c         C   s   |  j  j | ƒ d  S(   N(   R
   t   add_cookie_header(   R   R   (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __addcookies`   s    c         C   s   |  j  j | | ƒ d  S(   N(   R
   t   extract_cookies(   R   R   R   (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __getcookiesc   s    c         C   sC   t  j |  j j ƒ |  j d  k r/ t j | ƒ S|  j j | ƒ Sd  S(   N(	   t   sockett   setdefaulttimeoutR   t   timeoutR   R   R   t   urlopenR!   (   R   R   (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt   __openf   s    c         C   sU   t  | ƒ d } |  j j j | d  ƒ } | d  k r8 d  S| j } | j | | ƒ d  S(   Ni    (   R   R   t   proxyR   R   t   typet	   set_proxy(   R   R   R   t   protocolR5   (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt
   __setproxym   s    	c         C   s;   |  j  ƒ  } t |  j ƒ } t | j ƒ } | j | ƒ | S(   N(   t	   __class__R   R   R	   (   R   t   memot   clonet   pt   cp(    (    s+   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?   (    (    (    s+   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^   |  j  ƒ  } d  | k rN t j d j | ƒ ƒ } d | d  } | | j d <n  t j |  | ƒ S(   Nt   :s   Basic %siÿÿÿÿt   Authorization(   t   credentialsR   t   base64t   encodestringt   joinR#   R   R+   (   R   R   RF   t   encodedt   basic(    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyR+   …   s    c         C   s   |  j  j |  j  j f S(   N(   R   t   usernamet   password(   R   (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyRF      s    (   R@   RA   RB   R+   RF   (    (    (    s+   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   (    (    (    s+   suds-0.3.7-py2.6.egg/suds/transport/http.pyt   <module>   s   
\