Is 418 "I'm a teapot" really an HTTP response code?
HttpHttp Problem Overview
Is 418 "I'm a teapot" really an HTTP response code?
There are various references to this on the internet, including in lists of response codes, but I can't figure out whether it's a weird joke.
Http Solutions
Solution 1 - Http
I use this code. I have nginx reverse-proxying requests to two separate HTTP servers. One handles requests for unauthenticated users, and the second handles requests for authenticated users. The problem in this particular case, is the first server is the one that determines if the user is authenticated. Please don't ask why.
So, if the first server determines the user is authenticated, it responds 418 I'm a teapot
. NGINX then reroutes the traffic internally to the second server. As far as the browser is concerned, it was a single request.
This is in the spirit of HTCPCP code 418, because if you attempt to BREW with a teapot, the appropriate response is "I'm not the kind of thing that can handle that request, but there may be others." .. In other words, "I'm a teapot. Find a coffee maker." (the second server being the coffee maker).
Ultimately, while 418 is not explicitly defined in RFC 7231, it is still covered by the umbrella of 4xx (Client Error)
.
> 6. Response Status Codes > > - 4xx (Client Error): The request contains bad syntax or cannot be fulfilled > > 6.5. Client Error 4xx > > - The 4xx (Client Error) class of status code indicates that the client > seems to have erred. Except when responding to a HEAD request, the > server SHOULD send a representation containing an explanation of the > error situation, and whether it is a temporary or permanent > condition. These status codes are applicable to any request method. > User agents SHOULD display any included representation to the user.
Solution 2 - Http
HTTP response code 418 was originally defined in RFC 2324 ("Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)") and RFC 7168 ("The Hyper Text Coffee Pot Control Protocol for Tea Efflux Appliances (HTCPCP-TEA)") protocols.
Per Wikipedia: List of HTTP status codes: #418
> This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
Solution 3 - Http
Yes, I can confirm, that I've seen HTTP 418 coming back from a real production server. It does exist.
Solution 4 - Http
Yes it's a "real" code in the sense that it was published as part of an official RFC by the Internet Engineering Task Force. However, since that RFC was published on April 1 and meant as an April fools joke (along with the rest of Hyper Text Coffee Pot Control Protocol), not for legitimate implementation, it's not a "serious" code. That's why most sites use it as an Easter egg, but otherwise avoid it. As noted by this comment, there are often more appropriate statuses like 400 (Bad Request). Despite its satirical nature, it's now a reserved code (presumably as a result of becoming a popular engineering meme for the briefest moment), so don't expect it to be going anywhere anytime soon.
Notably, according to Larry Masinter (the author of that RFC purported by Wikipedia), the HTTP extension in question actually does serve a (satirical) purpose: "it identifies many of the ways in which HTTP has been extended inappropriately."
Solution 5 - Http
You really should not ask a HTTCP (Hyper-Text Teapot Control Protocol) to brew coffee. That's a job for a HTCPCP (Hyper-Text Coffee Pot Control Protocol).
Solution 6 - Http
I think it is safer to treat 418 as a reserved code that once had a half - official meaning but now officially "unassigned".
I assume, historically something has been differently thought about these codes than it is now. This sounds meaningless and funny today; probably was not?
In other words, I would avoid using this code.
Solution 7 - Http
There's one variation of it, for bot detection & rejection: HTTP 418: You look like a robot
.