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

Assignment 1 Server.test.js expects incorrect status body #9

Open
atotalnoob opened this issue Sep 1, 2018 · 2 comments
Open

Assignment 1 Server.test.js expects incorrect status body #9

atotalnoob opened this issue Sep 1, 2018 · 2 comments

Comments

@atotalnoob
Copy link

Unit test requires a bad gateway error, but wants a 404 code returned. This is incorrect, bad gateway is error code 502.

Also, per W3 spec, no body should be returned for a 404, either.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

@atotalnoob
Copy link
Author

Also if you are expecting a body returned, the body should be checked as .toLower() or .toUpper() to remove variations in capitalization.

Per W3, the Bad Gateway error is capitalized. Unit tests expects: "Bad gateway error" when in reality it should be "Bad Gateway error". This caused the unit test to fail incorrectly

@mrmvy
Copy link

mrmvy commented Sep 6, 2018

Actually, there is no prohibition against returning a body with a 404 status code (see, for example, RFC2616 (https://tools.ietf.org/html/rfc2616) or RFC7231 (https://tools.ietf.org/html/rfc7231). In fact, you can see that IETF actually returns a rather robust body with a 404 status code if you attempt to access https://tools.ietf.org/html/rfc8675309.

Also, both RFC2616 and RFC7231 indicate that the text listed in the RFCs for each status code is recommended text, not required text. There is no requirement that the text for any status code is capitalized or otherwise formatted in any particular manner. As noted in RFC2616, the status code itself is intended for computer-consumption while the text is intended for human consumption. Thus, returning "Bad gateway error" with a 404 status code is not incorrect (from the IETF's perspective) although it certainly could be misleading to a human.

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

No branches or pull requests

2 participants