12 |
|
#include <menes-api/process.hpp> |
13 |
|
#include <menes-app/simple.hpp> |
14 |
|
|
15 |
< |
struct |
15 |
> |
struct Environment |
16 |
|
{ |
17 |
< |
ext::String get(const ext::String& name) |
18 |
< |
{ |
19 |
< |
try |
20 |
< |
{ |
21 |
< |
return api::TheEnvironment.Get(name); |
22 |
< |
} |
23 |
< |
catch (ext::Exception) |
24 |
< |
{ |
25 |
< |
return ext::String(); |
26 |
< |
} |
27 |
< |
} |
17 |
> |
ext::String get(const ext::String& name) { try { return api::TheEnvironment.Get(name); } catch (ext::Exception) { return ext::String(); } } |
18 |
|
} env; |
19 |
|
|
20 |
|
int Main(const app::Options& options) |
52 |
|
<< env.get("SERVER_SIGNATURE") << "</body></html>\n"; |
53 |
|
} |
54 |
|
} |
55 |
< |
else |
66 |
< |
{ |
67 |
< |
api::Cout << "Location: http://computers.douglasthrift.net/bender.xml\r\n\r\n"; |
68 |
< |
} |
55 |
> |
else api::Cout << "Location: http://computers.douglasthrift.net/bender.xml\r\n\r\n"; |
56 |
|
} |
57 |
|
|
58 |
|
void Bender::bend(const ext::String& path, const ext::String& agent) |
59 |
|
{ |
60 |
|
Matcher matcher; |
61 |
|
|
62 |
< |
if (agent == matcher("Opera( |\\/)(\\d+)\\.(\\d+)")) |
76 |
< |
{ |
77 |
< |
bend(path); |
78 |
< |
} |
79 |
< |
else if (agent == matcher("rv:(\\d+)\\.(\\d+).*\\) Gecko")) |
62 |
> |
if (agent == matcher("Opera( |\\/)(\\d+)\\.(\\d+)")) bend(path); else if (agent == matcher("rv:(\\d+)\\.(\\d+).*\\) Gecko")) |
63 |
|
{ |
64 |
|
int major_(lexical_cast<int>(matcher[1])), minor_(lexical_cast<int>(matcher[2])); |
65 |
|
|
66 |
< |
if (major_ > 1 || (major_ == 1 && minor_ >= 5)) |
84 |
< |
{ |
85 |
< |
pass(path); |
86 |
< |
} |
87 |
< |
else bend(path); |
66 |
> |
if (major_ > 1 || (major_ == 1 && minor_ >= 5)) pass(path); else bend(path); |
67 |
|
} |
68 |
|
else bend(path); |
69 |
|
} |
88 |
|
if (!output.IsEmpty()) |
89 |
|
{ |
90 |
|
ext::String type("text/xml"); |
91 |
< |
Matcher matcher("http-equiv=\"Content-Type\" content=\"(.*)\""); |
91 |
> |
Matcher matcher("http-equiv=\"Content-Type\" content=\"(.*)\"", PCRE_MULTILINE); |
92 |
|
|
93 |
|
if (matcher == output) type = matcher[1]; |
94 |
|
|