Index: trunk/willow/src/include/wconfig.h |
— | — | @@ -40,6 +40,7 @@ |
41 | 41 | |
42 | 42 | struct radix; |
43 | 43 | extern struct configuration { |
| 44 | + string admin; |
44 | 45 | int foreground; |
45 | 46 | int nthreads; |
46 | 47 | string access_log; |
Index: trunk/willow/src/willow/wconfig.cc |
— | — | @@ -272,6 +272,7 @@ |
273 | 273 | .value("carp-hash", func(v_carp_hash), func(s_carp_hash)) |
274 | 274 | .value("threads", simple_range(1, 1024), set_int(config.nthreads)) |
275 | 275 | .value("msie-http11-hack", simple_yesno, set_yesno(config.msie_hack)) |
| 276 | + .value("admin", nonempty_qstring, set_string(config.admin)) |
276 | 277 | |
277 | 278 | .block("stats") |
278 | 279 | .value("interval", simple_range(1, INT_MAX), set_aint(stats.interval)) |
— | — | @@ -310,6 +311,7 @@ |
311 | 312 | */ |
312 | 313 | stats.interval = DEFAULT_STATS_INTERVAL; |
313 | 314 | config.nthreads = 1; |
| 315 | + config.admin = "nobody@example.com"; |
314 | 316 | conf.set(*t); |
315 | 317 | whttp_reconfigure(); |
316 | 318 | global_conf_tree = *t; |
Index: trunk/willow/src/willow/whttp.cc |
— | — | @@ -773,6 +773,32 @@ |
774 | 774 | delete client; |
775 | 775 | } |
776 | 776 | |
| 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 += "<"; |
| 787 | + break; |
| 788 | + case '>': |
| 789 | + res += ">"; |
| 790 | + break; |
| 791 | + case '"': |
| 792 | + res += """; |
| 793 | + break; |
| 794 | + case '\'': |
| 795 | + res += "'"; |
| 796 | + break; |
| 797 | + default: |
| 798 | + res += *it; |
| 799 | + } |
| 800 | + return res; |
| 801 | +} |
| 802 | + |
777 | 803 | static void |
778 | 804 | client_send_error(http_client *client, int errnum, const char * errdata, int status, const char *statstr) |
779 | 805 | { |
— | — | @@ -807,8 +833,11 @@ |
808 | 834 | switch(*p) { |
809 | 835 | case '%': |
810 | 836 | switch (*++p) { |
| 837 | + case 'A': |
| 838 | + errtxt += errsafe(config.admin); |
| 839 | + break; |
811 | 840 | case 'U': |
812 | | - errtxt += client->cl_path; |
| 841 | + errtxt += errsafe(client->cl_path); |
813 | 842 | break; |
814 | 843 | case 'D': |
815 | 844 | errtxt += current_time_str; |
— | — | @@ -817,7 +846,7 @@ |
818 | 847 | errtxt += my_hostname; |
819 | 848 | break; |
820 | 849 | case 'E': |
821 | | - errtxt += errdata; |
| 850 | + errtxt += errsafe(errdata); |
822 | 851 | break; |
823 | 852 | case 'V': |
824 | 853 | errtxt += my_version; |
— | — | @@ -829,9 +858,10 @@ |
830 | 859 | break; |
831 | 860 | } |
832 | 861 | case 'S': |
833 | | - errtxt += statstr; |
| 862 | + errtxt += errsafe(statstr); |
834 | 863 | break; |
835 | 864 | default: |
| 865 | + errtxt += *p; |
836 | 866 | break; |
837 | 867 | } |
838 | 868 | p++; |
— | — | @@ -859,7 +889,7 @@ |
860 | 890 | client->cl_entity->he_rdata.response.status = status; |
861 | 891 | client->cl_entity->he_rdata.response.status_str = statstr; |
862 | 892 | 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"); |
864 | 894 | client->cl_entity->he_source_type = ENT_SOURCE_BUFFER; |
865 | 895 | client->cl_entity->he_source.buffer.addr = client->cl_wrtbuf; |
866 | 896 | client->cl_entity->he_source.buffer.len = strlen(client->cl_wrtbuf); |
Index: trunk/willow/errors/ERR_CACHE_IO |
— | — | @@ -3,19 +3,63 @@ |
4 | 4 | <head> |
5 | 5 | <title>Error: %C %S</title> |
6 | 6 | <style type="text/css"> |
| 7 | +* { |
| 8 | + font-family: sans-serif; |
| 9 | +} |
| 10 | + |
7 | 11 | body { |
8 | | - background-color: white; |
| 12 | + background-color: #eeeeee; |
9 | 13 | color: black; |
10 | 14 | } |
| 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 | +} |
11 | 42 | </style> |
12 | 43 | </head> |
13 | 44 | <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 | + |
18 | 57 | <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"> |
20 | 63 | Generated %D by %H (%V) |
| 64 | +</div> |
21 | 65 | </body> |
22 | 66 | </html> |
Index: trunk/willow/errors/ERR_GENERAL |
— | — | @@ -3,19 +3,63 @@ |
4 | 4 | <head> |
5 | 5 | <title>Error: %C %S</title> |
6 | 6 | <style type="text/css"> |
| 7 | +* { |
| 8 | + font-family: sans-serif; |
| 9 | +} |
| 10 | + |
7 | 11 | body { |
8 | | - background-color: white; |
| 12 | + background-color: #eeeeee; |
9 | 13 | color: black; |
10 | 14 | } |
| 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 | +} |
11 | 42 | </style> |
12 | 43 | </head> |
13 | 44 | <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 | + |
18 | 57 | <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"> |
20 | 63 | Generated %D by %H (%V) |
| 64 | +</div> |
21 | 65 | </body> |
22 | 66 | </html> |
Index: trunk/willow/errors/ERR_BADREQUEST |
— | — | @@ -3,19 +3,63 @@ |
4 | 4 | <head> |
5 | 5 | <title>Error: %C %S</title> |
6 | 6 | <style type="text/css"> |
| 7 | +* { |
| 8 | + font-family: sans-serif; |
| 9 | +} |
| 10 | + |
7 | 11 | body { |
8 | | - background-color: white; |
| 12 | + background-color: #eeeeee; |
9 | 13 | color: black; |
10 | 14 | } |
| 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 | +} |
11 | 42 | </style> |
12 | 43 | </head> |
13 | 44 | <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"> |
20 | 63 | Generated %D by %H (%V) |
| 64 | +</div> |
21 | 65 | </body> |
22 | 66 | </html> |
Index: trunk/willow/errors/ERR_BLOCKED |
— | — | @@ -3,19 +3,63 @@ |
4 | 4 | <head> |
5 | 5 | <title>Error: %C %S</title> |
6 | 6 | <style type="text/css"> |
| 7 | +* { |
| 8 | + font-family: sans-serif; |
| 9 | +} |
| 10 | + |
7 | 11 | body { |
8 | | - background-color: white; |
| 12 | + background-color: #eeeeee; |
9 | 13 | color: black; |
10 | 14 | } |
| 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 | +} |
11 | 42 | </style> |
12 | 43 | </head> |
13 | 44 | <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 | + |
18 | 57 | <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"> |
20 | 63 | Generated %D by %H (%V) |
| 64 | +</div> |
21 | 65 | </body> |
22 | 66 | </html> |
Index: trunk/willow/errors/ERR_BADRESPONSE |
— | — | @@ -3,19 +3,63 @@ |
4 | 4 | <head> |
5 | 5 | <title>Error: %C %S</title> |
6 | 6 | <style type="text/css"> |
| 7 | +* { |
| 8 | + font-family: sans-serif; |
| 9 | +} |
| 10 | + |
7 | 11 | body { |
8 | | - background-color: white; |
| 12 | + background-color: #eeeeee; |
9 | 13 | color: black; |
10 | 14 | } |
| 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 | +} |
11 | 42 | </style> |
12 | 43 | </head> |
13 | 44 | <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 | + |
18 | 57 | <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"> |
20 | 63 | Generated %D by %H (%V) |
| 64 | +</div> |
21 | 65 | </body> |
22 | 66 | </html> |