ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Bender/Bender.cpp
(Generate patch)

Comparing Bender/Bender.cpp (file contents):
Revision 119 by Douglas Thrift, 2004-03-17T21:15:24-08:00 vs.
Revision 161 by Douglas Thrift, 2004-06-16T21:13:23-07:00

# Line 32 | Line 32 | Bender::Bender()
32   {
33          string path = sgetenv("PATH_TRANSLATED");
34  
35 <
36 <        if (path != "")
35 >        if (path != "" && sgetenv("REQUEST_URI").find(sgetenv("SCRIPT_NAME")) != 0)
36          {
37                  ifstream file(path.c_str());
38  
# Line 42 | Line 41 | Bender::Bender()
41                          file.close();
42  
43                          bend(path, sgetenv("HTTP_USER_AGENT"));
44 <
45 <                        return;
44 >                }
45 >                else
46 >                {
47 >                        cout << "Status: 404\n"
48 >                                << "Content-Type: text/html; charset=ISO-8859-1\n\n"
49 >                                << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
50 >                                << "<html><head>\n"
51 >                                << "<title>404 Not Found</title>\n"
52 >                                << "</head><body>\n"
53 >                                << "<h1>Not Found</h1>\n"
54 >                                << "<p>The requested URL " << sgetenv("PATH_INFO") << " was no"
55 >                                << "t found on this server.</p>\n"
56 >                                << "<hr />\n"
57 >                                << sgetenv("SERVER_SIGNATURE")
58 >                                << "</body></html>\n";
59                  }
60          }
61 <
62 <        cout << "Status: 404\n"
63 <                << "Content-Type: text/html; charset=ISO-8859-1\n\n"
64 <                << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
53 <                << "<html><head>\n"
54 <                << "<title>404 Not Found</title>\n"
55 <                << "</head><body>\n"
56 <                << "<h1>Not Found</h1>\n"
57 <                << "<p>The requested URL " << sgetenv("PATH_INFO") << " was not found "
58 <                << "on this server.</p>\n"
59 <                << "<hr />\n"
60 <                << sgetenv("SERVER_SIGNATURE")
61 <                << "</body></html>\n";
61 >        else
62 >        {
63 >                cout << "Location: http://computers.douglasthrift.net/bender.xml\n\n";
64 >        }
65   }
66  
67   void Bender::bend(const string& path, const string& agent)
# Line 69 | Line 72 | void Bender::bend(const string& path, co
72          {
73                  bend(path);
74          }
72        else if (agent == matcher(string("^Mozilla/4.0 \\(compatible; MSIE (\\d+)")
73                + "\\.(\\d+)(\\w+)?; .*\\)$"))
74        {
75                int version;
76                istringstream number(matcher[1]);
77
78                number >> version;
79
80                if (version >= 6)
81                {
82                        pass(path);
83                }
84                else
85                {
86                        bend(path);
87                }
88        }
75          else if (agent == matcher(string("^Mozilla/5.0 \\(.*; rv:(\\d+)\\.(\\d+)(")
76                  + "\\.d+)?(\\w+)?\\) Gecko\\/.*"))
77          {
# Line 117 | Line 103 | void Bender::bend(const string& path)
103  
104          if (transformer.transform(path.c_str(), output) == 0)
105          {
106 <                string type = "text/html; charset=ISO-8859-1";
107 <                Matcher matcher("<META http-equiv=\"Content-Type\" content=\"(.*)\">");
106 >                string type = "text/xml";
107 >                Matcher matcher("http-equiv=\"Content-Type\" content=\"(.*)\"");
108  
109                  if (matcher == output.str())
110                  {
# Line 135 | Line 121 | void Bender::bend(const string& path)
121  
122   void Bender::pass(const string& path)
123   {
124 <        cout << "Content-Type: text/xml; charset=ISO-8859-1\n\n";
124 >        cout << "Content-Type: text/xml\n\n";
125  
126          ifstream fin(path.c_str());
127          string line;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines