Skip to content

Commit

Permalink
fix valid partial response statuses to be 206 instead of 200
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanto committed Oct 5, 2023
1 parent 589d2a5 commit ec0bc69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Static {

// Range
await res
.status(200)
.status(206)
.length(end - start + 1)
.type(type)
.set('Content-Range', `bytes ${start}-${end}/${length}`)
Expand Down
14 changes: 7 additions & 7 deletions test/static-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,49 +88,49 @@ t.test('Static app', async t => {
.bodyLike(/^Hello World!/);

(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=1-5'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
.headerLike('Content-Range', /^bytes 1-5\/\d+/)
.bodyIs('ello ');
(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=-5'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
.headerLike('Content-Range', /^bytes 0-5\/\d+/)
.bodyIs('Hello ');
(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=1-'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
.headerLike('Content-Range', /^bytes 1-\d+\/\d+/)
.bodyLike(/^ello World!/);
(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=4-'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
.headerLike('Content-Range', /^bytes 4-\d+\/\d+/)
.bodyLike(/^o World!/);
(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=4-4'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
.headerLike('Content-Range', /^bytes 4-4\/\d+/)
.bodyIs('o');
(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=0-0'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
.headerLike('Content-Range', /^bytes 0-\d+\/\d+/)
.bodyIs('H');
(await ua.getOk('/static/hello.txt', {headers: {Range: 'bytes=-'}}))
.statusIs(200)
.statusIs(206)
.headerExists('Content-Type')
.headerExists('Content-Length')
.headerIs('Accept-Ranges', 'bytes')
Expand Down

0 comments on commit ec0bc69

Please sign in to comment.