Should I return “500” or “404” if the requested image is not found?

I work with code written by other people, sometimes I'm somewhat confused, and at this time, Qaru saves me. Please save me again.

Our site allows people to upload images, and then embed them in text on our site like this:

<img src="http://site.com/image_script.php?p=some_image_identifier"/>

My question is:

If the identifier "p" does not lead us to the image, if the server returns "500" or "404"?

I would think that it should be "404", but that’s not what is happening right now.

+3
source share
4 answers

500 - . , , , 404.

+14

404 (imho) . 500 . 404 , , . , URL.

+3

If the user enters the wrong script name, it should be 501 (or maybe 500). If they enter the wrong image identifier, it should be 404, since there is no corresponding resource.

0
source

404 file not found, obviously the obvious solution.

Or 400, a bad request because they requested an identifier that did not exist.

0
source

Source: https://habr.com/ru/post/1746763/


All Articles