@@ -976,6 +976,9 @@ def test_status_map(statuses, expected):
976
976
if expected < 400 :
977
977
self .assert_ ('x-works' in res .headers )
978
978
self .assertEquals (res .headers ['x-works' ], 'yes' )
979
+ self .assert_ ('accept-ranges' in res .headers )
980
+ self .assertEquals (res .headers ['accept-ranges' ], 'bytes' )
981
+
979
982
test_status_map ((200 , 404 , 404 ), 200 )
980
983
test_status_map ((200 , 500 , 404 ), 200 )
981
984
test_status_map ((304 , 500 , 404 ), 304 )
@@ -1247,7 +1250,7 @@ def test_best_response_sets_etag(self):
1247
1250
resp = controller .best_response (req , [200 ] * 3 , ['OK' ] * 3 , ['' ] * 3 ,
1248
1251
'Object' , etag = '68b329da9893e34099c7d8ad5cb9c940' )
1249
1252
self .assertEquals (resp .etag , '68b329da9893e34099c7d8ad5cb9c940' )
1250
-
1253
+
1251
1254
def test_proxy_passes_content_type (self ):
1252
1255
with save_globals ():
1253
1256
req = Request .blank ('/a/c/o' , environ = {'REQUEST_METHOD' : 'GET' })
@@ -2487,7 +2490,29 @@ def test_response_client_disconnect_attr(self):
2487
2490
self .assert_ (res .client_disconnect )
2488
2491
finally :
2489
2492
self .app .object_chunk_size = orig_object_chunk_size
2493
+
2494
+ def test_response_get_accept_ranges_header (self ):
2495
+ with save_globals ():
2496
+ req = Request .blank ('/a/c/o' , environ = {'REQUEST_METHOD' : 'GET' })
2497
+ self .app .update_request (req )
2498
+ controller = proxy_server .ObjectController (self .app , 'account' ,
2499
+ 'container' , 'object' )
2500
+ proxy_server .http_connect = fake_http_connect (200 , 200 , 200 )
2501
+ resp = controller .GET (req )
2502
+ self .assert_ ('accept-ranges' in resp .headers )
2503
+ self .assertEquals (resp .headers ['accept-ranges' ], 'bytes' )
2490
2504
2505
+ def test_response_head_accept_ranges_header (self ):
2506
+ with save_globals ():
2507
+ req = Request .blank ('/a/c/o' , environ = {'REQUEST_METHOD' : 'GET' })
2508
+ self .app .update_request (req )
2509
+ controller = proxy_server .ObjectController (self .app , 'account' ,
2510
+ 'container' , 'object' )
2511
+ proxy_server .http_connect = fake_http_connect (200 , 200 , 200 )
2512
+ resp = controller .HEAD (req )
2513
+ self .assert_ ('accept-ranges' in resp .headers )
2514
+ self .assertEquals (resp .headers ['accept-ranges' ], 'bytes' )
2515
+
2491
2516
def test_GET_calls_authorize (self ):
2492
2517
called = [False ]
2493
2518
@@ -2827,6 +2852,28 @@ def test_response_client_disconnect_attr(self):
2827
2852
finally :
2828
2853
self .app .object_chunk_size = orig_object_chunk_size
2829
2854
2855
+ def test_response_get_accept_ranges_header (self ):
2856
+ with save_globals ():
2857
+ proxy_server .http_connect = fake_http_connect (200 , 200 , body = '{}' )
2858
+ controller = proxy_server .ContainerController (self .app , 'account' ,
2859
+ 'container' )
2860
+ req = Request .blank ('/a/c?format=json' )
2861
+ self .app .update_request (req )
2862
+ res = controller .GET (req )
2863
+ self .assert_ ('accept-ranges' in res .headers )
2864
+ self .assertEqual (res .headers ['accept-ranges' ], 'bytes' )
2865
+
2866
+ def test_response_head_accept_ranges_header (self ):
2867
+ with save_globals ():
2868
+ proxy_server .http_connect = fake_http_connect (200 , 200 , body = '{}' )
2869
+ controller = proxy_server .ContainerController (self .app , 'account' ,
2870
+ 'container' )
2871
+ req = Request .blank ('/a/c?format=json' )
2872
+ self .app .update_request (req )
2873
+ res = controller .HEAD (req )
2874
+ self .assert_ ('accept-ranges' in res .headers )
2875
+ self .assertEqual (res .headers ['accept-ranges' ], 'bytes' )
2876
+
2830
2877
def test_PUT_metadata (self ):
2831
2878
self .metadata_helper ('PUT' )
2832
2879
@@ -3132,7 +3179,28 @@ def test_response_bytes_transferred_attr(self):
3132
3179
res .body
3133
3180
self .assert_ (hasattr (res , 'bytes_transferred' ))
3134
3181
self .assertEquals (res .bytes_transferred , 2 )
3135
-
3182
+
3183
+ def test_response_get_accept_ranges_header (self ):
3184
+ with save_globals ():
3185
+ proxy_server .http_connect = fake_http_connect (200 , 200 , body = '{}' )
3186
+ controller = proxy_server .AccountController (self .app , 'account' )
3187
+ req = Request .blank ('/a?format=json' )
3188
+ self .app .update_request (req )
3189
+ res = controller .GET (req )
3190
+ self .assert_ ('accept-ranges' in res .headers )
3191
+ self .assertEqual (res .headers ['accept-ranges' ], 'bytes' )
3192
+
3193
+ def test_response_head_accept_ranges_header (self ):
3194
+ with save_globals ():
3195
+ proxy_server .http_connect = fake_http_connect (200 , 200 , body = '{}' )
3196
+ controller = proxy_server .AccountController (self .app , 'account' )
3197
+ req = Request .blank ('/a?format=json' )
3198
+ self .app .update_request (req )
3199
+ res = controller .HEAD (req )
3200
+ res .body
3201
+ self .assert_ ('accept-ranges' in res .headers )
3202
+ self .assertEqual (res .headers ['accept-ranges' ], 'bytes' )
3203
+
3136
3204
def test_response_client_disconnect_attr (self ):
3137
3205
with save_globals ():
3138
3206
proxy_server .http_connect = fake_http_connect (200 , 200 , body = '{}' )
0 commit comments