Ñò
à"Ic           @   s  d  d k  Z  d  d k Z d  d k Z d  d k l Z d  d k l Z e i Z d d d „  ƒ  YZ d e i f d „  ƒ  YZ	 d e f d	 „  ƒ  YZ
 d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d „ Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   TestCase(   t   test_supportt
   FakeSocketc           B   s,   e  Z e i d  „ Z d „  Z d d „ Z RS(   c         C   s   | |  _  | |  _ d |  _ d  S(   Nt    (   t   textt	   fileclasst   data(   t   selfR   R   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   __init__   s    		c         C   s   |  i  | 7_  d  S(   N(   R   (   R   R   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   sendall   s    c         C   s:   | d j o | d j o t  i ƒ  ‚ n |  i |  i ƒ S(   Nt   rt   rb(   t   httplibt   UnimplementedFileModeR   R   (   R   t   modet   bufsize(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   makefile   s    N(   t   __name__t
   __module__t   StringIOR   R	   t   NoneR   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR      s   	t   NoEOFStringIOc           B   s&   e  Z d  Z d d „ Z d 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(   NR   s   caller tried to read past EOF(   R   t   readt   AssertionError(   R   t   nR   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR      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   (   R   t   lengthR   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR   %   s    N(   R   R   t   __doc__R   R   R   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR      s   t   HeaderTestsc           B   s   e  Z d  „  Z RS(   c         C   sÛ   d 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 ƒ q< Wq/ Wd  S(   Niÿÿÿÿt   HeaderCountingBufferc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   h  |  _  d  S(   N(   t   count(   R   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR   4   s    c         S   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   splitt   lent   lowerR   t
   setdefaultt   listt   append(   R   t   itemt   kvt   lcKey(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR%   6   s    (   R   R   R   R%   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR   3   s   	s   Content-lengtht   Hosts   Accept-encodings   example.comt   blahblahblaht   spamspamspamt   POSTt   /i   (   s   Content-lengthR)   s   Accept-encoding(   R   R$   t   Truet   Falset   HTTPConnectionR   t   sockt   _buffert   strR!   t   requestt   assertEqualR   R"   (   R   R   R   t   explicit_headert   headert   connt   bodyt   headers(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_auto_headers-   s      (   R   R   R;   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR   ,   s   t	   BasicTestc           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   s   d } t  | ƒ } t i | ƒ } | i ƒ  |  i | i ƒ  d ƒ |  i | i ƒ  ƒ d } t  | ƒ } t i | ƒ } |  i t i	 | i ƒ d  S(   Ns   HTTP/1.1 200 Ok

Textt   Texts   HTTP/1.1 400.100 Not Ok

Text(
   R   R   t   HTTPResponset   beginR5   R   t
   assertTruet   isclosedt   assertRaisest   BadStatusLine(   R   R9   R1   t   resp(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_status_linesM   s    
c         C   s‡   d } t  | ƒ } t i | ƒ } | i ƒ  |  i | i d ƒ d ƒ |  i | i ƒ  ƒ |  i | i d ƒ d ƒ |  i | i ƒ  ƒ d  S(   Ns*   HTTP/1.1 200 Ok
Content-Length: 4

Texti   t   Tet   xt(	   R   R   R>   R?   R5   R   t   assertFalseRA   R@   (   R   R9   R1   RD   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_partial_reads\   s    
c         C   sÈ   x' d D] } |  i  t i t i | ƒ q Wx— d d d d f D]ƒ \ } } } t i | ƒ } | i } | | i j o |  i d
 | | i f ƒ n | | i j o |  i d | | i f ƒ q= q= Wd  S(   Ns   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   [fe80::207:e9ff:fe9b]s!   Host incorrectly parsed: %s != %ss!   Port incorrectly parsed: %s != %s(   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   (   RB   R   t
   InvalidURLt   HTTPt   _connt   hostt   failt   port(   R   t   hpt   ht   pt   httpt   c(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_host_porth   s      	  c         C   sb   d } d } t  | ƒ } t i | ƒ } | i ƒ  | i d ƒ } | | j o |  i d ƒ n d  S(   Ns¨   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 properly(   R   R   R>   R?   t	   getheaderRN   (   R   R   t   hdrt   sR
   t   cookies(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_response_headersw   s    
c         C   sV   t  d t ƒ } t i | d d ƒ} | i ƒ  | i ƒ  d j o |  i d ƒ n d  S(   Ns*   HTTP/1.1 200 OK
Content-Length: 14432

t   methodt   HEADR   s)   Did not expect response from HEAD request(   R   R   R   R>   R?   R   RN   (   R   R1   RD   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_read_head‰   s    	
c         C   si   d } t  t d ƒ } t i d ƒ } t | ƒ } | | _ | i d d | ƒ |  i | i i	 | ƒ ƒ d  S(   NsP   GET /foo HTTP/1.1
Host: example.com
Accept-Encoding: identity
Content-Length:R   s   example.comt   GETs   /foo(
   t   opent   __file__R   R0   R   R1   R4   R@   R   t
   startswith(   R   t   expectedR9   R8   R1   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_send_file–   s    	c      	   C   sô   d } t  | d ƒ } t i | d d ƒ} | i ƒ  |  i | i ƒ  d ƒ | i ƒ  x˜ d	 D] } t  | | ƒ } t i | d d ƒ} | i ƒ  zM y | i ƒ  Wn+ t i j
 o } |  i | i d ƒ n X|  i	 d ƒ Wd  | i ƒ  Xq\ Wd  S(
   NsD   HTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello worl
1
d
s   0
R[   R^   s   hello worldR   s   foo
s   IncompleteRead expected(   R   s   foo
(
   R   R   R>   R?   t   assertEqualsR   t   closet   IncompleteReadt   partialRN   (   R   t   chunked_startR1   RD   t   xt   i(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_chunked¡   s$    

 
 c         C   sO   t  d ƒ } t i | d d ƒ} | i ƒ  |  i | i ƒ  d ƒ | i ƒ  d  S(   Ns.   HTTP/1.1 200 OK
Content-Length: -1

Hello
R[   R^   s   Hello
(   R   R   R>   R?   Rd   R   Re   (   R   R1   RD   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_negative_content_length½   s
    
(
   R   R   RE   RI   RU   RZ   R]   Rc   Rk   Rl   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR<   L   s   							t   OfflineTestc           B   s   e  Z d  „  Z RS(   c         C   s   |  i  t i t i d ƒ d  S(   Ns	   Not Found(   Rd   R   t	   responsest	   NOT_FOUND(   R   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_responsesÆ   s    (   R   R   Rp   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyRm   Å   s   t   TimeoutTestc           B   s)   e  Z d Z d  „  Z d „  Z d „  Z RS(   c         C   sD   t  i  t  i t  i ƒ |  _ t i |  i ƒ t _ |  i i d ƒ d  S(   Ni   (	   t   sockett   AF_INETt   SOCK_STREAMt   servR   t	   bind_portRq   t   PORTt   listen(   R   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   setUpÌ   s    c         C   s   |  i  i ƒ  d  |  _  d  S(   N(   Ru   Re   R   (   R   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   tearDownÑ   s    c         C   sL  |  i  t i ƒ  d j ƒ t i d ƒ z# t i t t i	 ƒ } | i
 ƒ  Wd t i d ƒ X|  i | i i ƒ  d ƒ | i ƒ  |  i  t i ƒ  d j ƒ t i d ƒ z) t i t t i	 d d ƒ} | i
 ƒ  Wd t i d ƒ X|  i | i i ƒ  d ƒ | i ƒ  t i t t i	 d d ƒ} | i
 ƒ  |  i | i i ƒ  d ƒ | i ƒ  d S(   sb   This will prove that the timeout gets through
        HTTPConnection and into the socket.
        i   Nt   timeout(   t   assert_Rr   t   getdefaulttimeoutR   t   setdefaulttimeoutR   R0   t   HOSTRq   Rw   t   connectR5   R1   t
   gettimeoutRe   (   R   t   httpConn(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   testTimeoutAttributeÕ   s*    
	

N(   R   R   R   Rw   Ry   Rz   Rƒ   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyRq   É   s   		t   HTTPSTimeoutTestc           B   s   e  Z d  „  Z RS(   c         C   sF   t  t d ƒ o2 t i t t i d d ƒ} |  i | i d ƒ n d  S(   Nt   HTTPSConnectionR{   i   (   t   hasattrR   R…   R   Rq   Rw   R5   R{   (   R   RQ   (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   test_attributesú   s    (   R   R   R‡   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyR„   ÷   s   c         C   s   t  i t t t t t ƒ d  S(   N(   R   t   run_unittestR   Rm   R<   Rq   R„   (   t   verbose(    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt	   test_main   s    t   __main__(    (   R   R   Rr   t   unittestR    t   testR   R   R   R   R   R<   Rm   Rq   R„   R   RŠ   R   (    (    (    s.   /mit/python/lib/python2.6/test/test_httplib.pyt   <module>   s   	 y.	