diff --git a/Tag.cpp b/Tag.cpp index 69a2848..81b22c1 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -23,6 +23,7 @@ #include "__tag.h" #include "__dotag.h" #include "__stream.h" +#include "__dump.h" #include namespace jet { @@ -178,6 +179,9 @@ namespace jet { } else if(ifTagName(in, "stream")) { __stream _stream(in, out, global, this); continue; + } else if(ifTagName(in, "dump")) { + __dump _dump(in, out, global, this); + continue; } else if(ifTagName(in, "tag")) { __tag _tag(in, out, global, this); continue; diff --git a/__dump.cpp b/__dump.cpp new file mode 100644 index 0000000..ac4ef07 --- /dev/null +++ b/__dump.cpp @@ -0,0 +1,33 @@ +#include "__dump.h" +#include "Exception.h" +#include +#include + +namespace jet { + + __dump::__dump(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) { + if(!variableDefined("file")) + throw coreutils::Exception("file must be sppecified for dump tag."); + + std::ofstream outFile(variables["file"].str()); + + outFile << "*** CGI VARIABLES ***" << std::endl; + + for (auto i = global.cgiVariables.begin(); i != global.cgiVariables.end(); i++) + outFile << i->first << "=[" << i->second << "]" << std::endl; + + outFile << "*** GLOBAL VARIABLES ***" << std::endl; + + for (auto i = global.variables.begin(); i != global.variables.end(); i++) + outFile << i->first << "=[" << i->second << "]" << std::endl; + + outFile << "*** LOCAL VARIABLES ***" << std::endl; + + for (auto i = parent->variables.begin(); i != parent->variables.end(); i++) + outFile << i->first << "=[" << i->second << "]" << std::endl; + + outFile.close(); + + } + +} diff --git a/__dump.h b/__dump.h new file mode 100644 index 0000000..7d75db5 --- /dev/null +++ b/__dump.h @@ -0,0 +1,19 @@ +#ifndef ____dump_h__ +#define ____dump_h__ + +#include "Tag.h" +#include "MString.h" +#include "Global.h" + +namespace jet { + + class __dump : public Tag { + + public: + __dump(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent); + + }; + +} + +#endif diff --git a/__jet.cpp b/__jet.cpp index 5a7ffd0..29cdf23 100644 --- a/__jet.cpp +++ b/__jet.cpp @@ -15,12 +15,10 @@ namespace jet { coreutils::ZString contentType(getenv("CONTENT_TYPE")); std::ofstream outFile("/tmp/output.txt"); - + coreutils::MString postdata; - postdata.read(0); - outFile << postdata << std::endl; - outFile.close(); - + postdata.read(0); // TODO: Need to limit the read characters to the CONTENT-LENGTH value; + if(contentType == "multipart/form-data") global.setupFormData(postdata); else if(contentType == "application/x-www-form-urlencoded") diff --git a/tests/testpost.jet b/tests/testpost.jet index cc436fc..a659d2b 100755 --- a/tests/testpost.jet +++ b/tests/testpost.jet @@ -8,4 +8,5 @@ $[:name2] $[:name:2;tohex] $[:name:3;tohex] $[:name2;tohex] +