Welcome! Log In Create A New Profile

Advanced

500 Server Error vs. 500 Internal Server Error ?

Posted by Jarno Huuskonen 
Jarno Huuskonen
500 Server Error vs. 500 Internal Server Error ?
January 09, 2017 01:50PM
Hello,

Haproxy uses 500 "Server Error" for error/status code 500.
AFAIK RFC 2616/7231 and most? other servers use 500 "Internal Server Error".

Is there a reason for using "Server Error" and not "Internal Server
Error" ?

If you think "Internal Server Error" is more suitable then this patch
changes the 500 status code texts to "Internal Server Error".
(Patch is against 1.8dev but should also apply to 1.7.1).
(I hope examples/errorfiles/500.http \r\n line endings survive email ...)

-Jarno

--
Jarno Huuskonen
From e6726c8ae5d4d9385f4e585e89f3f43a25ecf1fa Mon Sep 17 00:00:00 2001
From: Jarno Huuskonen <[email protected]>
Date: Mon, 9 Jan 2017 14:17:10 +0200
Subject: [PATCH] MINOR: Use "500 Internal Server Error" for 500 error/status
code message. Internal Server Error is what is in RFC 2616/7231.
To: haproxy@formilux.org
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4

---
examples/errorfiles/500.http | 4 ++--
src/hlua.c | 4 ++--
src/proto_http.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/examples/errorfiles/500.http b/examples/errorfiles/500.http
index bb121e8..ebf7d47 100644
--- a/examples/errorfiles/500.http
+++ b/examples/errorfiles/500.http
@@ -1,9 +1,9 @@
-HTTP/1.0 500 Server Error
+HTTP/1.0 500 Internal Server Error
Cache-Control: no-cache
Connection: close
Content-Type: text/html

-<html><body><h1>500 Server Error</h1>
+<html><body><h1>500 Internal Server Error</h1>
An internal server error occured.
</body></html>

diff --git a/src/hlua.c b/src/hlua.c
index 48fcf1a..d3dc565 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -216,12 +216,12 @@ struct hlua_mem_allocator {
static struct hlua_mem_allocator hlua_global_allocator;

static const char error_500[] =
- "HTTP/1.0 500 Server Error\r\n"
+ "HTTP/1.0 500 Internal Server Error\r\n"
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
- "<html><body><h1>500 Server Error</h1>\nAn internal server error occured.\n</body></html>\n";
+ "<html><body><h1>500 Internal Server Error</h1>\nAn internal server error occured.\n</body></html>\n";

/* These functions converts types between HAProxy internal args or
* sample and LUA types. Another function permits to check if the
diff --git a/src/proto_http.c b/src/proto_http.c
index f7f7545..8bc1636 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -196,12 +196,12 @@ static const char *http_err_msgs[HTTP_ERR_SIZE] = {
"<html><body><h1>429 Too Many Requests</h1>\nYou have sent too many requests in a given amount of time.\n</body></html>\n",

[HTTP_ERR_500] =
- "HTTP/1.0 500 Server Error\r\n"
+ "HTTP/1.0 500 Internal Server Error\r\n"
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n"
- "<html><body><h1>500 Server Error</h1>\nAn internal server error occured.\n</body></html>\n",
+ "<html><body><h1>500 Internal Server Error</h1>\nAn internal server error occured.\n</body></html>\n",

[HTTP_ERR_502] =
"HTTP/1.0 502 Bad Gateway\r\n"
--
1.8.3.1
Willy Tarreau
Re: 500 Server Error vs. 500 Internal Server Error ?
January 11, 2017 12:30PM
Hi Jarno,

On Mon, Jan 09, 2017 at 02:38:32PM +0200, Jarno Huuskonen wrote:
> Hello,
>
> Haproxy uses 500 "Server Error" for error/status code 500.
> AFAIK RFC 2616/7231 and most? other servers use 500 "Internal Server Error".
>
> Is there a reason for using "Server Error" and not "Internal Server
> Error" ?

There's no reason for it just like there's no reason against it.
The reason code is free, you could even translate it if you want.

> If you think "Internal Server Error" is more suitable then this patch
> changes the 500 status code texts to "Internal Server Error".
> (Patch is against 1.8dev but should also apply to 1.7.1).

I'm fine with merging this in 1.8.

> (I hope examples/errorfiles/500.http \r\n line endings survive email ...)

The \r was dropped, so I had to apply it by hand to the errorfile.

Thanks!
Willy
Sorry, only registered users may post in this forum.

Click here to login