File tree 2 files changed +6
-5
lines changed 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ class RetryHandler {
229
229
return false
230
230
}
231
231
232
- const { start, size, end = size } = contentRange
232
+ const { start, size, end = size - 1 } = contentRange
233
233
234
234
assert ( this . start === start , 'content-range mismatch' )
235
235
assert ( this . end == null || this . end === end , 'content-range mismatch' )
@@ -252,7 +252,7 @@ class RetryHandler {
252
252
)
253
253
}
254
254
255
- const { start, size, end = size } = range
255
+ const { start, size, end = size - 1 } = range
256
256
assert (
257
257
start != null && Number . isFinite ( start ) ,
258
258
'content-range mismatch'
@@ -266,7 +266,7 @@ class RetryHandler {
266
266
// We make our best to checkpoint the body for further range headers
267
267
if ( this . end == null ) {
268
268
const contentLength = headers [ 'content-length' ]
269
- this . end = contentLength != null ? Number ( contentLength ) : null
269
+ this . end = contentLength != null ? Number ( contentLength ) - 1 : null
270
270
}
271
271
272
272
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 => {
253
253
const server = createServer ( ( req , res ) => {
254
254
if ( x === 0 ) {
255
255
t . ok ( true , 'pass' )
256
+ res . setHeader ( 'content-length' , '6' )
256
257
res . setHeader ( 'etag' , 'asd' )
257
258
res . write ( 'abc' )
258
259
setTimeout ( ( ) => {
259
260
res . destroy ( )
260
261
} , 1e2 )
261
262
} 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' )
264
265
res . setHeader ( 'etag' , 'asd' )
265
266
res . statusCode = 206
266
267
res . end ( 'def' )
You can’t perform that action at this time.
0 commit comments