added dump tag.
This commit is contained in:
parent
a9ce087939
commit
1c7edf3118
4
Tag.cpp
4
Tag.cpp
@ -23,6 +23,7 @@
|
||||
#include "__tag.h"
|
||||
#include "__dotag.h"
|
||||
#include "__stream.h"
|
||||
#include "__dump.h"
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
|
33
__dump.cpp
Normal file
33
__dump.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "__dump.h"
|
||||
#include "Exception.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
}
|
19
__dump.h
Normal file
19
__dump.h
Normal file
@ -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
|
@ -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")
|
||||
|
@ -8,4 +8,5 @@ $[:name2]
|
||||
$[:name:2;tohex]
|
||||
$[:name:3;tohex]
|
||||
$[:name2;tohex]
|
||||
<dump file="/tmp/dump.txt" />
|
||||
</jet>
|
||||
|
Loading…
x
Reference in New Issue
Block a user