What Content-Type should a 204 No Response use?

前端 未结 2 1704
一整个雨季
一整个雨季 2020-12-15 02:45

When building a RESTful HTTP service, and a Response is given with a 204 No Content (e.g. after the Consumer issues a DELETE Request), what Content-Type should the Response

2条回答
  •  天涯浪人
    2020-12-15 03:28

    You have Content-Type when you have content and even then it's optional:

    Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body.

    (from RFC2616, §7.2.1, please note the use of SHOULD).

    Since there is no content, then there is no reason to specify a Content-Type header.

提交回复
热议问题