]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
s3-tests: Object download response code test
authorKyle Marsh <kyle.marsh@dreamhost.com>
Tue, 26 Jul 2011 23:58:15 +0000 (16:58 -0700)
committerKyle Marsh <kyle.marsh@dreamhost.com>
Wed, 27 Jul 2011 22:01:13 +0000 (15:01 -0700)
If a client specifies a range when requesting an object the server should
respond with 206 Partial Content when answering a request to get an object,
not 200 OK.  It should also respond with only those bytes requested.

This commit introduces a test, test_ranged_request_response_code, that
checks those criteria.

s3tests/functional/test_s3.py

index bf6449bec7f3df2118074e7565634ed7407893e6..a93de4c1c8dd21c9567f2d3177779dbdf2fc50f5 100644 (file)
@@ -1545,3 +1545,21 @@ def test_atomic_dual_write_4mb():
 
 def test_atomic_dual_write_8mb():
     _test_atomic_dual_write(1024*1024*8)
+
+def test_ranged_request_response_code():
+    content = 'testcontent'
+
+    bucket = get_new_bucket()
+    key = bucket.new_key('testobj')
+    key.set_contents_from_string(content)
+
+    key.open('r', headers={'Range': 'bytes=4-7'})
+    status = key.resp.status
+    fetched_content = ''
+    for data in key:
+        fetched_content += data;
+    key.close()
+
+    eq(fetched_content, content[4:8])
+    eq(status, 206)
+