diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-10-11 15:47:45 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-10-11 15:47:45 +0000 |
commit | 745875139b5ee46e469927d410364bfeeedb2995 (patch) | |
tree | 393d6ded249fdca428539098caeb285479fa7ab3 /src/test/httpsrv | |
parent | df6f199b4e158d1d6cfb99d45258efa22afee715 (diff) | |
download | libbu++-745875139b5ee46e469927d410364bfeeedb2995.tar.gz libbu++-745875139b5ee46e469927d410364bfeeedb2995.tar.bz2 libbu++-745875139b5ee46e469927d410364bfeeedb2995.tar.xz libbu++-745875139b5ee46e469927d410364bfeeedb2995.zip |
Despite some svn oddness, I'm now moving to a new setup for the tests, that's
very much like the original one, but now using build. You will need the latest
build in order to build the tests.
Diffstat (limited to 'src/test/httpsrv')
-rw-r--r-- | src/test/httpsrv/httpconnectionmonitor.cpp | 80 | ||||
-rw-r--r-- | src/test/httpsrv/httpconnectionmonitor.h | 16 | ||||
-rw-r--r-- | src/test/httpsrv/main.cpp | 22 |
3 files changed, 0 insertions, 118 deletions
diff --git a/src/test/httpsrv/httpconnectionmonitor.cpp b/src/test/httpsrv/httpconnectionmonitor.cpp deleted file mode 100644 index ee1eab3..0000000 --- a/src/test/httpsrv/httpconnectionmonitor.cpp +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
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, int nPort ) | ||
14 | { | ||
15 | printf("Got connection on port %d\n", nPort ); | ||
16 | Http hp( pCon ); | ||
17 | |||
18 | pCon->readInput( 60, 0 ); | ||
19 | printf("#######################\n%s\n#######################\n", pCon->getInput() ); | ||
20 | |||
21 | while( hp.parseRequest() == false ); | ||
22 | printf("Done parsing.\n\n"); | ||
23 | |||
24 | if( hp.getRequestType() == Http::reqGet ) | ||
25 | { | ||
26 | printf("\"\"\"%s\"\"\"\n", hp.getRequestURI() ); | ||
27 | if( !strcmp( hp.getRequestURI(), "/" ) ) | ||
28 | { | ||
29 | 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>"); | ||
30 | hp.buildResponse(); | ||
31 | hp.setResponseContent( | ||
32 | "text/html", | ||
33 | content.c_str(), | ||
34 | content.size() | ||
35 | ); | ||
36 | hp.sendResponse(); | ||
37 | } | ||
38 | else | ||
39 | { | ||
40 | 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>"); | ||
41 | hp.buildResponse( 404, "File not found."); | ||
42 | hp.setResponseContent( | ||
43 | "text/html", | ||
44 | content.c_str(), | ||
45 | content.size() | ||
46 | ); | ||
47 | hp.sendResponse(); | ||
48 | } | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | printf("Non get: %s\n", hp.getRequestTypeStr() ); | ||
53 | pCon->appendOutput("HTTP/1.1 100 Continue\r\n\r\n"); | ||
54 | } | ||
55 | pCon->writeOutput(); | ||
56 | //for( int j = 0; j < 50; j++ ) | ||
57 | { | ||
58 | pCon->readInput( 1, 0 ); | ||
59 | //printf("Size so far: %d\n", pCon->getInputAmnt() ); | ||
60 | } | ||
61 | |||
62 | if( pCon->hasInput() ) | ||
63 | { | ||
64 | std::string s( pCon->getInput(), pCon->getInputAmnt() ); | ||
65 | |||
66 | pCon->printInputDebug(); | ||
67 | //printf("Reamining data\n==============\n%s\n==============\n", | ||
68 | // s.c_str() ); | ||
69 | } | ||
70 | |||
71 | pCon->disconnect(); | ||
72 | |||
73 | return true; | ||
74 | } | ||
75 | |||
76 | bool HttpConnectionMonitor::onClosedConnection( Connection *pCon ) | ||
77 | { | ||
78 | return true; | ||
79 | } | ||
80 | |||
diff --git a/src/test/httpsrv/httpconnectionmonitor.h b/src/test/httpsrv/httpconnectionmonitor.h deleted file mode 100644 index 30c0afd..0000000 --- a/src/test/httpsrv/httpconnectionmonitor.h +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | #ifndef HTTPCONNECTIONMONITOR_H | ||
2 | #define HTTPCONNECTIONMONITOR_H | ||
3 | |||
4 | #include "connectionmonitor.h" | ||
5 | |||
6 | class HttpConnectionMonitor : public ConnectionMonitor | ||
7 | { | ||
8 | public: | ||
9 | HttpConnectionMonitor(); | ||
10 | ~HttpConnectionMonitor(); | ||
11 | |||
12 | bool onNewConnection( Connection *pCon, int nPort ); | ||
13 | bool onClosedConnection( Connection *pCon ); | ||
14 | }; | ||
15 | |||
16 | #endif | ||
diff --git a/src/test/httpsrv/main.cpp b/src/test/httpsrv/main.cpp deleted file mode 100644 index 2f1563c..0000000 --- a/src/test/httpsrv/main.cpp +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #include "connectionmanager.h" | ||
2 | #include "httpconnectionmonitor.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | printf("Starting server...\n"); | ||
7 | |||
8 | ConnectionManager srv; | ||
9 | HttpConnectionMonitor http; | ||
10 | |||
11 | srv.setConnectionMonitor( &http ); | ||
12 | |||
13 | printf("Listening on port 7331\n"); | ||
14 | srv.startServer( 7331 ); | ||
15 | |||
16 | for(;;) | ||
17 | { | ||
18 | srv.scanConnections( 5000, false ); | ||
19 | } | ||
20 | |||
21 | return 0; | ||
22 | } | ||