mò
­fIc           @   s    d  k  Z  d  k Z d  k Z d k l Z d k l Z d f  d „  ƒ  YZ d e i f d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 „  Z d
 „  Z
 d  d „ Z e ƒ  d  S(   N(   s   TestCase(   s   test_supportt
   FakeSocketc           B   s,   t  Z e i d „ Z d „  Z d  d „ Z RS(   Nc         C   s   | |  _  | |  _ d  S(   N(   t   textt   selft	   fileclass(   R   R   R   (    (    t.   /mit/python/lib/python2.4/test/test_httplib.pyt   __init__
   s    	c         C   s   | |  _  d  S(   N(   t   dataR   (   R   R   (    (    R   t   sendall   s    c         C   s:   | d j o | d j o t i ƒ  ‚ n |  i |  i ƒ S(   Nt   rt   rb(   t   modet   httplibt   UnimplementedFileModeR   R   R   (   R   R
   t   bufsize(    (    R   t   makefile   s    (   t   __name__t
   __module__t   StringIOR   R   t   NoneR   (    (    (    R   R    	   s   	t   NoEOFStringIOc           B   s&   t  Z d  Z d d „ Z e d „ Z RS(   s¨   Like StringIO, but raises AssertionError on EOF.

    This is used below to test that httplib doesn't try to read
    more from the underlying file than it should.
    iÿÿÿÿc         C   s6   t  i  i |  | ƒ } | d j o t d ƒ ‚ n | S(   Nt    s   caller tried to read past EOF(   R   t   readR   t   nR   t   AssertionError(   R   R   R   (    (    R   R      s    c         C   s6   t  i  i |  | ƒ } | d j o t d ƒ ‚ n | S(   NR   s   caller tried to read past EOF(   R   t   readlineR   t   lengthR   R   (   R   R   R   (    (    R   R   "   s    (   R   R   t   __doc__R   R   R   (    (    (    R   R      s    t   HeaderTestsc           B   s   t  Z d „  Z RS(   Nc         C   sØ   d  k  } d t f d „  ƒ  Y} x² t t f D]¤ } x› d D]“ } | i d ƒ } t	 d ƒ | _
 | ƒ  | _ d } h  } | o t t | ƒ ƒ | | <n | i d	 d
 | | ƒ |  i | i i | i ƒ  d ƒ q9 Wq, Wd  S(   Nt   HeaderCountingBufferc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s   h  |  _ d  S(   N(   R   t   count(   R   (    (    R   R   1   s    c         C   sp   | i d ƒ } t | ƒ d j o: | d i ƒ  } |  i i | d ƒ |  i | c d 7<n t	 i
 |  | ƒ d  S(   Nt   :i   i    (   t   itemt   splitt   kvt   lent   lowert   lcKeyR   R   t
   setdefaultt   listt   append(   R   R   R$   R!   (    (    R   R'   3   s    (   R   R   R   R'   (    (    (    R   R   0   s   	s   Content-lengtht   Hosts   Accept-encodings   example.comt   blahblahblaht   spamspamspamt   POSTt   /i   (   s   Content-lengthR(   s   Accept-encoding(   R   R&   R   t   Truet   Falset   explicit_headert   headert   HTTPConnectiont   connR    t   sockt   _buffert   bodyt   headerst   strR"   t   requestR   t   assertEqualR   R#   (   R   R5   R   R6   R0   R2   R/   R   (    (    R   t   test_auto_headers*   s    	  (   R   R   R:   (    (    (    R   R   )   s   c          C   sk   t  i  ƒ  } t i }  z | t _ t ƒ  Wd  |  t _ X| i ƒ  } x" | i d ƒ D] } | i
 ƒ  GHqR Wd  S(   Ns   
(   R   t   buft   syst   stdoutt   _stdoutt   _testt   getvaluet   sR    t   linet   strip(   R>   RA   RB   R;   (    (    R   t   testM   s    		 
 c          C   sM  d }  t |  ƒ } t i | d ƒ } | i ƒ  | i ƒ  GH| i ƒ  d }  t |  ƒ } t i | d ƒ } y | i ƒ  Wn t i	 j
 o d GHn Xd GHxD d D]< } y t i | ƒ } Wn t i j
 o d GHqŸ Xd	 GHqŸ Wx¯ d d d  d! f D]› \ } } } y t i | ƒ } Wn t i j
 o d GHn X| i } | | i j o t d | | i f ‚ n | | i j o t d | | i f ‚ qò qò Wd } d } t | ƒ }	 t i |	 d ƒ }
 |
 i ƒ  |
 i d ƒ } | | j o t d ‚ n t d t ƒ } t i | d d d ƒ} | i ƒ  | i ƒ  d j o t d ‚ n | i ƒ  d  S("   Ns   HTTP/1.1 200 Ok

Texti   s   HTTP/1.1 400.100 Not Ok

Texts    BadStatusLine raised as expecteds   Expect BadStatusLines   www.python.org:abcs   www.python.org:s   InvalidURL raised as expecteds   Expect InvalidURLs   [fe80::207:e9ff:fe9b]:8000s   fe80::207:e9ff:fe9bi@  s   www.python.org:80s   www.python.orgiP   s   [fe80::207:e9ff:fe9b]s   InvalidURL raised erroneouslys   Host incorrectly parseds   Port incorrectly parseds¨   HTTP/1.1 200 OK
Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"
Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"

No body
sr   Customer="WILE_E_COYOTE"; Version="1"; Path="/acme", Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"s
   Set-Cookies&   multiple headers not combined properlys*   HTTP/1.1 200 OK
Content-Length: 14432

t   methodt   HEADR   s)   Did not expect response from HEAD request(   s   www.python.org:abcs   www.python.org:(   s   [fe80::207:e9ff:fe9b]:8000s   fe80::207:e9ff:fe9bi@  (   s   www.python.org:80s   www.python.orgiP   (   s   www.python.orgs   www.python.orgiP   (   s   [fe80::207:e9ff:fe9b]s   fe80::207:e9ff:fe9biP   (   R5   R    R3   R   t   HTTPResponset   respt   beginR   t   closet   BadStatusLinet   hpt   HTTPt   ht
   InvalidURLt   pt   httpt   _connt   ct   hostR   t   portR   t   hdrRA   R   t	   getheadert   cookiesR   (   R5   RQ   RV   RX   RN   RL   RS   R3   RP   RA   R   R   RH   (    (    R   R?   [   s^    


 
	 
	  
	
c         C   s   t  g } t i | Œ  d  S(   N(   R   t   testst   test_supportt   run_unittest(   t   verboseRY   (    (    R   t	   test_main¤   s    	(   R   R   R<   t   unittestt   TestCaseRD   RZ   R    R   R   R?   R   R]   (   RZ   R_   R   R   R?   R   R    R   R<   R]   RD   (    (    R   t   ?   s   			$		I