Mercurial > hg > FileServer
changeset 33:86b519dd8467
finish test and implementation
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 05 Mar 2012 14:08:31 -0800 |
parents | 0edb831061f5 |
children | aca8cb6bfd63 |
files | tests/test_fileapp.txt |
diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_fileapp.txt Mon Mar 05 14:06:00 2012 -0800 +++ b/tests/test_fileapp.txt Mon Mar 05 14:08:31 2012 -0800 @@ -29,7 +29,7 @@ 6L >>> req = Request.blank('/') >>> res = req.get_response(app) - >>> print res + >>> print res 200 OK Content-Type: text/plain; charset=UTF-8 Content-Length: 6 @@ -46,3 +46,25 @@ >>> req3.if_modified_since = res.last_modified >>> req3.get_response(app) <Response ... 304 Not Modified> + +We can even do Range requests:: + + >>> req = Request.blank('/') + >>> res = req.get_response(app) + >>> req2 = Request.blank('/') + >>> # Re-fetch the first 3 bytes: + >>> req2.range = (0, 3) + >>> res2 = req2.get_response(app) + >>> res2 + <Response ... 206 Partial Content> + >>> res2.body + 'hel' + >>> # Now, conditional range support: + >>> req3 = Request.blank('/') + >>> req3.if_range = res.etag + >>> req3.range = (0, 3) + >>> req3.get_response(app) + <Response ... 206 Partial Content> + >>> req3.if_range = 'invalid-etag' + >>> req3.get_response(app) + <Response ... 200 OK>