Message body on a 404 message

2019-03-18 04:34发布

问题:

I was talking with a co-worker that for some reason wrote a framework from the ground up just because it wasn't able to automatically unmarshall a message body on a 404 HTTP Packet.

He says that he's following REST principles. My guess is that a message body on a 404 HTTP Packet violate those principles, but I'm not sure of it.

If someone has a opinion regarding this, please answer :)

回答1:

If you use a web browser to go to http://www.google.com/unknown You will get a 404 status code and an entity body.

It is quite common for entity bodies to be returned with 404s.

If you look at the description of 400 errors in the HTTPbis spec you will see

the server SHOULD include a representation containing an
explanation of the error situation, and whether it is a temporary or
permanent condition.



标签: rest