Ticket #343: large_response_test.patch

File large_response_test.patch, 2.3 KB (added by gawel, 3 years ago)
  • tests/test_exactproxy.txt

     
    3838        'GET', 
    3939        '/testform', 
    4040        '', 
    41         {'Host': 'example.com:80'}) 
     41        {'Host': 'example.com:80', 'Content-Length': 0}) 
    4242    Called httplib.HTTPConnection.getresponse() 
    4343    Called httpresponse.getheader('content-length') 
    4444    Called httpresponse.read() 
     
    5555        'GET', 
    5656        '/testform', 
    5757        '', 
    58         {'Host': 'example.com:80'}) 
     58        {'Host': 'example.com:80', 'Content-Length': 0}) 
    5959    Called httplib.HTTPConnection.getresponse() 
    6060    Called httpresponse.getheader('content-length') 
    6161    Called httpresponse.read() 
     
    7676        'GET', 
    7777        '/testform', 
    7878        '', 
    79         {'Host': 'example.com:80'}) 
     79        {'Host': 'example.com:80', 'Content-Length': 0}) 
    8080    Called httplib.HTTPConnection.getresponse() 
    8181    Called httpresponse.getheader('content-length') 
    8282    Called httpresponse.read() 
     
    102102        'POST', 
    103103        '/testform?test=result', 
    104104        'var=value&var2=value2', 
    105         {'Host': 'differenthost.com'}) 
     105        {'Host': 'differenthost.com', 'Content-Length': 21}) 
    106106    Called httplib.HTTPConnection.getresponse() 
    107107    Called httpresponse.getheader('content-length') 
    108108    Called httpresponse.read() 
    109109    Called httplib.HTTPConnection.close() 
     110 
     111A large response:: 
     112 
     113    >>> from wsgiproxy.exactproxy import BLOCK_SIZE 
     114    >>> set_response('200 Ok', h(content_type='application/unknow'), 'chunk '*BLOCK_SIZE) 
     115    >>> req = Request.blank('http://download-example.com/testfile') 
     116    >>> res = send(req) 
     117    Called httplib.HTTPConnection('download-example.com:80') 
     118    Called httplib.HTTPConnection.request( 
     119        'GET', 
     120        '/testfile', 
     121        '', 
     122        {'Host': 'download-example.com:80', 'Content-Length': 0}) 
     123    Called httplib.HTTPConnection.getresponse() 
     124    Called httpresponse.getheader('content-length') 
     125    Called httpresponse.read() 
     126    Called httplib.HTTPConnection.close() 
     127    >>> len(res.body) > BLOCK_SIZE 
     128    True 
     129    >>> print res # doctest: +ELLIPSIS 
     130    200 Ok 
     131    content-type: application/unknow 
     132    Content-Length: 393216 
     133    <BLANKLINE> 
     134    chunk chunk chunk chunk chunk chunk chunk ... 
     135