Home > Back-end >  Non integer HTTP response codes possible?
Non integer HTTP response codes possible?

Time:05-14

I am aware of standard HTTP response codes and their categorization (1xx, 2xx, 3xx, 4xx and 5xx)

But, I have seen certain web requests return non-standard HTTP response codes, like 999, 1001, 1002, 1006 etc. However, I have never seen any HTTP response code that contains alphanumeric characters. Is it possible for any server to send non-integer response codes?

CodePudding user response:

Non-standard is non-standard. You might call it impossible, or you might say that everything is possible until it breaks something you need.

Practically, most software passes around HTTP status codes as integers, and will reject, break, or behave in unexpected ways if they aren't.

Don't do it.

CodePudding user response:

A server response is just a sequence of bytes sent over the network, and the status codes are sent as text (in HTTP 1.x). It's therefore very possible to send across alphanumeric characters where a standards-compliant server would send across a valid HTTP status code.

If a non-numeric value is sent, don't expect clients to do a sane thing with them. Clients quite reasonably expect a standards-compliant (numeric) value, and well-behaved clients would likely fail if they receive something not conforming to the standard.

  • Related