Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clean up markup and headers for HAProxy error pages.

  • Loading branch information...
commit 224927bbf204bdc4bdd69facb117f5a8b9d6715f 1 parent 703d196
@spladug spladug authored
View
1  .gitignore
@@ -0,0 +1 @@
+*.http
View
16 403.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+<head>
+<title>Ow! -- reddit.com</title>
+<style>
+body { text-align: center; }
+h2 { color: red; font-size: 200%; }
+</style>
+</head>
+<body>
+<img src="http://www.redditstatic.com/youbrokeit3.png" alt="you broke reddit!">
+<h2>You appear to be a bad robot. Check out <a
+href="http://github.com/reddit/reddit/wiki/API">the rules for
+robots</a>. Thanks.</h2>
+</body>
+</html>
View
18 403.http
@@ -1,18 +0,0 @@
-HTTP/1.1 403 OK
-Content-Type: text/html; charset=UTF-8
-
-<html>
-<head>
-<title>Ow! -- reddit.com</title>
-</head>
-<body style="text-align: center">
-
-<img src="http://www.reddit.com/static/youbrokeit3.png">
-<br style="clear: both"/>
-<div style="margin: auto; display: inline-block">
-
-<h2 style="color: red; font-size: 200%;">
-You appear to be a bad robot. Check out <a href="http://code.reddit.com/wiki/API">the rules for robots</a>. Thanks.
-</h2>
-</body>
-</html>
View
15 502.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+<title>Ow! -- reddit.com</title>
+<style>
+body { text-align: center; }
+h2 { color: red; font-size: 200%; }
+</style>
+</head>
+<body>
+<img src="http://www.redditstatic.com/youbrokeit1.png" alt="you broke reddit!">
+<h2>Your request took too long for our servers, so we had to cut it off.
+Try again and hopefully it will be fast enough this time.</h2>
+</body>
+</html>
View
18 502.http
@@ -1,18 +0,0 @@
-HTTP/1.1 502 OK
-Content-Type: text/html; charset=UTF-8
-
-<html>
-<head>
-<title>Ow! -- reddit.com</title>
-</head>
-<body style="text-align: center">
-
-<img src="http://www.reddit.com/static/youbrokeit1.png">
-<br style="clear: both"/>
-<div style="margin: auto; display: inline-block">
-
-<h2 style="color: red; font-size: 200%;">
-Our servers did something nasty and the proxy didn't like it.
-</h2>
-</body>
-</html>
View
15 503.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+<title>Ow! -- reddit.com</title>
+<style>
+body { text-align: center; }
+h2 { color: red; font-size: 200%; }
+</style>
+</head>
+<body>
+<img src="http://www.redditstatic.com/heavy-mallet.png" alt="ow!">
+<h2>reddit is under heavy load right now. please try again in a few
+minutes.</h2>
+</body>
+</html>
View
18 503.http
@@ -1,18 +0,0 @@
-HTTP/1.1 503 OK
-Content-Type: text/html; charset=UTF-8
-
-<html>
-<head>
-<title>Ow! -- reddit.com</title>
-</head>
-<body style="text-align: center">
-
-<img src="http://sp.reddit.com/heavy-mallet.gif">
-<br style="clear: both"/>
-<div style="margin: auto; display: inline-block">
-
-<h2 style="color: red; font-size: 200%;">
-reddit is under heavy load right now, sorry. Try again in a few minutes.
-</h2>
-</body>
-</html>
View
15 504.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+<title>Ow! -- reddit.com</title>
+<style>
+body { text-align: center; }
+h2 { color: red; font-size: 200%; }
+</style>
+</head>
+<body>
+<img src="http://www.redditstatic.com/heavy-mallet.png" alt="ow!">
+<h2>Your request took too long for our servers, so we had to cut it off.
+Try again and hopefully it will be fast enough this time.</h2>
+</body>
+</html>
View
18 504.http
@@ -1,18 +0,0 @@
-HTTP/1.1 504 OK
-Content-Type: text/html; charset=UTF-8
-
-<html>
-<head>
-<title>Ow! -- reddit.com</title>
-</head>
-<body style="text-align: center">
-
-<img src="http://sp.reddit.com/heavy-mallet.gif">
-<br style="clear: both"/>
-<div style="margin: auto; display: inline-block">
-
-<h2 style="color: red; font-size: 200%;">
-Your request took too long for our servers, so we had to cut it off. Try again and hopefully it will be fast enough this time.
-</h2>
-</body>
-</html>
View
10 Makefile
@@ -0,0 +1,10 @@
+ERROR_PAGES := $(wildcard [0-9][0-9][0-9].html)
+ERROR_FILES := $(patsubst %.html,%.http,$(ERROR_PAGES))
+
+all: $(ERROR_FILES)
+
+%.http: %.html
+ python make-error-page.py $< > $@
+
+clean:
+ rm -f $(ERROR_FILES)
View
24 make-error-page.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+import sys
+
+
+REASON_PHRASES = {403: "Forbidden",
+ 502: "Bad Gateway",
+ 503: "Service Unavailable",
+ 504: "Gateway Timeout"}
+
+
+input_file = sys.argv[1]
+html_file = open(input_file, 'r')
+html = html_file.read()
+
+status_code = int(input_file.partition('.')[0])
+reason_phrase = REASON_PHRASES[status_code]
+
+sys.stdout.write("HTTP/1.1 %d %s\r\n" % (status_code, reason_phrase))
+sys.stdout.write("Content-Type: text/html; charset=UTF-8\r\n")
+sys.stdout.write("Content-Length: %d\r\n" % len(html))
+sys.stdout.write("\r\n")
+sys.stdout.write(html)
+sys.stdout.flush()
Please sign in to comment.
Something went wrong with that request. Please try again.