From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/tests/httpsrv/httpconnectionmonitor.cpp | 88 ----------------------------- src/tests/httpsrv/httpconnectionmonitor.h | 16 ------ src/tests/httpsrv/main.cpp | 22 -------- 3 files changed, 126 deletions(-) delete mode 100644 src/tests/httpsrv/httpconnectionmonitor.cpp delete mode 100644 src/tests/httpsrv/httpconnectionmonitor.h delete mode 100644 src/tests/httpsrv/main.cpp (limited to 'src/tests/httpsrv') diff --git a/src/tests/httpsrv/httpconnectionmonitor.cpp b/src/tests/httpsrv/httpconnectionmonitor.cpp deleted file mode 100644 index 51d82f3..0000000 --- a/src/tests/httpsrv/httpconnectionmonitor.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "httpconnectionmonitor.h" -#include "http.h" -#include "exceptions.h" -#include - -HttpConnectionMonitor::HttpConnectionMonitor() -{ -} - -HttpConnectionMonitor::~HttpConnectionMonitor() -{ -} - -bool HttpConnectionMonitor::onNewConnection( Connection *pCon, int nPort ) -{ - printf("Got connection on port %d\n", nPort ); - - try - { - pCon->readInput( 60, 0 ); - printf("#######################\n%s\n#######################\n", pCon->getInput() ); - - Http hp( pCon ); - while( hp.parseRequest() == false ); - printf("Done parsing.\n\n"); - - if( hp.getRequestType() == Http::reqGet ) - { - printf("\"\"\"%s\"\"\"\n", hp.getRequestURI() ); - if( !strcmp( hp.getRequestURI(), "/" ) ) - { - std::string content("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>"); - hp.buildResponse(); - hp.setResponseContent( - "text/html", - content.c_str(), - content.size() - ); - hp.sendResponse(); - } - else - { - 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>"); - hp.buildResponse( 404, "File not found."); - hp.setResponseContent( - "text/html", - content.c_str(), - content.size() - ); - hp.sendResponse(); - } - } - else - { - printf("Non get: %s\n", hp.getRequestTypeStr() ); - pCon->appendOutput("HTTP/1.1 100 Continue\r\n\r\n"); - } - pCon->writeOutput(); - //for( int j = 0; j < 50; j++ ) - { - pCon->readInput( 1, 0 ); - //printf("Size so far: %d\n", pCon->getInputAmnt() ); - } - - if( pCon->hasInput() ) - { - std::string s( pCon->getInput(), pCon->getInputAmnt() ); - - pCon->printInputDebug(); - //printf("Reamining data\n==============\n%s\n==============\n", - // s.c_str() ); - } - - pCon->disconnect(); - } - catch( ConnectionException &e ) - { - printf("Connection: %s\n", e.what() ); - } - - return true; -} - -bool HttpConnectionMonitor::onClosedConnection( Connection *pCon ) -{ - return true; -} - diff --git a/src/tests/httpsrv/httpconnectionmonitor.h b/src/tests/httpsrv/httpconnectionmonitor.h deleted file mode 100644 index 30c0afd..0000000 --- a/src/tests/httpsrv/httpconnectionmonitor.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef HTTPCONNECTIONMONITOR_H -#define HTTPCONNECTIONMONITOR_H - -#include "connectionmonitor.h" - -class HttpConnectionMonitor : public ConnectionMonitor -{ -public: - HttpConnectionMonitor(); - ~HttpConnectionMonitor(); - - bool onNewConnection( Connection *pCon, int nPort ); - bool onClosedConnection( Connection *pCon ); -}; - -#endif diff --git a/src/tests/httpsrv/main.cpp b/src/tests/httpsrv/main.cpp deleted file mode 100644 index 2f1563c..0000000 --- a/src/tests/httpsrv/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "connectionmanager.h" -#include "httpconnectionmonitor.h" - -int main() -{ - printf("Starting server...\n"); - - ConnectionManager srv; - HttpConnectionMonitor http; - - srv.setConnectionMonitor( &http ); - - printf("Listening on port 7331\n"); - srv.startServer( 7331 ); - - for(;;) - { - srv.scanConnections( 5000, false ); - } - - return 0; -} -- cgit v1.2.3