@@ -588,14 +588,29 @@ def test_range_get(self):
588588
589589 response = self .request (route , headers = {'Range' : 'bytes=--' })
590590 self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
591-
591+
592592 response = self .request (route , headers = {'Range' : 'bytes=' })
593593 self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
594594
595595 # multipart ranges (not supported currently)
596596 response = self .request (route , headers = {'Range' : 'bytes=1-2, 4-7' })
597597 self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
598598
599+ # empty file
600+ with open (os .path .join (self .tempdir_name , 'empty' ), 'wb' ):
601+ pass
602+ empty_path = self .base_url + '/empty'
603+
604+ response = self .request (empty_path , headers = {'Range' : 'bytes=0-512' })
605+ self .check_status_and_reason (response , HTTPStatus .OK , data = b'' )
606+
607+ response = self .request (empty_path , headers = {'Range' : 'bytes=-512' })
608+ self .check_status_and_reason (response , HTTPStatus .OK , data = b'' )
609+
610+ response = self .request (empty_path , headers = {'Range' : 'bytes=1-2' })
611+ self .assertEqual (response .getheader ('content-range' ), 'bytes */0' )
612+ self .check_status_and_reason (response , HTTPStatus .REQUESTED_RANGE_NOT_SATISFIABLE )
613+
599614 def test_head (self ):
600615 response = self .request (
601616 self .base_url + '/test' , method = 'HEAD' )
0 commit comments