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

Update response.send() to check HTTP status code length #1722

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Adimvicky
Copy link

@Adimvicky Adimvicky commented Nov 21, 2018

I updated line 300 which checks that the HTTP status code passed into the Response.send() function is of type "number" to also check that the length of the status code is equal to three since all HTTP status codes are three digits. This allows for the Response.send() function to send ordinary numbers of any length ( other than three ) as response if need be, instead of throwing.

Pre-Submission Checklist

  • Opened an issue discussing these changes before opening the PR
  • Ran the linter and tests via make prepush
  • Included comprehensive and convincing tests for changes

Issues

Closes:

  • Issue #
  • Issue #
  • Issue #

Summarize the issues that discussed these changes

Changes

What does this PR do?

I updated line 300 which checks that the HTTP status code passed into the Response.send() function is of type "number" to also check that the length of the status code is equal to three since all HTTP status codes are three digits. This allows for the Response.send() function to send ordinary numbers of any length ( other than three ) as response if need be.
Copy link
Member

@sean3z sean3z left a comment

Choose a reason for hiding this comment

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

The contribution is greatly appreciated!! 🙂

Certainly an interesting approach! I'm thinking this will become confusing for restify consumers though - especially since the api would only allow numbers, 0-99 and 1000+; leaving 100-999 off-limits.

I know this has been a hot topic before but, will likely require a slightly more sophisticated solve

@kolbma
Copy link

kolbma commented Jun 22, 2023

I don't think this would be a good feature like it is...

  1. It adds computation overhead to each and every request
  2. You can simply use something like https://www.npmjs.com/package/statuses and check it in your own code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants