diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
commit | f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54 (patch) | |
tree | 53cec4864776e07950e3c72f2a990a1017d08045 /src/test/httpsrv/httpconnectionmonitor.cpp | |
download | libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.gz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.bz2 libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.xz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.zip |
libbu++ is finally laid out the way it should be, trunk, branches, and tags.
Diffstat (limited to '')
-rw-r--r-- | src/test/httpsrv/httpconnectionmonitor.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/test/httpsrv/httpconnectionmonitor.cpp b/src/test/httpsrv/httpconnectionmonitor.cpp new file mode 100644 index 0000000..4eb6817 --- /dev/null +++ b/src/test/httpsrv/httpconnectionmonitor.cpp | |||
@@ -0,0 +1,72 @@ | |||
1 | #include "httpconnectionmonitor.h" | ||
2 | #include "http.h" | ||
3 | #include <sys/stat.h> | ||
4 | |||
5 | HttpConnectionMonitor::HttpConnectionMonitor() | ||
6 | { | ||
7 | } | ||
8 | |||
9 | HttpConnectionMonitor::~HttpConnectionMonitor() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | bool HttpConnectionMonitor::onNewConnection( Connection *pCon ) | ||
14 | { | ||
15 | Http hp( pCon ); | ||
16 | |||
17 | pCon->readInput( 60, 0 ); | ||
18 | printf("#######################\n%s\n#######################\n", pCon->getInput() ); | ||
19 | |||
20 | while( hp.parseRequest() == false ); | ||
21 | printf("Done parsing.\n\n"); | ||
22 | |||
23 | if( hp.getRequestType() == Http::reqGet ) | ||
24 | { | ||
25 | printf("\"\"\"%s\"\"\"\n", hp.getRequestURI() ); | ||
26 | if( !strcmp( hp.getRequestURI(), "/" ) ) | ||
27 | { | ||
28 | std::string content("<html><head><title>Server Test</test></head><body>This is a test of a new system where all the pages will be more or less dynamic...<br>If you want to try to login, you can do that here:<br><form method=\"post\" action=\"showvars\" enctype=\"multipart/form-data\">Name: <input type=\"text\" name=\"name\"><br>Password: <input type=\"password\" name=\"pass\"><br><input type=\"submit\" name=\"action\" value=\"login\"></form></body></html>"); | ||
29 | hp.buildResponse(); | ||
30 | hp.setResponseContent( | ||
31 | "text/html", | ||
32 | content.c_str(), | ||
33 | content.size() | ||
34 | ); | ||
35 | hp.sendResponse(); | ||
36 | } | ||
37 | else | ||
38 | { | ||
39 | std::string content("<html><head><title>URL Not Found</test></head><body>There is no content mapped to the URL you requested. Please try another one.</body></html>"); | ||
40 | hp.buildResponse( 404, "File not found."); | ||
41 | hp.setResponseContent( | ||
42 | "text/html", | ||
43 | content.c_str(), | ||
44 | content.size() | ||
45 | ); | ||
46 | hp.sendResponse(); | ||
47 | } | ||
48 | } | ||
49 | else | ||
50 | { | ||
51 | printf("Non get: %s\n", hp.getRequestTypeStr() ); | ||
52 | } | ||
53 | pCon->writeOutput(); | ||
54 | |||
55 | if( pCon->hasInput() ) | ||
56 | { | ||
57 | std::string s( pCon->getInput(), pCon->getInputAmnt() ); | ||
58 | |||
59 | printf("Reamining data\n==============\n%s\n==============\n", | ||
60 | s.c_str() ); | ||
61 | } | ||
62 | |||
63 | pCon->disconnect(); | ||
64 | |||
65 | return true; | ||
66 | } | ||
67 | |||
68 | bool HttpConnectionMonitor::onClosedConnection( Connection *pCon ) | ||
69 | { | ||
70 | return true; | ||
71 | } | ||
72 | |||