
R_c           @  st  d  d l  m Z d  d l m Z e j d e  y d  d l m Z Wn! e k
 rg d  d l	 m Z n Xd  d l
 Z
 d  d l Z y d  d l m Z Wn! e k
 r d  d l m Z n Xd  d l Z d  d l m Z d  d l j Z d  d l Z d  d	 l m Z m Z d  d
 l m Z d  d l m Z d  d l m Z d Z e j Z e Z e Z  e Z! d e j" k Z# i d d 6d d 6Z$ d e% f d     YZ& d   Z' d   Z( d e) f d     YZ* e* j+ Z, d e j- f d     YZ- d e- f d     YZ. d e. f d     YZ/ d e/ f d      YZ0 d! e. f d"     YZ1 d# e. f d$     YZ2 d% e- f d&     YZ3 d' e- f d(     YZ4 d) e- f d*     YZ5 d+ e- f d,     YZ6 d- e6 f d.     YZ7 d/ e- f d0     YZ8 d1 e- f d2     YZ9 d3 e- f d4     YZ: d5 e- f d6     YZ; d7 e- f d8     YZ< d  d l= Z e> e j? d9  Z@ e@ r`d: e< f d;     YZA n  d< e< f d=     YZB e@ rd> eA eB f d?     YZC n  d@ e- f dA     YZD dB e- f dC     YZE dD eE f dE     YZF dF e- f dG     YZG dH eG f dI     YZH dJ eG f dK     YZI dL e- f dM     YZJ dN e- f dO     YZK dP eK f dQ     YZL dR e- f dS     YZM dT e- f dU     YZN dV e- f dW     YZO dX e- f dY     YZP dZ e- f d[     YZQ d\ e- f d]     YZR d^ eM f d_     YZS d` e- f da     YZT db e- f dc     YZU dd e- f de     YZV df e- f dg     YZW dh e- f di     YZX dj e- f dk     YZY dl e- f dm     YZZ dn e- f do     YZ[ dp e j\ f dq     YZ] dr e- f ds     YZ^ dt e- f du     YZ_ d dv  Za dw e jb f dx     YZc dy e- f dz     YZd d{ e- f d|     YZe d} e- f d~     YZf [. eg d k rpe jh   n  d S(   i(   t   print_function(   t   monkeyt   thread(   t   parse_qsN(   t   StringIO(   t   BytesIO(   t	   validator(   t   PY3t   PYPY(   t   socket(   t   pywsgi(   t   Inputs   Content-Lengths   -vt   OKi   s   Internal Server Errori  t   ConnectionClosedc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   A   s   c         C  s   |  j    } | s t  n  | j d  } i  } x t r |  j    j   } | sU Pn  | j d  } y | j d d  \ } } Wn t d | f    n X| j   d   | D k s t d | | | f   | | | <q3 W| | f S(   Ns   latin-1s   : i   s   Failed to split: %rc         S  s   h  |  ] } | j     q S(    (   t   lower(   t   .0t   x(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pys	   <setcomp>U   s   	 s$   Header %r:%r sent more than once: %r(	   t   readlineR   t   decodet   Truet   stript   splitt   printR   t   AssertionError(   t   fdt   response_linet   headerst   linet   keyt   value(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   read_headersE   s$    		5c         c  s   x t  r |  j   } | j   } y t | d  } Wn t d |    n X| d k r |  j d  } | d k s t t |    Pn  |  j |  } | V|  j d  } | d k s t t |    q Wd  S(   Ni   s   Failed to parse chunk size: %ri    i   s   
(   R   R   R   t   intR   t   readR   t   repr(   R   R   t
   chunk_sizet   crlft   data(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   iread_chunksZ   s     	t   Responsec           B  sq   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 d d	 d
 d d d d   Z RS(   c         C  s   | |  _  | |  _ d  |  _ t |  _ y | d  j d d  \ } } |  _ t |  |  _	 | j d  \ } |  _
 | d k s t t |    |  j
 d	 k s t t |  j
    Wn" t k
 r t d |    n Xd  S(
   Nit    i   t   /t   HTTPs   1.0s   1.1s	   Error: %r(   s   1.0s   1.1(   t   status_lineR   t   Nonet   bodyt   Falset   chunksR   t   reasonR!   t   codet   versionR   R#   t	   ExceptionR   (   t   selfR,   R   R3   R2   R+   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   __init__o   s    				"(c         c  s   |  j  V|  j V|  j Vd  S(   N(   R,   R   R.   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   __iter__~   s    c         C  s/   |  j  j |  j |  j |  j |  j f } d | S(   Ns0   <%s status_line=%r headers=%r body=%r chunks=%r>(   t	   __class__R   R,   R   R.   R0   (   R5   t   args(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   __str__   s    'c         C  sl   t  | d  r= |  j | k sh t d |  j | |  f   n+ |  j | k sh t d |  j | |  f   d  S(   Nt   __contains__s$   Unexpected code: %r (expected %r)
%s(   t   hasattrR2   R   (   R5   R2   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt
   assertCode   s    .c         C  s/   |  j  | k s+ t d |  j  | |  f   d  S(   Ns&   Unexpected reason: %r (expected %r)
%s(   R1   R   (   R5   R1   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   assertReason   s    c         C  s/   |  j  | k s+ t d |  j  | |  f   d  S(   Ns'   Unexpected version: %r (expected %r)
%s(   R3   R   (   R5   R3   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   assertVersion   s    c         C  sA   |  j  j | t  } | | k s= t d | | | |  f   d  S(   Ns)   Unexpected header %r: %r (expected %r)
%s(   R   t   getR/   R   (   R5   t   headerR   t
   real_value(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   assertHeader   s    c         C  sV   t  | t  r' t r' | j d  } n  |  j | k sR t d |  j | |  f   d  S(   Nt   asciis$   Unexpected body: %r (expected %r)
%s(   t
   isinstancet   strR   t   encodeR.   R   (   R5   R.   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt
   assertBody   s    i   t   defaults   1.1c         C  s	  t  |  \ } }	 |  | |	  }
 | d  k	 r= |
 j |  n  | d k r[ t j |  } n  | d  k	 rw |
 j |  n  | d  k	 r |
 j |  n  |
 j d k r |
 S| d  k	 r t | t	  r t
 |  } n  |
 j d |  n  y d |	 j d d  k rDt |	 k rt d  n  t t |   |
 _ d j |
 j  |
 _ n@ t |	 k rut	 |	 t  } | j |  |
 _ n | j   |
 _ Wn. t d |
  d	 d  l } | j     n X| d  k	 r|
 j |  n  | d  k	 r| |
 j k st | |
 j f   n  |
 S(
   NRI   id   s   Content-Lengtht   chunkeds   Transfer-Encodingt    sh   WARNING: server used chunked transfer-encoding despite having Content-Length header (libevent 1.x's bug)s)   Response.read failed to read the body:
%si(   R    R-   R=   t   REASONSR@   R>   R?   R2   RE   R!   RF   RC   t   CONTENT_LENGTHR   t   listR'   R0   t   joinR.   R"   t	   tracebackt	   print_excRH   R   (   t   clsR   R2   R1   R3   R.   R0   t   content_lengtht   _status_lineR   R5   t   numRP   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR"      sH     
'N(   R   R   R6   R7   R:   R=   R>   R?   RC   RH   t   classmethodR-   R"   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR(   m   s   									t   TestCasec           B  s   e  Z d Z e e  Z d Z d  Z d Z d   Z	 d   Z
 d   Z e j rl e j rl d   Z d   Z n  d   Z d   Z d	   Z d
   Z RS(   RK   t	   localhostc         C  s   d d  l  } | j d  } | S(   Nis   gevent.pywsgi(   t   loggingt	   getLogger(   R5   RY   t   logger(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   init_logger   s    c         C  sA   |  j    } |  _ t j |  j d f | d | d | |  _ d  S(   Ni    t   logt	   error_log(   R\   R[   R
   t
   WSGIServert   listen_addrt   server(   R5   t   applicationR[   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   init_server   s    c         C  sg   |  j  } |  j d  k	 r* |  j |  } n  |  j |  |  j j   |  j j |  _ t j	 j
 |   d  S(   N(   Rb   R   R-   Rc   Ra   t   startt   server_portt   portt	   greentestRW   t   setUp(   R5   Rb   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRh      s    	c         C  s   |  j  j t j |   | S(   N(   t   close_on_teardownt   appendt   weakreft   ref(   R5   t   resource(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   _close_on_teardown   s    c         C  sH   g  |  j  D] } |   d  k	 r
 |   ^ q
 |  _  t t |   j   d  S(   N(   Ri   R-   t   superRW   t   _tearDownCloseOnTearDown(   R5   t   r(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRp      s    1c         C  sU   t  j j |   |  j d  k	 rH t j j d   |  j j   Wd  QXn  d  |  _ d  S(   Ng      ?(	   Rg   RW   t   tearDownRa   R-   t   geventt   Timeoutt	   start_newt   stop(   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRr      s
    c           s~   t  j  j  j f     j      } t rz   j    f d    d t f    f d     Y} |   } n  | S(   Nc            s   d | k r" | j  d  | d <n  d | k r;  |  |   Sd | d < |  |   } | j     f d   } | | _  j |  | S(   Nt   bufsizet	   bufferingt   modet   rwbc           s+   t  |  t  r! |  j d  }  n    |   S(   NRD   (   RE   RF   RG   (   R&   (   t   _rconn_write(    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   write  s    (   t   popR|   Rn   (   R9   t   kwargst   rconnR|   (   t   conn_makefileR5   (   R{   sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   makefile  s    
		t   proxyc             s   e  Z    f d    Z RS(   c           s   | d k r  St    |  S(   NR   (   t   getattr(   R5   t   name(   t   connR   (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   __getattribute__  s    (   R   R   R   (    (   R   R   (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   (   R	   t   create_connectiont   connect_addrRf   Rn   R   R   t   object(   R5   t   resultR   (    (   R   R   R   R5   sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   connect  s    	c         C  s   |  j    j d d  S(   NRw   i   (   R   R   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   %  s    c         O  s5   |  j    j d d  } | j d  t | | |  S(   NRw   i   s#   GET / HTTP/1.1
Host: localhost

(   R   R   R|   t	   read_http(   R5   R9   R~   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   urlopen(  s    N(   R   R   R-   Ra   t   staticmethodR   Rb   R`   R   R\   Rc   Rh   Rg   t   CPYTHONt   PY2Rn   Rp   Rr   R   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRW      s   							$	t   CommonTestsc           B  s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C  s   |  j    } | j d  t | d d } | j j d  d k rN t rN d  S| j d  t | d d d	 d
 d d | j d  t | d d | j   d  S(   Ns#   GET / HTTP/1.1
Host: localhost

R.   s   hello worldt
   Connectiont   closes+   GET /notexist HTTP/1.1
Host: localhost

R2   i  R1   s	   Not Founds	   not found(   R   R|   R   R   R@   t   server_implements_pipelineR   (   R5   R   t   response(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt
   test_basic0  s    c         C  s   t  s
 d  S|  j   } | j d d  t | d d t d  } yT t j j d d | } z* t | d d	 d
 d d d | j   Wd  | j   XWn% t k
 r } | | k	 r   q n Xd  S(   Ns#   GET / HTTP/1.1
Host: localhost

s+   GET /notexist HTTP/1.1
Host: localhost

R.   s   hello worlds@   HTTP pipelining not supported; the second request is thrown awayg      ?t	   exceptionR2   i  R1   s	   Not Founds	   not found(	   R   R   R|   R   R   Rs   Rt   Ru   R   (   R5   R   R   t   timeoutt   ex(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_pipeline<  s    c         C  s   |  j    } | j d  t |  } | j j d  d k rH t rH d  S| j d  t |  | j d  y | j   } Wn/ t j k
 r } | j	 d t
 k r   q n X|  j | d | f  d  S(   Ns#   GET / HTTP/1.1
Host: localhost

R   R   s6   GET / HTTP/1.1
Host: localhost
Connection: close

i    sC   The remote side is expected to close the connection, but it sent %r(   R   R|   R   R   R@   R   R   R	   t   errorR9   t   CONN_ABORTED_ERRORSt   assertFalse(   R5   R   R   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_connection_closeN  s     

c         C  s   |  j    } g  } x! t d  D] } | j d  q Wd j |  } d | } | j |  | j   } | j d  d } |  j | d  | j   d  S(   Ni  t   pathR*   s%   GET /%s HTTP/1.0
Host: localhost

R)   i   t   414(	   R   t   rangeRj   RO   R|   R   R   t   assertEqualR   (   R5   R   t
   path_partst   _R   t   requestR   t   status(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   SKIP_test_006_reject_long_urlsc  s    
(   R   R   R   R   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   .  s   			t   TestNoChunksc           B  s    e  Z d Z d    Z d   Z RS(   c         C  s`   |  j  | j d   | d } | d k rF | d d g  d d g S| d	 d g  d
 d g S(   Ns   wsgi.input_terminatedt	   PATH_INFOR*   s   200 OKs   Content-Types
   text/plains   hello t   worlds   404 Not Founds   not t   found(   s   Content-Types
   text/plain(   s   Content-Types
   text/plain(   t
   assertTrueR@   (   R5   t   envt   start_responseR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   v  s    

c         C  s   |  j    } | j d  t | d d } |  j | j  | j d d  t s` |  j    } n  | j d  t | d d d	 d
 d d } |  j | j  | j d d  d  S(   Ns#   GET / HTTP/1.1
Host: localhost

R.   s   hello worlds   Content-Lengtht   11s,   GET /not-found HTTP/1.1
Host: localhost

R2   i  R1   s	   Not Founds	   not foundt   9(   R   R|   R   R   R0   RC   R   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test  s    N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   q  s   		t   TestExplicitContentLengthc           B  s   e  Z d    Z RS(   c         C  sf   |  j  | j d   | d } | d k rI | d d d g  d	 d
 g S| d d d g  d d g S(   Ns   wsgi.input_terminatedR   R*   s   200 OKs   Content-Types
   text/plains   Content-LengthR   s   hello R   s   404 Not FoundR   s   not R   (   s   Content-Types
   text/plain(   s   Content-LengthR   (   s   Content-Types
   text/plain(   s   Content-LengthR   (   R   R@   (   R5   R   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    

(   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   t	   TestYieldc           B  s   e  Z e d     Z RS(   c         c  sG   |  d } | d k r. | d d	 g  d Vn | d d
 g  d Vd  S(   NR   R*   s   200 OKs   Content-Types
   text/plains   hello worlds   404 Not Founds	   not found(   s   Content-Types
   text/plain(   s   Content-Types
   text/plain(    (   R   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    
(   R   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   t   TestBytearrayc           B  s   e  Z d Z e d     Z RS(   c         C  sY   |  d } | d k r< | d d
 g  t  d  t  d  g S| d d g  t  d	  g S(   NR   R*   s   200 OKs   Content-Types
   text/plains   hello R   s   404 Not Founds	   not found(   s   Content-Types
   text/plain(   s   Content-Types
   text/plain(   t	   bytearray(   R   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    
N(   R   R   R-   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   t   MultiLineHeaderc           B  s    e  Z e d     Z d   Z RS(   c         C  s-   d |  d k s t   | d d g  d g S(   Ns   test.submitt   CONTENT_TYPEs   200 OKs   Content-Types
   text/plaint   ok(   s   Content-Types
   text/plain(   R   (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s6   d j  d	  } |  j   } | j |  t |  d S(
   s
   issue #116s   
s   POST / HTTP/1.0s   Host: localhosts9   Content-Type: multipart/related; boundary="====XXXX====";s$    type="text/xml";start="test.submit"s   Content-Length: 0RK   N(   s   POST / HTTP/1.0s   Host: localhosts9   Content-Type: multipart/related; boundary="====XXXX====";s$    type="text/xml";start="test.submit"s   Content-Length: 0RK   RK   (   RO   R   R|   R   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_multiline_116  s         	(   R   R   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   t
   TestGetArgc           B  s    e  Z e d     Z d   Z RS(   c         C  st   |  d j  d  } t r+ | j d  } n  t |  j d d g  d } | d d g  d
 | | f j d  g S(   Ns
   wsgi.inputi   RD   t   ai   i    s   200 OKs   Content-Types
   text/plains   a is %s, body is %s(   s   Content-Types
   text/plain(   R"   R   R   R   R@   RG   (   R   R   R.   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  sS   |  j    } d j d
  } | j |  | j d  t | d d	 | j   d  S(   Ns   
s   POST / HTTP/1.0s   Host: localhosts   Content-Length: 3RK   s   a=at   01234567890123456789R.   s   a is a, body is a=a(   s   POST / HTTP/1.0s   Host: localhosts   Content-Length: 3RK   s   a=a(   R   RO   R|   R   R   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_007_get_arg  s        	(   R   R   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   	t   TestCloseIterc           B  s8   e  Z d Z d    Z d   Z e Z d   Z d   Z	 RS(   c         C  s   | d d g  |  S(   Ns   200 OKs   Content-Types
   text/plain(   s   Content-Types
   text/plain(    (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         c  s   t  d  Vd Vd  S(   Ns   Hello Worldt   !(   R   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR7     s    c         C  s   |  j  d 7_  d  S(   Ni   (   t   closed(   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    c         C  sU   t  |  _ |  j   } | j d  t | d d d d d g |  j |  j d  d  S(   Ns#   GET / HTTP/1.1
Host: localhost

R.   s   Hello World!R0   s   Hello WorldR   i   (   R/   R   R   R|   R   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_close_is_called  s
    	N(
   R   R   R-   R   Rb   R7   R/   R   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   			t   TestChunkedAppc           B  s;   e  Z d  d d g Z d   Z d   Z d   Z d   Z RS(   t   thist   isRJ   c         C  s   d j  |  j  S(   NRK   (   RO   R0   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR.     s    c         c  sC   |  j  | j d   | d d g  x |  j D] } | Vq0 Wd  S(   Ns   wsgi.input_terminateds   200 OKs   Content-Types
   text/plain(   s   Content-Types
   text/plain(   R   R@   R0   (   R5   R   R   t   chunk(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   
  s    c         C  s   |  j    } | j d  t | d |  j   d d  } t rf | j d d  |  j | j |  j  nE | j d t	  | j d t
 t |  j      |  j | j t	  d  S(   Ns6   GET / HTTP/1.1
Host: localhost
Connection: close

R.   R0   s   Transfer-EncodingRJ   s   Content-Length(   R   R|   R   R.   R-   t   server_implements_chunkedRC   R   R0   R/   RF   t   len(   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_chunked_response  s    "c         C  s   |  j    } | j d  t |  } |  j | j |  j    |  j | j j d  d   | j j d  } | d  k	 r |  j | t t	 |  j      n  d  S(   Ns6   GET / HTTP/1.0
Host: localhost
Connection: close

s   Transfer-Encodings   Content-Length(
   R   R|   R   R   R.   R   R@   R-   RF   R   (   R5   R   R   RS   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_no_chunked_http_1_0  s    (   R   R   R0   R.   Rb   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s
   			t   TestBigChunksc           B  s   e  Z d  d g d Z RS(   R   i    i   (   R   R   R0   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   '  s   t   TestNegativeReadc           B  s#   e  Z d    Z d   Z d   Z RS(   c         C  sT   |  j  | j d   | d d	 g  | d d k rP | d j d  } | g Sd  S(
   Ns   wsgi.input_terminateds   200 OKs   Content-Types
   text/plainR   s   /reads
   wsgi.inputi(   s   Content-Types
   text/plain(   R   R@   R"   (   R5   R   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   -  s
    c         C  s3   |  j    } d } | j |  t | d d d  S(   Nsl   POST /read HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

2
oh
4
 hai
0

R.   s   oh hai(   R   R|   R   (   R5   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_negative_chunked_read4  s    c         C  s3   |  j    } d } | j |  t | d d d  S(   NsT   POST /read HTTP/1.1
Host: localhost
Connection: close
Content-Length: 6

oh haiR.   s   oh hai(   R   R|   R   (   R5   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_negative_nonchunked_read<  s    (   R   R   Rb   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   +  s   		t   TestNegativeReadlinec           B  s/   e  Z d Z e d     Z d   Z d   Z RS(   c         C  s>   | d d g  |  d d k r: |  d j  d  } | g Sd  S(	   Ns   200 OKs   Content-Types
   text/plainR   s	   /readlines
   wsgi.inputi(   s   Content-Types
   text/plain(   R   (   R   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   H  s    c         C  s3   |  j    } d } | j |  t | d d d  S(   Nsp   POST /readline HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

2
oh
4
 hai
0

R.   s   oh hai(   R   R|   R   (   R5   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_negative_chunked_readlineO  s    c         C  s3   |  j    } d } | j |  t | d d d  S(   NsX   POST /readline HTTP/1.1
Host: localhost
Connection: close
Content-Length: 6

oh haiR.   s   oh hai(   R   R|   R   (   R5   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt!   test_negative_nonchunked_readlineW  s    N(   R   R   R-   R   R   Rb   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   E  s   	t   TestChunkedPostc           B  sG   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c           s   |  j    j d   | d d g    d d k rP   d j d  } | g S  d d	 k r g  t   f d
   d  D] } | ^ qy } | S  d d k r g  t   f d   d  D] } | ^ q Sd  S(   Ns   wsgi.input_terminateds   200 OKs   Content-Types
   text/plainR   s   /as
   wsgi.inputi   s   /bc             s     d j  d  S(   Ns
   wsgi.inputi   (   R"   (    (   R   (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   <lambda>k  RK   RK   s   /cc             s     d j  d  S(   Ns
   wsgi.inputi   (   R"   (    (   R   (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   o  RK   (   s   Content-Types
   text/plain(   R   R@   R"   t   iter(   R5   R   R   R&   R   t   lines(    (   R   sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   c  s    +c         C  s   |  j    } d } | j |  t | d d |  j    } | j | j d d   t | d d |  j    } | j | j d d   t | d d d  S(   Nsi   POST /a HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

2
oh
4
 hai
0

R.   s   oh hais   /as   /bs   /c(   R   R|   R   t   replace(   R5   R   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_014_chunked_postq  s    c         C  s3   d } |  j    } | j |  t | d d d  S(   Nst   POST /a HTTP/1.1
Host: localhost
Connection: close
Content-Length: 12
Transfer-Encoding: chunked

{"hi": "ho"}R2   i  (   R   R|   R   (   R5   R&   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt#   test_229_incorrect_chunk_no_newline  s    c         C  s3   d } |  j    } | j |  t | d d d  S(   Nsv   POST /a HTTP/1.1
Host: localhost
Connection: close
Content-Length: 12
Transfer-Encoding: chunked

{"hi": "ho"}
R2   i  (   R   R|   R   (   R5   R&   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt    test_229_incorrect_chunk_non_hex  s    c         C  s3   d } |  j    } | j |  t | d d d  S(   Nsw   POST /a HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

2;token="oh hi"
oh
4
 hai
0

R.   s   oh hai(   R   R|   R   (   R5   R&   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt!   test_229_correct_chunk_quoted_ext  s    c         C  s3   d } |  j    } | j |  t | d d d  S(   Nsu   POST /a HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

2;token=oh_hi
oh
4
 hai
0

R.   s   oh hai(   R   R|   R   (   R5   R&   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt    test_229_correct_chunk_token_ext  s    c         C  sI   d } | j  d d d  } |  j   } | j |  t | d d d  S(   Nsu   POST /a HTTP/1.1
Host: localhost
Connection: close
Transfer-Encoding: chunked

2;token=oh_hi
oh
4
 hai
0

t   oh_hit   _oh_hii  R2   i  (   R   R   R|   R   (   R5   R&   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt+   test_229_incorrect_chunk_token_ext_too_long  s
    (	   R   R   Rb   R   R   R   R   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   `  s   						t   TestUseWritec           B  sN   e  Z d  Z d Z e e e e   Z d   Z d   Z d   Z	 d   Z
 RS(   t   abcdet   endc         C  s   | d d k r> | d d
 d |  j  f g  } | |  j  n} | d d k rp | d d g  } | |  j  nK | d d k r | d d g  } | |  j  | |  j  n t d	   |  j g S(   NR   s   /explicit-content-lengths   200 OKs   Content-Types
   text/plains   Content-Lengths   /no-content-lengths   /no-content-length-twices   Invalid url(   s   Content-Types
   text/plain(   s   Content-Types
   text/plain(   s   Content-Types
   text/plain(   RS   R.   R4   R   (   R5   R   R   R|   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    	c         C  s\   |  j    } | j d  t | d |  j |  j } | j d |  j  | j d t  d  S(   NsM   GET /explicit-content-length HTTP/1.1
Host: localhost
Connection: close

R.   s   Content-Lengths   Transfer-Encoding(   R   R|   R   R.   R   RC   RS   R/   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_explicit_content_length  s
    c         C  su   |  j    } | j d  t | d |  j |  j } t r^ | j d t  | j d d  n | j d |  j  d  S(   NsG   GET /no-content-length HTTP/1.1
Host: localhost
Connection: close

R.   s   Content-Lengths   Transfer-EncodingRJ   (	   R   R|   R   R.   R   R   RC   R/   RS   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_no_content_length  s    c         C  s   |  j    } | j d  t | d |  j |  j |  j } t r | j d t  | j d d  | j |  j |  j |  j g k s t	 | j   n | j d t
 d	   d  S(
   NsM   GET /no-content-length-twice HTTP/1.1
Host: localhost
Connection: close

R.   s   Content-Lengths   Transfer-EncodingRJ   i   i   i
   i   (   R   R|   R   R.   R   R   RC   R/   R0   R   RF   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_no_content_length_twice  s    #3(   R   R   R.   R   RF   R   RS   Rb   R   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   			
t   HttpsTestCasec           B  sk   e  Z e j j e j j e  d   Z e j j e j j e  d  Z d   Z	 d d d  Z d   Z RS(   s   test_server.crts   test_server.keyc         C  s4   t  j |  j d f | d |  j d |  j |  _ d  S(   Ni    t   certfilet   keyfile(   R
   R_   R`   R   R   Ra   (   R5   Rb   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRc     s    t   GETc         K  s   d d  l  } |  j   } | j |  } | j d d  } | j d |  | d  k	 r | j d t |   | j |  | j d  d  k r | | d <q n | j d  | j   z t	 | |  SWd  | j
   | j
   | j
   Xd  S(   NiRw   i   s    %s / HTTP/1.1
Host: localhost
s   Content-Length: %s

R.   s   
(   t   sslR   t   wrap_socketR   R|   R-   R   R@   t   flushR   R   (   R5   t   methodt	   post_bodyR~   R   t   raw_sockt   sockR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s"    


c         C  sD   | d d k s  t  | d   | d d g  | d j d  g S(	   Ns   wsgi.url_schemet   httpss   200 OKs   Content-Types
   text/plains
   wsgi.inputi
   (   s   Content-Types
   text/plain(   R   R"   (   R5   t   environR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s     N(   R   R   t   osR   RO   t   dirnamet   __file__R   R   Rc   R-   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s
   !!	t   create_default_contextt   HttpsSslContextTestCasec           B  s   e  Z d    Z RS(   c         C  s]   d d l  m } |   } | j d |  j d |  j  t j |  j d f | d | |  _ d  S(   Ni(   t   _create_unverified_contextR   R   i    t   ssl_context(	   t
   gevent.sslR   t   load_cert_chainR   R   R
   R_   R`   Ra   (   R5   Rb   R   t   context(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRc     s
    	(   R   R   Rc   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   t	   TestHttpsc           B  s,   e  Z e e d   r* d   Z d   Z n  RS(   R   c         C  s/   |  j  d d d d  } |  j | j d  d  S(   NR   t   POSTR   t   abc(   R   R   R.   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_012_ssl_server#  s    c         C  s#   |  j    } |  j | j d  d  S(   NRK   (   R   R   R.   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_013_empty_return'  s    (   R   R   R<   R	   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   	t   TestHttpsWithContextc           B  s   e  Z RS(    (   R   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   ,  s   t   TestInternationalc           B  s    e  Z d Z d    Z d   Z RS(   c         C  sZ   d } t  r | j d  } n  |  j | d |  |  j | d d  | d d	 g  g  S(
   Ns   /приветs   latin-1R   t   QUERY_STRINGsC   %D0%B2%D0%BE%D0%BF%D1%80%D0%BE%D1%81=%D0%BE%D1%82%D0%B2%D0%B5%D1%82s
   200 PASSEDs   Content-Types
   text/plain(   s   Content-Types
   text/plain(   R   R   R   (   R5   R   R   t
   path_bytes(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   2  s    c      
   C  sQ   |  j    } | j d j d d   t | j   d d d t d d d	 d
 d  S(   Ns   GET /%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82?%D0%B2%D0%BE%D0%BF%D1%80%D0%BE%D1%81=%D0%BE%D1%82%D0%B2%D0%B5%D1%82 HTTP/1.1
Host: localhost
Connection: close

s   
s   
R1   t   PASSEDR0   R.   RK   RS   i    (   R   t   sendallR   R   R   R/   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   =  s    N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  /  s   	t"   TestNonLatin1HeaderFromApplicationc           B  sD   e  Z e Z d Z d  Z e Z d   Z	 d   Z
 d   Z d   Z RS(   s   Ὂ3c         C  s    t  t |   j   g  |  _ d  S(   N(   Ro   R  Rh   t   errors(   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRh   N  s    c         C  s    g  |  _  t t |   j   d  S(   N(   R  Ro   R  Rr   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRr   R  s    	c         C  sK   y  | d d d |  j  f g  Wn$ |  j j t j   d     n Xg  S(   Ns
   200 PASSEDs   Content-Types
   text/plains   Custom-Headeri   (   s   Content-Types
   text/plain(   RA   R  Rj   t   syst   exc_info(   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   V  s    c         C  s   |  j    } |  j   | j d  |  j r t | j   d d d d |  j d t j  |  j	 t
 |  j  d  |  j d \ } } |  j | t  n5 t | j   d d	 d d
 |  j	 t
 |  j  d  d  S(   Ns   GET / HTTP/1.1

R2   i  R1   s   Internal Server Errort
   where_typei   i    i   R  (   R   t   expect_one_errorR  t   should_errorR   R   t   assert_errorR
   t   SecureEnvironR   R   R  t   assertIsInstancet   UnicodeError(   R5   R   R   t   v(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   a  s    
	N(   R   R   R/   t   error_fatalR-   R   RA   R   R  Rh   Rr   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  G  s   			t)   TestNonLatin1UnicodeHeaderFromApplicationc           B  s   e  Z d  Z e Z RS(   u   Ὂ3(   R   R   RA   R   R  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  p  s   t   TestInputReadlinec           B  s    e  Z d Z d    Z d   Z RS(   c         C  s   | d } g  } xR t  rd | j   } | s/ Pn  t rD | j d  n | } | j t |  d  q W| d g   t r g  | D] } | j d  ^ q S| S(   Ns
   wsgi.inputRD   R)   s	   200 hello(   R   R   R   R   Rj   R#   RG   (   R5   R   R   t   inputR   R   t   l(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    
	c         C  sS   |  j    } d } | j d t |  | f  | j   t | d d d d d  S(   Ns   hello

world
123sM   POST / HTTP/1.1
Host: localhost
Connection: close
Content-Length: %s

%sR1   t   helloR.   s   'hello\n' '\n' 'world\n' '123' (   R   R|   R   R   R   (   R5   R   t   content(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    	
N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  x  s   	t   TestInputIterc           B  s   e  Z d    Z RS(   c         C  s   | d } g  } xJ | D]B } | s' Pn  t  r< | j d  n | } | j t |  d  q W| d g   t  r g  | D] } | j d  ^ qw S| S(   Ns
   wsgi.inputRD   R)   s	   200 hello(   R   R   Rj   R#   RG   (   R5   R   R   R  R   R   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    
(   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   t   TestInputReadlinesc           B  s   e  Z d    Z RS(   c         C  s   | d } g  | j    D]! } t r2 | j d  n | ^ q } g  | D] } t |  d ^ qE } | d g   t r g  | D] } | j d  ^ q{ S| S(   Ns
   wsgi.inputRD   R)   s	   200 hello(   t	   readlinesR   R   R#   RG   (   R5   R   R   R  R  R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s
    
4#(   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   t
   TestInputNc           B  s    e  Z d Z d    Z d   Z RS(   c         C  s"   | d j  d  | d g   g  S(   Ns
   wsgi.inputi   s   200 OK(   R"   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s   |  j    d  S(   N(   R   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   	t	   TestErrorc           B  s)   e  Z e   Z e Z d    Z d   Z RS(   c         C  s   t  j d  |  _ |  j  d  S(   Ns   TestError.application(   Rg   t   ExpectedExceptionR   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s4   |  j    |  j d d  |  j t j |  j  d  S(   NR2   i  (   R  R   R  Rg   R  R   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    
(   R   R   R   R   R/   R  Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   		t   TestError_after_start_responsec           B  s   e  Z d    Z RS(   c         C  s/   t  j d  |  _ | d d g  |  j  d  S(   Ns*   TestError_after_start_response.applications   200 OKs   Content-Types
   text/plain(   s   Content-Types
   text/plain(   Rg   R  R   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    (   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   t   TestEmptyYieldc           B  s    e  Z e d     Z d   Z RS(   c         c  s   | d d g  d Vd Vd  S(   Ns   200 OKs   Content-Types
   text/plainRK   (   s   Content-Types
   text/plain(    (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  sw   |  j    j d d  } | j d  t r4 g  } n t } t | d d d | | j   } |  j | d d |  d  S(   NRw   i   s6   GET / HTTP/1.1
Host: localhost
Connection: close

R.   RK   R0   s   got garbage: %r(   R   R   R|   R   R/   R   R"   R   (   R5   R   R0   t   garbage(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_err  s    	(   R   R   R   Rb   R"  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s   t   TestFirstEmptyYieldc           B  s    e  Z e d     Z d   Z RS(   c         c  s   | d d g  d Vd Vd  S(   Ns   200 OKs   Content-Types
   text/plainRK   R  (   s   Content-Types
   text/plain(    (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s}   |  j    j d d  } | j d  t r7 d g } n t } t | d d d | | j   } |  j | d k d |  d  S(	   NRw   i   s6   GET / HTTP/1.1
Host: localhost
Connection: close

R  R.   R0   RK   s   got garbage: %r(   R   R   R|   R   R/   R   R"   R   (   R5   R   R0   R!  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR"    s    (   R   R   R   Rb   R"  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR#    s   t   TestEmptyYield304c           B  s    e  Z e d     Z d   Z RS(   c         c  s   | d g   d Vd Vd  S(   Ns   304 Not modifiedRK   (    (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  sh   |  j    j d d  } | j d  t | d d d d d t | j   } |  j | d d	 |  d  S(
   NRw   i   s6   GET / HTTP/1.1
Host: localhost
Connection: close

R2   i0  R.   RK   R0   s   got garbage: %r(   R   R   R|   R   R/   R"   R   (   R5   R   R!  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR"  
  s
    (   R   R   R   Rb   R"  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR$    s   t   TestContentLength304c           B  s    e  Z d Z d    Z d   Z RS(   c         C  sK   y | d d g  Wn$ t  k
 r: } | d g   | j SXt  d   d  S(   Ns   304 Not modifieds   Content-Lengtht   100s
   200 Raiseds)   start_response did not fail but it should(   s   Content-LengthR&  (   R   R9   (   R5   R   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c      
   C  st   |  j    j d d  } | j d  d } t | d d d d d	 | d
 t | j   } |  j | d d |  d  S(   NRw   i   s6   GET / HTTP/1.1
Host: localhost
Connection: close

sG   Invalid Content-Length for 304 response: '100' (must be absent or zero)R2   i   R1   t   RaisedR.   R0   RK   s   got garbage: %r(   R   R   R|   R   R/   R"   R   (   R5   R   R.   R!  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR"    s    "N(   R   R   R-   R   Rb   R"  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR%    s   		t   TestBody304c           B  s    e  Z d Z d    Z d   Z RS(   c         C  s   | d g   d g S(   Ns   304 Not modifiedR.   (    (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   *  s    c         C  so   |  j    j d d  } | j d  y t |  Wn) t k
 r^ } |  j t |  d  n Xt d   d  S(   NRw   i   s6   GET / HTTP/1.1
Host: localhost
Connection: close

s"   The 304 response must have no bodys   AssertionError must be raised(   R   R   R|   R   R   R   RF   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR"  .  s    N(   R   R   R-   R   Rb   R"  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR(  '  s   	t   TestWrite304c           B  s&   e  Z d Z d Z d    Z d   Z RS(   c         C  sJ   | d g   } t  |  _ y | d  Wn t k
 rE t |  _   n Xd  S(   Ns   304 Not modifiedR.   (   R/   t   error_raisedR   R   (   R5   R   R   R|   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   =  s    		c         C  s}   |  j    j d d  } | j d  |  j t   } t |  Wd  QX| j } |  j t |  d  |  j	 |  j
 d  d  S(   NRw   i   s6   GET / HTTP/1.1
Host: localhost
Connection: close

s"   The 304 response must have no bodys   write() must raise(   R   R   R|   t   assertRaisesR   R   R   R   RF   R   R*  (   R5   R   t   excR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR"  F  s    	N(   R   R   R-   R   R*  Rb   R"  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR)  9  s   		t   TestEmptyWritec           B  s   e  Z e d     Z RS(   c         C  s*   | d d g  } | d  | d  g  S(   Ns   200 OKs   Content-Types
   text/plainRK   (   s   Content-Types
   text/plain(    (   R   R   R|   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   R  s    

(   R   R   R   Rb   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR-  P  s   t   BadRequestTestsc           B  s/   e  Z d Z d Z d    Z d   Z d   Z RS(   c         C  s.   |  j  | d |  j  | d d g  d g S(   NRM   s   200 OKs   Content-Types
   text/plainR  (   s   Content-Types
   text/plain(   R   RS   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   _  s    c         C  sI   d |  _  |  j   j d d  } | j d |  j   t | d d d  S(	   Ns   -100Rw   i   s7   GET / HTTP/1.1
Host: localhost
Content-Length: %s

R2   i   i  (   i   i  (   RS   R   R   R|   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_negative_content_lengthd  s    	c         C  sI   d |  _  |  j   j d d  } | j d |  j   t | d d d  S(	   NR   Rw   i   s7   GET / HTTP/1.1
Host: localhost
Content-Length: %s

R2   i   i  (   i   i  (   RS   R   R   R|   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_illegal_content_lengthj  s    	N(   R   R   R-   R   RS   Rb   R/  R0  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR.  Z  s
   		t   ChunkedInputTestsc           B  s}   e  Z d  Z d Z d   Z d d  Z d d  Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z RS(   RK   c         C  s   | d } g  } | d } | d k rA | j  d  } | g } nb | d k rn xS | D] } | j |  qT Wn5 | d k r | j  d  | j d  n t d	   | d
 d g  | S(   Ns
   wsgi.inputR   s   /short-readi
   s   /liness   /pingi   t   pongs   bad paths   200 OKs   Content-Types
   text/plain(   s   Content-Types
   text/plain(   R"   Rj   t   RuntimeError(   R5   R   R   R  R   t   pit   dR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   u  s    

c         C  s(   | d  k r |  j } n  t | d | S(   Nt   dirt(   R-   R6  t   chunk_encode(   R5   R0   R6  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR7    s    c      	   C  s+   |  j  d d d d d d d d g d	 | S(
   NR   s    is RJ   s   
lines    2s   
t   line3RK   R6  (   R7  (   R5   R6  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR.     s    c         C  s!   | j  d  t | d d d  S(   Ns   GET /ping HTTP/1.1

R.   R2  (   R|   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   ping  s    c         C  sZ   y |  j  |  WnB t k
 rU t r-   n  |  j   j d d  } |  j  |  n Xd  S(   NRw   i   (   R9  R   R   R   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   ping_if_possible  s    c         C  sv   |  j    } d | } |  j   } | j d d  } | j |  t | d d |  j |  | j   | j   d  S(   NsN   POST /short-read HTTP/1.1
transfer-encoding: Chunked
Content-Length:1000

Rw   i   R.   s
   this is ch(   R.   R   R   R|   R   R:  R   (   R5   R.   t   reqR   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt#   test_short_read_with_content_length  s    

c         C  s\   |  j    } d | } |  j   j d d  } | j |  t | d d |  j |  d  S(   NsK   POST /short-read HTTP/1.1
transfer-encoding: Chunked
Content-Length:0

Rw   i   R.   s
   this is ch(   R.   R   R   R|   R   R:  (   R5   R.   R;  R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt(   test_short_read_with_zero_content_length  s    
c         C  s\   |  j    } d | } |  j   j d d  } | j |  t | d d |  j |  d  S(   Ns9   POST /short-read HTTP/1.1
transfer-encoding: Chunked

Rw   i   R.   s
   this is ch(   R.   R   R   R|   R   R:  (   R5   R.   R;  R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_short_read  s    
c         C  s   |  j  d d  } d | } |  j   j d d  } | j |  y t | d d WnB t k
 r } t |  j d  r t s t	 d	  d  Sn    n X|  j
 |  d  S(
   NR6  s   ; here is dirt blas3   POST /ping HTTP/1.1
transfer-encoding: Chunked

Rw   i   R.   R2  s   Unexpected code: 400t   ChunkedNotImplementedWarning(   R.   R   R   R|   R   R   RF   t
   startswithR   R   R:  (   R5   R.   R;  R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt	   test_dirt  s    

c         C  sn   |  j    } d t |  } | j d  } | | 7} |  j   j d d  } | j |  t | d d d  S(   NsH   POST /lines HTTP/1.1
Content-Length: %s
transfer-encoding: Chunked

s   latin-1Rw   i   R.   s   this is chunked
line 2
line3(   R.   R   RG   R   R   R|   R   (   R5   R.   R;  R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_chunked_readline  s    
c         C  s   |  j    d } d | } |  j   } | j d d d d  } | j |  | j   | j   ~ ~ t j   j j   t j	 d  t
 j r d d  l } | j   t j	 d  t j   j j   | j   t j	 d  n  |  j t d	  d  S(
   Ns   4
this9   POST /short-read HTTP/1.1
transfer-encoding: Chunked

Rw   i   Ry   t   wbg{Gz?is1   unexpected end of file while parsing chunked data(   R  R   R   R|   R   Rs   t   get_hubt   loopt
   update_nowt   sleepRg   R   t   gct   collectR  t   IOError(   R5   R.   R;  R   R   RH  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_close_before_finished  s(    



	

N(   R   R   R6  R-   R   Rb   R7  R.   R9  R:  R<  R=  R>  RA  RB  RK  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR1  q  s   							
		
t   Expect100ContinueTestsc           B  s    e  Z d Z d    Z d   Z RS(   c         C  s   t  | d  } | d k r6 | d d d g  d g S| d	 j d
  } | | d	 j | d
  7} | d d t t |   f d g  | g S(   NRM   i   s   417 Expectation Faileds   Content-Lengtht   7s   Content-Types
   text/plaint   failures
   wsgi.inputi   s   200 OK(   s   Content-LengthRM  (   s   Content-Types
   text/plain(   s   Content-Types
   text/plain(   R!   R"   RF   R   (   R5   R   R   RS   t   text(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    %c         C  s   |  j    j d d  } | j d  y t | d d d d WnB t k
 r } t |  j d  r} t s} t d	  d  Sn    n X| j d
  t | d d t | d d d  S(   NRw   i   sO   PUT / HTTP/1.1
Host: localhost
Content-length: 1025
Expect: 100-continue

R2   i  R.   RN  s   Unexpected code: 400t    100ContinueNotImplementedWarningsS   PUT / HTTP/1.1
Host: localhost
Content-length: 7
Expect: 100-continue

testingid   t   testing(	   R   R   R|   R   R   RF   R@  t   server_implements_100continueR   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_continue  s    
N(   R   R   R-   R   Rb   RS  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRL  
  s   	t   MultipleCookieHeadersTestc           B  s    e  Z d Z d    Z d   Z RS(   c         C  s9   |  j  | d d  |  j  | d d  | d g   g  S(   Nt   HTTP_COOKIEs   name1="value1"; name2="value2"t   HTTP_COOKIE2s   nameA="valueA"; nameB="valueB"s   200 OK(   R   (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   0  s    c         C  s?   |  j    j d d  } | j d j d d   t |  d  S(   NRw   i   s~   GET / HTTP/1.1
Host: localhost
Cookie: name1="value1"
Cookie2: nameA="valueA"
Cookie2: nameB="valueB"
Cookie: name2="value2"

s   
s   
(   R   R   R|   R   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   6  s    N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRT  ,  s   	t   TestLeakInputc           B  s8   e  Z d Z d Z d    Z d   Z d   Z d   Z RS(   c         C  s#   t  j |   d  |  _ d  |  _ d  S(   N(   RW   Rr   R-   t   _leak_wsgi_inputt   _leak_environ(   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRr   F  s    	c         C  st   | d } | d |  _  | |  _ | d k rB t j d  | d <n  d } | d d t t |   f d g  | g S(   NR   s
   wsgi.inputs   /leak-framei    t   _leakt   foobars   200 OKs   Content-Lengths   Content-Types
   text/plain(   s   Content-Types
   text/plain(   RX  RY  R  t	   _getframeRF   R   (   R5   R   R   R4  RO  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   K  s    
	%c         C  sN   |  j    j d d  } | j d  | j   } |  j | j d  |  d  S(   NRw   i   s%   GET / HTTP/1.0
Connection: close

s   HTTP/1.1 200 OK(   R   R   R|   R"   R   R@  (   R5   R   R5  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt!   test_connection_close_leak_simpleV  s    c         C  s^   |  j    j d d  } | j d  | j   } |  j | j d  |  |  j j d  d  S(   NRw   i   s/   GET /leak-frame HTTP/1.0
Connection: close

s   HTTP/1.1 200 OKRZ  (   R   R   R|   R"   R   R@  RY  R}   (   R5   R   R5  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt    test_connection_close_leak_frame\  s
    N(	   R   R   R-   RX  RY  Rr   Rb   R]  R^  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRW  A  s   			t   TestHTTPResponseSplittingc           B  s_   e  Z d Z d  Z d	 Z d Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z RS(
   s   200 OKc         C  s2   t  j |   d  |  _ t j |  _ t j |  _ d  S(   N(   RW   Rh   R-   t	   start_excR_  R   R   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRh   l  s    	c         C  s   t  j |   d  |  _ d  S(   N(   RW   Rr   R-   R`  (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRr   r  s    c         C  sC   y | |  j  |  j  Wn t k
 r5 } | |  _ n
 Xd  |  _ d S(   N(    (   R   R   R4   R`  R-   (   R5   R   R   t   e(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   v  s    	c         C  sT   |  j    } | j d  | j   |  j |  j t  |  j |  j j d |  d  S(   Ns#   GET / HTTP/1.0
Host: localhost

i    (   R   R|   R"   R  R`  t
   ValueErrorR   R9   (   R5   t   messageR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   _assert_failure  s
    
c         C  s   d |  _  |  j d  d  S(   Ns0   200 OK
Connection: close
Content-Length: 0

s$   carriage return or newline in status(   R   Rd  (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_newline_in_status  s    	c         C  s   d g |  _  |  j d  d  S(   Nt   Tests   Hi
Connection: closes*   carriage return or newline in header value(   Rf  s   Hi
Connection: close(   R   Rd  (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_newline_in_header_value  s    c         C  s   d g |  _  |  j d  d  S(   Ns   Test
t   His)   carriage return or newline in header name(   s   Test
Rh  (   R   Rd  (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_newline_in_header_name  s    N(    (   R   R   R-   R   R   R   R`  Rh   Rr   Rb   Rd  Re  Rg  Ri  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR_  c  s   							t   TestInvalidEnvironc           B  s    e  Z d Z d    Z d   Z RS(   c         C  sq   x] | j    D]O \ } } | d k s4 | j d  r | d k r\ t d | | f   q\ q q W| d g   g  S(   NRM   R   t   HTTP_t	   HTTP_HOSTs&   Unexpected environment variable: %s=%rs   200 OK(   RM   R   (   t   itemsR@  R   (   R5   R   R   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s     c         C  sJ   |  j    } | j d  t |  |  j    } | j d  t |  d  S(   Ns#   GET / HTTP/1.0
Host: localhost

s#   GET / HTTP/1.1
Host: localhost

(   R   R|   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    
N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRj    s   	t   TestInvalidHeadersDroppedc           B  s    e  Z d Z d    Z d   Z RS(   c         C  s!   |  j  d |  | d g   g  S(   Nt   HTTP_X_AUTH_USERs   200 OK(   t   assertNotIn(   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s'   |  j    } | j d  t |  d  S(   Ns$   GET / HTTP/1.0
x-auth_user: bob

(   R   R|   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    N(   R   R   R-   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRn    s   	t   Handlerc           B  s   e  Z d    Z RS(   c         C  s   |  j  j d  } | d d k rq | |  j  j d  7} | j   d k r] |  j j d  n |  j d |  d  S| |  j  j   Sd  S(	   Ni   i    t   <i   s   <policy-file-request/>t   HELLOs   Invalid request: %rRr  (   t   rfileR"   R   R	   R  t	   log_errorR-   R   (   R5   R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   read_requestline  s    (   R   R   Rv  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRq    s   t   TestHandlerSubclassc           B  s)   e  Z d Z d    Z d   Z d   Z RS(   c         C  s   | d g   g  S(   Ns   200 OK(    (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s(   t  j |  j d f | d t |  _ d  S(   Ni    t   handler_class(   R
   R_   R`   Rq  Ra   (   R5   Rb   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRc     s    c         C  s   |  j    } | j d  | j   |  j | j   d  |  j    } | j d  | j   t |  |  j    } | j d  | j   |  j | j   d  d  S(   Ns   <policy-file-request/> Rs  s6   GET / HTTP/1.1
Host: localhost
Connection: close

s   <policy-file-XXXuest/> RK   (   R   R|   R   R   R"   R   (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    



N(   R   R   R-   R   Rb   Rc   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRw    s   		t   TestErrorAfterChunkc           B  s&   e  Z d Z e d     Z d   Z RS(   c         c  s(   | d d g  d Vt  j d   d  S(   Ns   200 OKs   Content-Types
   text/plainR  Ry  (   s   Content-Types
   text/plain(   Rg   R  (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  sV   |  j    j d d  } |  j   | j d  |  j t t |  |  j t j	  d  S(   NRw   i   s;   GET / HTTP/1.1
Host: localhost
Connection: keep-alive

(
   R   R   R  R|   R+  Rb  R   R  Rg   R  (   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s
    
N(   R   R   R-   R   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRy    s   c         C  s\   | d  k r d } n  d } x: |  D]2 } d t |  | | f } | | j d  7} q" W| S(   NRK   s
   %x%s
%s
RD   (   R-   R   RG   (   R0   R6  t   bt   cR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR7    s    	t   TestInputRawc           B  s   e  Z d e d   Z e r' d   Z n  d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C  sg   t  | t  r$ t |  } t } n' t  | t  rK t rK | j d  } n  t t |  d | d | S(   NRD   RS   t   chunked_input(	   RE   RN   R7  R   RF   R   RG   R   R   (   R5   R&   RS   R}  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt
   make_input  s    	c         G  sA   t  | t  r! | j d  } n  t t |   j | | |  d  S(   NRD   (   RE   RF   RG   Ro   R|  R   (   R5   R&   t   expectedR9   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR     s    c         C  s,   |  j  d d d } |  j t | j  d  S(   Nt   1RS   i   (   R~  R+  RJ  R"   (   R5   t   i(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_short_post  s    c         C  s/   |  j  d d d } |  j t | j d  d  S(   NR  RS   i   (   R~  R+  RJ  R"   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt    test_short_post_read_with_length  s    c         C  s,   |  j  d d d } |  j t | j  d  S(   NR  RS   i   (   R~  R+  RJ  R   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_short_post_readline  s    c         C  s5   |  j  d d d } | j   } |  j | d  d  S(   Nt   12RS   i   (   R~  R"   R   (   R5   R  R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt	   test_post   s    c         C  s8   |  j  d d d } | j d  } |  j | d  d  S(   NR  RS   i   i
   (   R~  R"   R   (   R5   R  R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_post_read_with_length%  s    c         C  s8   |  j  d d d g  } | j   } |  j | d  d  S(   NR  t   2RK   R  (   R~  R"   R   (   R5   R  R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_chunked*  s    c         C  s;   |  j  d d d g  } | j d  } |  j | d  d  S(   NR  R  RK   i
   R  (   R~  R"   R   (   R5   R  R&   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_chunked_read_with_length/  s    c         C  s,   |  j  d d g  } |  j t | j  d  S(   NR  R  (   R~  R+  RJ  R"   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_chunked_missing_chunk4  s    c         C  s/   |  j  d d g  } |  j t | j d  d  S(   NR  R  i
   (   R~  R+  RJ  R"   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt+   test_chunked_missing_chunk_read_with_length8  s    c         C  s,   |  j  d d g  } |  j t | j  d  S(   NR  R  (   R~  R+  RJ  R   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt#   test_chunked_missing_chunk_readline<  s    c         C  s,   |  j  d d t } |  j t | j  d  S(   Ns   2
1R}  (   R~  R   R+  RJ  R"   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_chunked_short_chunk@  s    c         C  s/   |  j  d d t } |  j t | j d  d  S(   Ns   2
1R}  i   (   R~  R   R+  RJ  R"   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt)   test_chunked_short_chunk_read_with_lengthD  s    c         C  s,   |  j  d d t } |  j t | j  d  S(   Ns   2
1R}  (   R~  R   R+  RJ  R   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt!   test_chunked_short_chunk_readlineH  s    c         C  s  t  d  d } d t j d } | d 7} | | } d } d } t  d	 | d
 t |   t | d  r |  j | j   d  n  t r t r |  j	 t
 t |  j |  n  |  j | d | } |  j | j   d  |  j | j |  d  |  j | j |  |  |  j | | d t |  d } |  j | j   d  |  j | j |  d  |  j | j |  |  |  j | j |  d  d  S(   Ns   BEGIN 32bits
   asdf
ghij
R   i
   s   
s   qjk
i   i ʚ;t   Ns   Data lent
   bit_lengthi#   RS   s   asdf
s   ghij
i   t   qI    (   R   R
   t   MAX_REQUEST_LINER   R<   R   R  R   R   R+  t   OverflowErrorR   R   R~  (   R5   R&   t	   long_datat   partial_datat   nR  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_32bit_overflowL  s*    


#N(   R   R   R-   R/   R~  R   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR|    s"   													t   Test414c           B  s    e  Z e d     Z d   Z RS(   c         C  s   t  d   d  S(   Ns   should not get there(   R   (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb   p  s    c         C  sD   |  j    } d d } | j d | j d   t | d d d  S(   NR   i N  s"   GET /%s HTTP/1.0
Hello: world

s   latin-1R2   i  (   R   R|   RG   R   (   R5   R   t   longline(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR   t  s    
(   R   R   R   Rb   R   (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  n  s   t   TestLoggingc           B  sQ   e  Z d  e f d     YZ d   Z e d    Z d   Z d   Z d   Z	 RS(   t   Loggerc           B  s5   e  Z d Z d Z d Z d    Z d   Z d   Z RS(   c         C  s   | | f |  _  d  S(   N(   t   logged(   R5   t   levelt   msg(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR]     s    c         C  s   | |  _  d  S(   N(   t   accessed(   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   access  s    c         C  s   |  j  S(   N(   t   thing(   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt	   get_thing  s    N(	   R   R   R-   R  R  R  R]   R  R  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  ~  s   		c         C  s
   |  j    S(   N(   R  (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR\     s    c         C  s   | d d g  d g S(   Ns   200 OKs   Content-Types
   text/plainR  (   s   Content-Types
   text/plain(    (   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s{   |  j  t |  j j t j   |  j j j d  |  j j j d  |  j |  j j j	 d  |  j |  j j j
 d  d  S(   NR  R|   i   (   i   R|   (   R   RE   Ra   R]   R
   t   LoggingLogAdapterR  R|   R   R  R  (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_proxy_methods_on_log  s
    c         C  sW   d |  j  j _ |  j |  j  j j   d  |  j  j ` |  j |  j  j j   d   d  S(   Ni*   (   Ra   R]   R  R   R  R-   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_set_attributes  s    c         C  sM   |  j    |  j j j d } |  j d | k |  |  j d | k |  d  S(   Ni   s   "GET / HTTP/1.1" 200 s   
(   R   Ra   R]   R  R   (   R5   R  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_status_log  s    
(
   R   R   R   R  R\   R   Rb   R  R  R  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR  {  s   				t   TestEnvironc           B  sM   e  Z d Z d    Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   c         C  s)   t  t |   j |  t j |  j _ d  S(   N(   Ro   R  Rc   R
   R  Ra   t   environ_class(   R5   Rb   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRc     s    c         C  s'   |  j  | t j  | d d g  g  S(   Ns   200 OKs   Content-Types
   text/plain(   s   Content-Types
   text/plain(   R  R
   R  (   R5   R   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyRb     s    c         C  s   |  j    d  S(   N(   R   (   R5   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt!   test_environ_is_secure_by_default  s    c         C  sk  t  j   } |  j d t |   |  j d t |   d | d <|  j d t |   |  j d t |   t | _ |  j t i d d 6 t |   |  j t i d d 6 t |   | ` d | _ |  j t i d d 6 t |   |  j t i d d 6 t |   d | _ |  j t i d d 6 t |   |  j t i d d 6 t |   | ` d  S(	   Ns'   <pywsgi.SecureEnviron dict (keys: 0) atR   R   s'   <pywsgi.SecureEnviron dict (keys: 1) ats   missing values   <MASKED>(   s   missing value(   R   (	   R
   R  t   assertInR#   RF   R/   t   secure_reprR   t   whitelist_keys(   R5   R   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_default_secure_repr  s"    
	##	##	##c         C  s  d t  j f d     Y} |   } |  j | j  t | _ |  j | j  |  j t i   t |   |  j t	 i   t	 |   t
 | _ d | _ d | d <|  j t i d d 6 t |   |  j t	 i d d 6 t	 |   ~ ~ d d  l } | j   d  S(   Nt   EnvironClassc           B  s   e  Z d  Z RS(   (    (   R   R   t	   __slots__(    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   R   i   i(   R   (   R
   R  R   R  R/   t   default_secure_reprR   R   RF   R#   R   t   default_whitelist_keysRH  RI  (   R5   R  R   RH  (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_override_class_defaults  s     				
## c         C  s:   x3 t  j t  j f D] } |  j |   j   |  q Wd  S(   N(   R
   t   EnvironR  R  t   copy(   R5   RR   (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_copy_still_secure  s    c   	      C  s  d d  l  } d d  l } x t j t j f D] } i d d 6} | |  } |  j | |  |  j | |  |  j | |  xe t d | j d  D]M } | j	 | |  } |  j
 d |  | j |  } |  j t |  t  q W|  j | j	 |  | j	 |   q+ Wd  S(   NiR   R   i    i   R  (   t   picklet   jsonR
   R  R  R  R   R   t   HIGHEST_PROTOCOLt   dumpsRp  t   loadst   typet   dict(	   R5   R  R  RR   t   bltinR   t   protocolt   env_dumpt   loaded(    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   test_pickle_copy_returns_dict  s    N(   R   R   R-   R   Rc   Rb   R  R  R  R  R  (    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyR    s   						t   __main__(i   t
   __future__R    Rs   R   t	   patch_allR/   t   urllib.parseR   t   ImportErrort   urlparseR   R  t	   cStringIOR   t   ioR   Rk   t   wsgiref.validateR   t   gevent.testingRQ  Rg   R   R   R	   R
   t   gevent.pywsgiR   RM   R   R   R   R   RR  t   argvt   DEBUGRL   R4   R   R    R'   R   R(   R"   R   RW   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   HAVE_SSLCONTEXTR   R   R   R  R  R  R  R  R  R  R  R  R   R#  R$  R%  R(  R)  R-  R.  R1  RL  RT  RW  R_  Rj  Rn  t   WSGIHandlerRq  Rw  Ry  R-   R7  t   BaseTestCaseR|  R  R  R  R   t   main(    (    (    sR   /var/www/syncserver/local/lib/python2.7/site-packages/gevent/tests/test__pywsgi.pyt   <module>   s   	

		Y	eC$U3$)

""0i5`