r17232 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17231‎ | r17232 | r17233 >
Date:01:34, 24 October 2006
Author:river
Status:old
Tags:
Comment:
errors should be more Web 2.0-looking
Modified paths:
  • /trunk/willow/errors/ERR_BADREQUEST (modified) (history)
  • /trunk/willow/errors/ERR_BADRESPONSE (modified) (history)
  • /trunk/willow/errors/ERR_BLOCKED (modified) (history)
  • /trunk/willow/errors/ERR_CACHE_IO (modified) (history)
  • /trunk/willow/errors/ERR_GENERAL (modified) (history)
  • /trunk/willow/src/include/wconfig.h (modified) (history)
  • /trunk/willow/src/willow/wconfig.cc (modified) (history)
  • /trunk/willow/src/willow/whttp.cc (modified) (history)

Diff [purge]

Index: trunk/willow/src/include/wconfig.h
@@ -40,6 +40,7 @@
4141
4242 struct radix;
4343 extern struct configuration {
 44+ string admin;
4445 int foreground;
4546 int nthreads;
4647 string access_log;
Index: trunk/willow/src/willow/wconfig.cc
@@ -272,6 +272,7 @@
273273 .value("carp-hash", func(v_carp_hash), func(s_carp_hash))
274274 .value("threads", simple_range(1, 1024), set_int(config.nthreads))
275275 .value("msie-http11-hack", simple_yesno, set_yesno(config.msie_hack))
 276+ .value("admin", nonempty_qstring, set_string(config.admin))
276277
277278 .block("stats")
278279 .value("interval", simple_range(1, INT_MAX), set_aint(stats.interval))
@@ -310,6 +311,7 @@
311312 */
312313 stats.interval = DEFAULT_STATS_INTERVAL;
313314 config.nthreads = 1;
 315+ config.admin = "nobody@example.com";
314316 conf.set(*t);
315317 whttp_reconfigure();
316318 global_conf_tree = *t;
Index: trunk/willow/src/willow/whttp.cc
@@ -773,6 +773,32 @@
774774 delete client;
775775 }
776776
 777+static string
 778+errsafe(string const &s)
 779+{
 780+string::const_iterator it = s.begin(), end = s.end();
 781+string res;
 782+ res.reserve((long) (s.size() * 1.2));
 783+ for (; it != end; ++it)
 784+ switch (*it) {
 785+ case '<':
 786+ res += "&lt;";
 787+ break;
 788+ case '>':
 789+ res += "&gt;";
 790+ break;
 791+ case '"':
 792+ res += "&quot;";
 793+ break;
 794+ case '\'':
 795+ res += "&apos;";
 796+ break;
 797+ default:
 798+ res += *it;
 799+ }
 800+ return res;
 801+}
 802+
777803 static void
778804 client_send_error(http_client *client, int errnum, const char * errdata, int status, const char *statstr)
779805 {
@@ -807,8 +833,11 @@
808834 switch(*p) {
809835 case '%':
810836 switch (*++p) {
 837+ case 'A':
 838+ errtxt += errsafe(config.admin);
 839+ break;
811840 case 'U':
812 - errtxt += client->cl_path;
 841+ errtxt += errsafe(client->cl_path);
813842 break;
814843 case 'D':
815844 errtxt += current_time_str;
@@ -817,7 +846,7 @@
818847 errtxt += my_hostname;
819848 break;
820849 case 'E':
821 - errtxt += errdata;
 850+ errtxt += errsafe(errdata);
822851 break;
823852 case 'V':
824853 errtxt += my_version;
@@ -829,9 +858,10 @@
830859 break;
831860 }
832861 case 'S':
833 - errtxt += statstr;
 862+ errtxt += errsafe(statstr);
834863 break;
835864 default:
 865+ errtxt += *p;
836866 break;
837867 }
838868 p++;
@@ -859,7 +889,7 @@
860890 client->cl_entity->he_rdata.response.status = status;
861891 client->cl_entity->he_rdata.response.status_str = statstr;
862892 if (errnum >= 0) {
863 - client->cl_entity->he_headers.add("Content-Type", "text/html");
 893+ client->cl_entity->he_headers.add("Content-Type", "text/html;charset=UTF-8");
864894 client->cl_entity->he_source_type = ENT_SOURCE_BUFFER;
865895 client->cl_entity->he_source.buffer.addr = client->cl_wrtbuf;
866896 client->cl_entity->he_source.buffer.len = strlen(client->cl_wrtbuf);
Index: trunk/willow/errors/ERR_CACHE_IO
@@ -3,19 +3,63 @@
44 <head>
55 <title>Error: %C %S</title>
66 <style type="text/css">
 7+* {
 8+ font-family: sans-serif;
 9+}
 10+
711 body {
8 - background-color: white;
 12+ background-color: #eeeeee;
913 color: black;
1014 }
 15+
 16+#topbar {
 17+ font-size: 1.3em;
 18+ text-align: center;
 19+ border-bottom: solid 1px black;
 20+ color: #770000;
 21+}
 22+
 23+#header {
 24+ font-size: 1.3em;
 25+ text-decoration: underline;
 26+}
 27+
 28+#footer {
 29+ border-top: dashed 1px black;
 30+ padding-top: 3px;
 31+ text-align: right;
 32+ color: #777777;
 33+}
 34+
 35+span.ms {
 36+ font-family: monospace;
 37+}
 38+
 39+a {
 40+ color: #555599;
 41+}
1142 </style>
1243 </head>
1344 <body>
14 -<h1>Request failed: %C %S</h1>
15 -<p>While trying to retrieve the URL:</p>
16 -<ul><li>%U</li></ul>
17 -<p>The following internal cache error was encountered:</p>
 45+
 46+<div id="topbar">
 47+Error loading page: %C %S
 48+</div>
 49+
 50+<p>This is the Willow proxy-cache at server <span class="ms">%H</span>.
 51+I am sorry to inform you that I was unable to retrieve the URL you requested:</p>
 52+
 53+<ul><li><a href="%U"><span class="ms">%U</span></a></li></ul>
 54+
 55+<p>The following error was encountered while trying:</p>
 56+
1857 <ul><li>%E</li></ul>
19 -<hr>
 58+
 59+<p>Please wait a while and try again. If the problem persists, please contact
 60+my owner: <a href="mailto:%A">%A</a>.</p>
 61+
 62+<div id="footer">
2063 Generated %D by %H (%V)
 64+</div>
2165 </body>
2266 </html>
Index: trunk/willow/errors/ERR_GENERAL
@@ -3,19 +3,63 @@
44 <head>
55 <title>Error: %C %S</title>
66 <style type="text/css">
 7+* {
 8+ font-family: sans-serif;
 9+}
 10+
711 body {
8 - background-color: white;
 12+ background-color: #eeeeee;
913 color: black;
1014 }
 15+
 16+#topbar {
 17+ font-size: 1.3em;
 18+ text-align: center;
 19+ border-bottom: solid 1px black;
 20+ color: #770000;
 21+}
 22+
 23+#header {
 24+ font-size: 1.3em;
 25+ text-decoration: underline;
 26+}
 27+
 28+#footer {
 29+ border-top: dashed 1px black;
 30+ padding-top: 3px;
 31+ text-align: right;
 32+ color: #777777;
 33+}
 34+
 35+span.ms {
 36+ font-family: monospace;
 37+}
 38+
 39+a {
 40+ color: #555599;
 41+}
1142 </style>
1243 </head>
1344 <body>
14 -<h1>Request failed: %C %S</h1>
15 -<p>While trying to retrieve the URL:</p>
16 -<ul><li>%U</li></ul>
17 -<p>The following error was encountered:</p>
 45+
 46+<div id="topbar">
 47+Error loading page: %C %S
 48+</div>
 49+
 50+<p>This is the Willow proxy-cache at server <span class="ms">%H</span>.
 51+I am sorry to inform you that I was unable to retrieve the URL you requested:</p>
 52+
 53+<ul><li><a href="%U"><span class="ms">%U</span></a></li></ul>
 54+
 55+<p>The following error was encountered while trying:</p>
 56+
1857 <ul><li>%E</li></ul>
19 -<hr>
 58+
 59+<p>Please wait a while and try again. If the problem persists, please contact
 60+my owner: <a href="mailto:%A">%A</a>.</p>
 61+
 62+<div id="footer">
2063 Generated %D by %H (%V)
 64+</div>
2165 </body>
2266 </html>
Index: trunk/willow/errors/ERR_BADREQUEST
@@ -3,19 +3,63 @@
44 <head>
55 <title>Error: %C %S</title>
66 <style type="text/css">
 7+* {
 8+ font-family: sans-serif;
 9+}
 10+
711 body {
8 - background-color: white;
 12+ background-color: #eeeeee;
913 color: black;
1014 }
 15+
 16+#topbar {
 17+ font-size: 1.3em;
 18+ text-align: center;
 19+ border-bottom: solid 1px black;
 20+ color: #770000;
 21+}
 22+
 23+#header {
 24+ font-size: 1.3em;
 25+ text-decoration: underline;
 26+}
 27+
 28+#footer {
 29+ border-top: dashed 1px black;
 30+ padding-top: 3px;
 31+ text-align: right;
 32+ color: #777777;
 33+}
 34+
 35+span.ms {
 36+ font-family: monospace;
 37+}
 38+
 39+a {
 40+ color: #555599;
 41+}
1142 </style>
1243 </head>
1344 <body>
14 -<h1>Request failed: %C %S</h1>
15 -<p>While trying to retrieve the URL:</p>
16 -<ul><li>%U</li></ul>
17 -<p>The following error was encountered:</p>
18 -<ul><li>%E.</li></ul>
19 -<hr>
 45+
 46+<div id="topbar">
 47+Error loading page: %C %S
 48+</div>
 49+
 50+<p>This is the Willow proxy-cache at server <span class="ms">%H</span>.
 51+I am sorry to inform you that I was unable to retrieve the URL you requested:</p>
 52+
 53+<ul><li><a href="%U"><span class="ms">%U</span></a></li></ul>
 54+
 55+<p>The following error was encountered while trying:</p>
 56+
 57+<ul><li>%E</li></ul>
 58+
 59+<p>Please wait a while and try again. If the problem persists, please contact
 60+my owner: <a href="mailto:%A">%A</a>.</p>
 61+
 62+<div id="footer">
2063 Generated %D by %H (%V)
 64+</div>
2165 </body>
2266 </html>
Index: trunk/willow/errors/ERR_BLOCKED
@@ -3,19 +3,63 @@
44 <head>
55 <title>Error: %C %S</title>
66 <style type="text/css">
 7+* {
 8+ font-family: sans-serif;
 9+}
 10+
711 body {
8 - background-color: white;
 12+ background-color: #eeeeee;
913 color: black;
1014 }
 15+
 16+#topbar {
 17+ font-size: 1.3em;
 18+ text-align: center;
 19+ border-bottom: solid 1px black;
 20+ color: #770000;
 21+}
 22+
 23+#header {
 24+ font-size: 1.3em;
 25+ text-decoration: underline;
 26+}
 27+
 28+#footer {
 29+ border-top: dashed 1px black;
 30+ padding-top: 3px;
 31+ text-align: right;
 32+ color: #777777;
 33+}
 34+
 35+span.ms {
 36+ font-family: monospace;
 37+}
 38+
 39+a {
 40+ color: #555599;
 41+}
1142 </style>
1243 </head>
1344 <body>
14 -<h1>Request failed: %C %S</h1>
15 -<p>While trying to retrieve the URL:</p>
16 -<ul><li>%U</li></ul>
17 -<p>The following error was encountered:</p>
 45+
 46+<div id="topbar">
 47+Error loading page: %C %S
 48+</div>
 49+
 50+<p>This is the Willow proxy-cache at server <span class="ms">%H</span>.
 51+I am sorry to inform you that I was unable to retrieve the URL you requested:</p>
 52+
 53+<ul><li><a href="%U"><span class="ms">%U</span></a></li></ul>
 54+
 55+<p>The following error was encountered while trying:</p>
 56+
1857 <ul><li>Your IP address was denied access to this server.</li></ul>
19 -<hr>
 58+
 59+<p>Please wait a while and try again. If the problem persists, please contact
 60+my owner: <a href="mailto:%A">%A</a>.</p>
 61+
 62+<div id="footer">
2063 Generated %D by %H (%V)
 64+</div>
2165 </body>
2266 </html>
Index: trunk/willow/errors/ERR_BADRESPONSE
@@ -3,19 +3,63 @@
44 <head>
55 <title>Error: %C %S</title>
66 <style type="text/css">
 7+* {
 8+ font-family: sans-serif;
 9+}
 10+
711 body {
8 - background-color: white;
 12+ background-color: #eeeeee;
913 color: black;
1014 }
 15+
 16+#topbar {
 17+ font-size: 1.3em;
 18+ text-align: center;
 19+ border-bottom: solid 1px black;
 20+ color: #770000;
 21+}
 22+
 23+#header {
 24+ font-size: 1.3em;
 25+ text-decoration: underline;
 26+}
 27+
 28+#footer {
 29+ border-top: dashed 1px black;
 30+ padding-top: 3px;
 31+ text-align: right;
 32+ color: #777777;
 33+}
 34+
 35+span.ms {
 36+ font-family: monospace;
 37+}
 38+
 39+a {
 40+ color: #555599;
 41+}
1142 </style>
1243 </head>
1344 <body>
14 -<h1>Request failed: %C %S</h1>
15 -<p>While trying to retrieve the URL:</p>
16 -<ul><li>%U</li></ul>
17 -<p>The following error was encountered:</p>
 45+
 46+<div id="topbar">
 47+Error loading page: %C %S
 48+</div>
 49+
 50+<p>This is the Willow proxy-cache at server <span class="ms">%H</span>.
 51+I am sorry to inform you that I was unable to retrieve the URL you requested:</p>
 52+
 53+<ul><li><a href="%U"><span class="ms">%U</span></a></li></ul>
 54+
 55+<p>The following error was encountered while trying:</p>
 56+
1857 <ul><li>Could not parse server response.</li></ul>
19 -<hr>
 58+
 59+<p>Please wait a while and try again. If the problem persists, please contact
 60+my owner: <a href="mailto:%A">%A</a>.</p>
 61+
 62+<div id="footer">
2063 Generated %D by %H (%V)
 64+</div>
2165 </body>
2266 </html>