What should the Content-Type be for a 4xx error without a body?
Asked Answered
P

1

19

Consider an HTTP request that gets the following response:

405 Method Not Allowed
Content-Length: 0

What should the content-type of something like this be?

  • Set to nothing?
  • Not set?
  • Set to text/plain or text/html
Prolocutor answered 22/2, 2013 at 20:48 Comment(1)
Possible duplicate of Should content-type header be present when the message body is emptyPricecutting
U
23

You haven't got any content, therefore I wouldn't set a Content-Type at all. If you find that causes problems to clients (which seems unlikely, to be honest), I'd probably go with text/plain - definitely not text/html, as your "empty content" is not an HTML document.

Uttermost answered 22/2, 2013 at 20:50 Comment(1)
@dB.: It would have been useful to say so before. It sounds like you basically need to follow whatever the bug ends up deciding you need.Uttermost

© 2022 - 2024 — McMap. All rights reserved.