From 514721c24c7212c084ad2530e8239ff121097818 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 6 Apr 2009 19:13:51 +0000 Subject: Ok, I rearranged some things, we have a tools dir now, those build by default. Also I added a bunch of classes that I've been tinkering with that are almost ready for use, so I figured I may as well throw them in here. --- src/tests/fastcgi.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/tests/fastcgi.cpp (limited to 'src/tests/fastcgi.cpp') diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp new file mode 100644 index 0000000..53dd68a --- /dev/null +++ b/src/tests/fastcgi.cpp @@ -0,0 +1,81 @@ +#include "bu/fastcgi.h" + +class Cgi : public Bu::FastCgi +{ +public: + Cgi() : + Bu::FastCgi::FastCgi() + { + } + + Cgi( int iPort ) : + Bu::FastCgi::FastCgi( iPort ) + { + } + + virtual ~Cgi() + { + } + + virtual int request( const StrHash &hParams, + const Bu::FString &sStdIn, Bu::Stream &sStdOut, + Bu::Stream &sStdErr ) + { + Bu::FString sOut("Content-Type: text/html\r\n\r\n"); + sOut += "

Environment:

"; + char buf[2048]; + sOut += "

Cwd:

"; + sOut += "

Stdin:

"; + sOut.formatAppend("%d bytes
", sStdIn.getSize() );
+		Bu::FString sL, sR;
+		for( Bu::FString::const_iterator i = sStdIn.begin();
+			i; i++ )
+		{
+			sL.formatAppend("%02X ",
+				(unsigned int)((unsigned char)*i) );
+			if( *i < 27 )
+				sR += ". ";
+			else
+				sR.formatAppend("&#%d; ",
+					(unsigned int)((unsigned char)*i) );
+			if( sL.getSize()/3 == 8 )
+			{
+				sOut += sL + " | " + sR + "\n";
+				sL = sR = "";
+			}
+		}
+		if( sL != "" )
+		{
+			while( sL.getSize()/3 < 8 )
+				sL += "   ";
+			sOut += sL + " | " + sR + "\n";
+		}
+		sOut += "

";
+		sOut += sStdIn;
+		sOut += "
"; + sOut += "


"; + sOut += ""; + + sStdOut.write( sOut ); + + return 0; + } +}; + +int main() +{ + Cgi c( 8789 ); + + c.run(); + + return 0; +} + -- cgit v1.2.3