Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update statuses to v2.0.1 #1480

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/application/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe('app.respond', () => {
describe('with custom status=700', () => {
it('should respond with the associated status message', async () => {
const app = new Koa()
statuses['700'] = 'custom status'
statuses.message['700'] = 'custom status'

app.use(ctx => {
ctx.status = 700
Expand Down
4 changes: 2 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ const proto = module.exports = {
if (err.code === 'ENOENT') statusCode = 404

// default to 500
if (typeof statusCode !== 'number' || !statuses[statusCode]) statusCode = 500
if (typeof statusCode !== 'number' || !statuses.message[statusCode]) statusCode = 500

// respond
const code = statuses[statusCode]
const code = statuses.message[statusCode]
const msg = err.expose ? err.message : code
this.status = err.status = statusCode
this.length = Buffer.byteLength(msg)
Expand Down
4 changes: 2 additions & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {
assert(code >= 100 && code <= 999, `invalid status code: ${code}`)
this._explicitStatus = true
this.res.statusCode = code
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses[code]
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses.message[code]
if (this.body && statuses.empty[code]) this.body = null
},

Expand All @@ -99,7 +99,7 @@ module.exports = {
*/

get message () {
return this.res.statusMessage || statuses[this.status]
return this.res.statusMessage || statuses.message[this.status]
},

/**
Expand Down