File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ class RetryHandler {
229229 return false
230230 }
231231
232- const { start, size, end = size } = contentRange
232+ const { start, size, end = size - 1 } = contentRange
233233
234234 assert ( this . start === start , 'content-range mismatch' )
235235 assert ( this . end == null || this . end === end , 'content-range mismatch' )
@@ -252,7 +252,7 @@ class RetryHandler {
252252 )
253253 }
254254
255- const { start, size, end = size } = range
255+ const { start, size, end = size - 1 } = range
256256 assert (
257257 start != null && Number . isFinite ( start ) ,
258258 'content-range mismatch'
@@ -266,7 +266,7 @@ class RetryHandler {
266266 // We make our best to checkpoint the body for further range headers
267267 if ( this . end == null ) {
268268 const contentLength = headers [ 'content-length' ]
269- this . end = contentLength != null ? Number ( contentLength ) : null
269+ this . end = contentLength != null ? Number ( contentLength ) - 1 : null
270270 }
271271
272272 assert ( Number . isFinite ( this . start ) )
Original file line number Diff line number Diff line change @@ -253,14 +253,15 @@ test('Should handle 206 partial content', async t => {
253253 const server = createServer ( ( req , res ) => {
254254 if ( x === 0 ) {
255255 t . ok ( true , 'pass' )
256+ res . setHeader ( 'content-length' , '6' )
256257 res . setHeader ( 'etag' , 'asd' )
257258 res . write ( 'abc' )
258259 setTimeout ( ( ) => {
259260 res . destroy ( )
260261 } , 1e2 )
261262 } else if ( x === 1 ) {
262- t . deepStrictEqual ( req . headers . range , 'bytes=3-' )
263- res . setHeader ( 'content-range' , 'bytes 3-6 /6' )
263+ t . deepStrictEqual ( req . headers . range , 'bytes=3-5 ' )
264+ res . setHeader ( 'content-range' , 'bytes 3-5 /6' )
264265 res . setHeader ( 'etag' , 'asd' )
265266 res . statusCode = 206
266267 res . end ( 'def' )
You can’t perform that action at this time.
0 commit comments