UFWebApps / UF-Directory-App-Assignment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assignment 1 Server.test.js expects incorrect status body

atotalnoob opened this issue · comments

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

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

commented

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.