@@ -540,48 +540,49 @@ def test_get(self):
540
540
os .chmod (self .tempdir , 0o755 )
541
541
542
542
def test_range_get (self ):
543
- response = self .request (self .base_url + '/test' )
543
+ route = self .base_url + '/test'
544
+ response = self .request (route )
544
545
self .assertEqual (response .getheader ('accept-ranges' ), 'bytes' )
545
546
self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
546
547
547
548
# valid ranges
548
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=3-12' })
549
+ response = self .request (route , headers = {'Range' : 'bytes=3-12' })
549
550
self .assertEqual (response .getheader ('content-range' ), 'bytes 3-12/30' )
550
551
self .assertEqual (response .getheader ('content-length' ), '10' )
551
552
self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [3 :13 ])
552
553
553
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=3-' })
554
+ response = self .request (route , headers = {'Range' : 'bytes=3-' })
554
555
self .assertEqual (response .getheader ('content-range' ), 'bytes 3-29/30' )
555
556
self .assertEqual (response .getheader ('content-length' ), '27' )
556
557
self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [3 :])
557
558
558
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=-5' })
559
+ response = self .request (route , headers = {'Range' : 'bytes=-5' })
559
560
self .assertEqual (response .getheader ('content-range' ), 'bytes 25-29/30' )
560
561
self .assertEqual (response .getheader ('content-length' ), '5' )
561
562
self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [25 :])
562
563
563
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=29-29' })
564
+ response = self .request (route , headers = {'Range' : 'bytes=29-29' })
564
565
self .assertEqual (response .getheader ('content-range' ), 'bytes 29-29/30' )
565
566
self .assertEqual (response .getheader ('content-length' ), '1' )
566
567
self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [29 :])
567
568
568
569
# end > file size
569
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=25-100' })
570
+ response = self .request (route , headers = {'Range' : 'bytes=25-100' })
570
571
self .assertEqual (response .getheader ('content-range' ), 'bytes 25-29/30' )
571
572
self .assertEqual (response .getheader ('content-length' ), '5' )
572
573
self .check_status_and_reason (response , HTTPStatus .PARTIAL_CONTENT , data = self .data [25 :])
573
574
574
575
# invalid ranges
575
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=100-200' })
576
+ response = self .request (route , headers = {'Range' : 'bytes=100-200' })
576
577
self .check_status_and_reason (response , HTTPStatus .REQUESTED_RANGE_NOT_SATISFIABLE )
577
578
578
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=4-3' })
579
+ response = self .request (route , headers = {'Range' : 'bytes=4-3' })
579
580
self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
580
581
581
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=wrong format' })
582
+ response = self .request (route , headers = {'Range' : 'bytes=wrong format' })
582
583
self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
583
584
584
- response = self .request (self . base_url + '/test' , headers = {'Range' : 'bytes=-' })
585
+ response = self .request (route , headers = {'Range' : 'bytes=-' })
585
586
self .check_status_and_reason (response , HTTPStatus .OK , data = self .data )
586
587
587
588
def test_head (self ):
0 commit comments