42 |
|
file.close(); |
43 |
|
|
44 |
|
bend(path, sgetenv("HTTP_USER_AGENT")); |
45 |
< |
|
46 |
< |
return; |
45 |
> |
} |
46 |
> |
else |
47 |
> |
{ |
48 |
> |
cout << "Status: 404\n" |
49 |
> |
<< "Content-Type: text/html; charset=ISO-8859-1\n\n" |
50 |
> |
<< "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" |
51 |
> |
<< "<html><head>\n" |
52 |
> |
<< "<title>404 Not Found</title>\n" |
53 |
> |
<< "</head><body>\n" |
54 |
> |
<< "<h1>Not Found</h1>\n" |
55 |
> |
<< "<p>The requested URL " << sgetenv("PATH_INFO") << " was no" |
56 |
> |
<< "t found on this server.</p>\n" |
57 |
> |
<< "<hr />\n" |
58 |
> |
<< sgetenv("SERVER_SIGNATURE") |
59 |
> |
<< "</body></html>\n"; |
60 |
|
} |
61 |
|
} |
62 |
< |
|
63 |
< |
cout << "Location: http://computers.douglasthrift.net/bender.xml\n\n"; |
62 |
> |
else |
63 |
> |
{ |
64 |
> |
cout << "Location: http://computers.douglasthrift.net/bender.xml\n\n"; |
65 |
> |
} |
66 |
|
} |
67 |
|
|
68 |
|
void Bender::bend(const string& path, const string& agent) |
73 |
|
{ |
74 |
|
bend(path); |
75 |
|
} |
61 |
– |
else if (agent == matcher(string("^Mozilla/4.0 \\(compatible; MSIE (\\d+)") |
62 |
– |
+ "\\.(\\d+)(\\w+)?; .*\\)$")) |
63 |
– |
{ |
64 |
– |
int version; |
65 |
– |
istringstream number(matcher[1]); |
66 |
– |
|
67 |
– |
number >> version; |
68 |
– |
|
69 |
– |
if (version >= 6) |
70 |
– |
{ |
71 |
– |
pass(path); |
72 |
– |
} |
73 |
– |
else |
74 |
– |
{ |
75 |
– |
bend(path); |
76 |
– |
} |
77 |
– |
} |
76 |
|
else if (agent == matcher(string("^Mozilla/5.0 \\(.*; rv:(\\d+)\\.(\\d+)(") |
77 |
|
+ "\\.d+)?(\\w+)?\\) Gecko\\/.*")) |
78 |
|
{ |
105 |
|
if (transformer.transform(path.c_str(), output) == 0) |
106 |
|
{ |
107 |
|
string type = "text/html; charset=ISO-8859-1"; |
108 |
< |
Matcher matcher("<META http-equiv=\"Content-Type\" content=\"(.*)\">"); |
108 |
> |
Matcher matcher("http-equiv=\"Content-Type\" content=\"(.*)\""); |
109 |
|
|
110 |
|
if (matcher == output.str()) |
111 |
|
{ |