What Content-Type should a 204 No Response use?

前端 未结 2 1711
一整个雨季
一整个雨季 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:16

    Well, there's a little more to the story though, and it involves when the real-world (browsers) meet the theoretical world (specifications). Seems Firefox (ver 38 as I write this) has a bug where the browser attempts to parse the content as xml if there's no content-type header, EVEN WHEN the response code is 204 (no content). See https://bugzilla.mozilla.org/show_bug.cgi?id=521301

    So, while a content type header doesn't make much sense when there's no content (and there MUST NOT be content on a 204) it seems to make sense to return some header anyway. And I don't see where that would be a violation of the spec.

提交回复
热议问题