@@ -544,6 +544,7 @@ def test_range_get(self):
544544 self .assertEqual (response .getheader ('accept-ranges' ), 'bytes' )
545545 self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
546546
547+ # valid ranges
547548 response = self .request (self .base_url + '/test' , headers = {'Range' : 'bytes=3-12' })
548549 self .assertEqual (response .getheader ('content-range' ), 'bytes 3-12/30' )
549550 self .assertEqual (response .getheader ('content-length' ), '10' )
@@ -559,6 +560,18 @@ def test_range_get(self):
559560 self .assertEqual (response .getheader ('content-length' ), '5' )
560561 self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [25 :])
561562
563+ response = self .request (self .base_url + '/test' , headers = {'Range' : 'bytes=29-29' })
564+ self .assertEqual (response .getheader ('content-range' ), 'bytes 29-29/30' )
565+ self .assertEqual (response .getheader ('content-length' ), '1' )
566+ self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [29 :])
567+
568+ # end > file size
569+ response = self .request (self .base_url + '/test' , headers = {'Range' : 'bytes=25-100' })
570+ self .assertEqual (response .getheader ('content-range' ), 'bytes 25-29/30' )
571+ self .assertEqual (response .getheader ('content-length' ), '5' )
572+ self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [25 :])
573+
574+ # invalid ranges
562575 response = self .request (self .base_url + '/test' , headers = {'Range' : 'bytes=100-200' })
563576 self .check_status_and_reason (response , HTTPStatus .REQUESTED_RANGE_NOT_SATISFIABLE )
564577
@@ -568,6 +581,9 @@ def test_range_get(self):
568581 response = self .request (self .base_url + '/test' , headers = {'Range' : 'bytes=wrong format' })
569582 self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
570583
584+ response = self .request (self .base_url + '/test' , headers = {'Range' : 'bytes=-' })
585+ self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
586+
571587 def test_head (self ):
572588 response = self .request (
573589 self .base_url + '/test' , method = 'HEAD' )
0 commit comments