Skip to content

Replace http.STATUS_CODES with the statuses module - #3215

Closed
wesleytodd wants to merge 1 commit into
expressjs:masterfrom
wesleytodd:statuses-module
Closed

Replace http.STATUS_CODES with the statuses module#3215
wesleytodd wants to merge 1 commit into
expressjs:masterfrom
wesleytodd:statuses-module

Conversation

@wesleytodd

Copy link
Copy Markdown
Member

Replaced usage of core http.STATUS_CODES with the list from the statuses module. This was pulled out from #3213 as recommended by @dougwilson in a side conversation. For posterity, it is known that it might be considered a "breaking" change because it changes the response text, which is why the tests were breaking.

@dougwilson I couldn't remember if you said to make the PR against 5.0 and backport it, or against 4.0 and cherry-pick it forward, I know we mentioned both ways. Let me know if I did this the wrong way and I can fix it.

@wesleytodd
wesleytoddforce-pushed the statuses-module branch 2 times, most recently from 987423f to d8c5930CompareFebruary 20, 2017 21:41
Comment threadtest/res.redirect.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just hard-code the literal text here. It was dynamic because http was not consistent between major versions, but statuses will be consistent.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@dougwilsondougwilson self-assigned this Feb 20, 2017
@dougwilson

Copy link
Copy Markdown
Contributor

Ideally I think it can land on 4.x. The target of the PR itself is not too big of an issue, as we can merge it where ever, but if you want to update the PR to target master, that would work too :) You shouldn't need to close and open a new PR to do this, so if you're not sure, just leave it targeting the 5.x branch, haha

@wesleytodd
wesleytodd changed the base branch from 5.x to 4.xFebruary 20, 2017 21:58
@wesleytodd
wesleytodd changed the base branch from 4.x to masterFebruary 20, 2017 22:01
@wesleytodd

Copy link
Copy Markdown
MemberAuthor

Ok, made the test change, and updated to PR against master.

@dougwilsondougwilson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The require

Comment threadlib/response.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm iffy about requiring any sub file in a module. The statuses API is lame, but probably can still be used here. I would just do var statuses = require('statuses') and then the code below would still work, after the variable name change (with a possible oddity in res.sendStatus that would need to be dealt with regardless of this change).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe I am missing something here, but the object found in statuses/codes is not directly exposed. So I don't think I can get Found from 302 in the existing api. I would either need to change the statuses package to expose it, or use the statuses.codes array to reverse engineer back to the original data structure. Of those two, I obviously lean toward updating the statuses package to expose the raw codes object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ node -pe 'require("statuses")[302]'
Found

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, yeah totally missed the mechanism that exposed that on the first read. Sorry for the bother. Updating now.

@dougwilsondougwilson added this to the 4.15 milestone Feb 21, 2017
@dougwilsondougwilson mentioned this pull request Feb 21, 2017
22 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@wesleytodd@dougwilson@LinusU