summaryrefslogtreecommitdiff
path: root/src/tests/fastcgi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/fastcgi.cpp')
-rw-r--r--src/tests/fastcgi.cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp
deleted file mode 100644
index 7447a6f..0000000
--- a/src/tests/fastcgi.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/fastcgi.h"
9
10#include <unistd.h>
11
12class Cgi : public Bu::FastCgi
13{
14public:
15 Cgi() :
16 Bu::FastCgi::FastCgi()
17 {
18 }
19
20 Cgi( int iPort ) :
21 Bu::FastCgi::FastCgi( iPort )
22 {
23 }
24
25 virtual ~Cgi()
26 {
27 }
28
29 virtual int onRequest( const StrHash &hParams,
30 const Bu::String &sStdIn, Bu::Stream &sStdOut,
31 Bu::Stream &/*sStdErr*/ )
32 {
33 Bu::String sOut("Content-Type: text/html\r\n\r\n");
34 sOut += "<html><body><h1>Environment:</h1><ul>";
35 for( StrHash::const_iterator i = hParams.begin(); i; i++ )
36 {
37 sOut += "<li>" + i.getKey() + " = " +
38 i.getValue() + "</li>";
39 }
40 sOut += "</ul>";
41 char buf[2048];
42 sOut += "<h1>Cwd:</h1><ul><li>";
43 sOut += getcwd( buf, 2048 );
44 sOut += "</li></ul>";
45 sOut += "<h1>Stdin:</h1>";
46 sOut += Bu::String("%1 bytes<pre>").arg( sStdIn.getSize() );
47 Bu::String sL, sR;
48 for( Bu::String::const_iterator i = sStdIn.begin();
49 i; i++ )
50 {
51 sL += Bu::String("%1").arg(
52 (unsigned int)((unsigned char)*i), Bu::Fmt::hex().width(2).fill('0') );
53 if( *i < 27 )
54 sR += ". ";
55 else
56 sR += Bu::String("&#%1; ").arg(
57 (unsigned int)((unsigned char)*i) );
58 if( sL.getSize()/3 == 8 )
59 {
60 sOut += sL + " | " + sR + "\n";
61 sL = sR = "";
62 }
63 }
64 if( sL != "" )
65 {
66 while( sL.getSize()/3 < 8 )
67 sL += " ";
68 sOut += sL + " | " + sR + "\n";
69 }
70 sOut += "</pre><hr/><pre>";
71 sOut += sStdIn;
72 sOut += "</pre>";
73 sOut += "<form method=\"post\" enctype=\"multipart/form-data\"><textarea name=\"bob\"></textarea><br /><input type=\"file\" name=\"somefile\" /><br /><input type=\"submit\" name=\"yeah\" value=\"try it\" /></form>";
74 sOut += "</body></html>";
75
76 sStdOut.write( sOut );
77
78 return 0;
79 }
80};
81
82int main()
83{
84 Cgi c( 8789 );
85
86 c.run();
87
88 return 0;
89}
90