If C++ is not the way you wish todo CGI try these resources instead.
interface:
construction destruction
CGI( );
~CGI( );
return the data in a post query represented by "valuename"
returns true on success.
if the 'post' query has encoding "multipart/form-data"
"filedata" will hold the data represented by "valuename" and "data" will be the name
sent to the web server of that file without path information.
if this is not a "multipart/form-data" encoding "data" will hold the
data represented by "valuename".
To use for file uploading, the form in the html file that sends the data will need
to look something like this:
<form method="post" action="/cgi-bin/my.cgi" enctype="multipart/form-data">
<input type="submit" value="Upload">
<input type="file" name="file1">
</form>
now to get this data:
CGI cgi;
std::vector<char> filecontents;
std::string filename;
if(cgi.GetValue("file1", filecontents, filename) {
// now do something with the data.
}
bool GetValue(const string& valuename,
vector<char>& filedata,
string& data) const;
If the ENCTYPE of the form is "application/x-www-form-urlencoded"
bool GetValue(const string& valuename, string& value) const;
return the standard input in a vector. This is set on a post query
const vector& StdInput( ) const;
return the environment variables set by the Web Server
string Document_Root( ) const;
string Http_Accept( ) const;
string Http_Accept_Encoding ( ) const;
string Http_Accept_Language( ) const;
string Http_Connection( ) const;
string Http_Host( ) const;
string Http_Referer( ) const;
string Http_User_Agent( ) const;
string Http_Cache_Control( ) const;
string Path( ) const;
string Script_Filename( ) const;
string Script_Name( ) const;
string Server_Addr( ) const;
string Server_Admin( ) const;
string Server_Name( ) const;
string Server_Signature( ) const;
string Server_Software( ) const;
string Server_Protocol( ) const;
string Request_Method( ) const;
string Request_Uri( ) const;
string Gateway_Interface( ) const;
string Query_String( ) const;
string Content_Type( ) const;
string Http_Cookie( ) const;
string Auth_Type( ) const;
string Remote_Addr( ) const;
int Remote_Port( ) const;
int Server_Port( ) const;
unsigned long Content_Length( ) const;
SSL specific environment
string Https( ) const;
string Ssl_Cipher( ) const;
string Ssl_Protocol( ) const;
string Ssl_Version_Library( ) const;
string Ssl_Session_Id( ) const;
string Ssl_Version_Interface( ) const;
int Ssl_Cipher_Usekeysize( ) const;
int Ssl_Cipher_Algkeysize( ) const;
string Ssl_Cipher_Export( ) const;
string Ssl_Server_Cert( ) const;
string Ssl_Server_V_Start( ) const;
string Ssl_Server_V_End( ) const;
string Ssl_Server_M_Serial( ) const;
string Ssl_Server_A_Key( ) const;
string Ssl_Server_A_Sig( ) const;
string Ssl_Server_S_Dn( ) const;
string Ssl_Server_S_Dn_Cn( ) const;
string Ssl_Server_S_Dn_Email( ) const;
string Ssl_Server_S_Dn_O( ) const;
string Ssl_Server_S_Dn_Ou( ) const;
string Ssl_Server_S_Dn_C( ) const;
string Ssl_Server_S_Dn_Sp( ) const;
string Ssl_Server_S_Dn_T( ) const;
string Ssl_Server_S_Dn_I( ) const;
string Ssl_Server_S_Dn_G( ) const;
string Ssl_Server_S_Dn_S( ) const;
string Ssl_Server_S_Dn_D( ) const;
string Ssl_Server_S_Dn_Uid( ) const;
string Ssl_Server_S_Dn_St( ) const;
string Ssl_Server_S_Dn_L( ) const;
string Ssl_Server_I_Dn( ) const;
string Ssl_Server_I_Dn_Cn( ) const;
string Ssl_Server_I_Dn_Email( ) const;
string Ssl_Server_I_Dn_O( ) const;
string Ssl_Server_I_Dn_Ou( ) const;
string Ssl_Server_I_Dn_C( ) const;
string Ssl_Server_I_Dn_Sp( ) const;
string Ssl_Server_I_Dn_T( ) const;
string Ssl_Server_I_Dn_I( ) const;
string Ssl_Server_I_Dn_G( ) const;
string Ssl_Server_I_Dn_S( ) const;
string Ssl_Server_I_Dn_D( ) const;
string Ssl_Server_I_Dn_Uid( ) const;
string Ssl_Server_I_Dn_St( ) const;
string Ssl_Server_I_Dn_L( ) const;
string Ssl_Client_Cert( ) const;
string Ssl_Client_Verify( ) const;
string Ssl_Client_V_Start( ) const;
string Ssl_Client_V_End( ) const;
string Ssl_Client_M_Version( ) const;
string Ssl_Client_M_Serial( ) const;
string Ssl_Client_A_Key( ) const;
string Ssl_Client_A_Sig( ) const;
string Ssl_Client_S_Dn( ) const;
string Ssl_Client_S_Dn_Cn( ) const;
string Ssl_Client_S_Dn_Email( ) const;
string Ssl_Client_S_Dn_O( ) const;
string Ssl_Client_S_Dn_Ou( ) const;
string Ssl_Client_S_Dn_C( ) const;
string Ssl_Client_S_Dn_Sp( ) const;
string Ssl_Client_S_Dn_T( ) const;
string Ssl_Client_S_Dn_I( ) const;
string Ssl_Client_S_Dn_G( ) const;
string Ssl_Client_S_Dn_S( ) const;
string Ssl_Client_S_Dn_D( ) const;
string Ssl_Client_S_Dn_Uid( ) const;
string Ssl_Client_S_Dn_St( ) const;
string Ssl_Client_S_Dn_L( ) const;
string Ssl_Client_I_Dn( ) const;
string Ssl_Client_I_Dn_Cn( ) const;
string Ssl_Client_I_Dn_Email( ) const;
string Ssl_Client_I_Dn_O( ) const;
string Ssl_Client_I_Dn_Ou( ) const;
string Ssl_Client_I_Dn_C( ) const;
string Ssl_Client_I_Dn_Sp( ) const;
string Ssl_Client_I_Dn_T( ) const;
string Ssl_Client_I_Dn_I( ) const;
string Ssl_Client_I_Dn_G( ) const;
string Ssl_Client_I_Dn_S( ) const;
string Ssl_Client_I_Dn_D( ) const;
string Ssl_Client_I_Dn_Uid( ) const;
string Ssl_Client_I_Dn_St( ) const;
string Ssl_Client_I_Dn_L( ) const;
helper function.
translate data from a normal non file upload "post" query
i.e. the string "Hello%20World" returns "Hello World"
string escape(const string& str) const;