allow cookie, header and stream only in cgi mode.
This commit is contained in:
parent
8b49bf39a9
commit
edebae34b1
1
Global.h
1
Global.h
@ -31,6 +31,7 @@ namespace jet {
|
||||
std::map<coreutils::MString, coreutils::MString> headers;
|
||||
std::map<coreutils::MString, coreutils::MString> tags;
|
||||
char **envp;
|
||||
bool cgi = false;
|
||||
|
||||
};
|
||||
|
||||
|
2
TODO.txt
2
TODO.txt
@ -1,9 +1,7 @@
|
||||
|
||||
1) Allow keyword variables to be resolved with a ';resolve' modifier.
|
||||
2) Only allow stream tag in CGI mode.
|
||||
3) Create a method to upload a file directly to a file name to bypass
|
||||
buffering on large files.
|
||||
4) Allow the cookie tag only if CGI mode selected.
|
||||
5) Call tag is acting wierd. Look at testcall.jet.
|
||||
6) Create a tag for uploading of URL data to a specific file instead
|
||||
of buffering in an internal variable. Use <upload />. See testcgi.jet
|
||||
|
@ -8,6 +8,8 @@ namespace jet {
|
||||
|
||||
__cookie::__cookie(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
output = false;
|
||||
if(!global.cgi)
|
||||
throw coreutils::Exception("must enable cgi mode on jet tag to use cookie tag.");
|
||||
if(!keywordDefined("name"))
|
||||
throw coreutils::Exception("header tag must have name defined.");
|
||||
if(!keywordDefined("expr") && keywordDefined("value") && hasContainer)
|
||||
|
@ -11,21 +11,24 @@ namespace jet {
|
||||
|
||||
std::ofstream outFile(keywords["file"].str());
|
||||
|
||||
if(global.cgi) {
|
||||
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 = local->variables.begin(); i != local->variables.end(); i++)
|
||||
outFile << i->first << "=[" << i->second << "]" << std::endl;
|
||||
|
||||
outFile << "*** KEYWORD VALUES ***" << std::endl;
|
||||
for (auto i = parent->keywords.begin(); i != parent->keywords.end(); i++)
|
||||
outFile << i->first << "=[" << i->second << "]" << std::endl;
|
||||
|
||||
outFile.close();
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ namespace jet {
|
||||
|
||||
__header::__header(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
output = false;
|
||||
if(!global.cgi)
|
||||
throw coreutils::Exception("must enable cgi mode on jet tag to use header tag.");
|
||||
if(!keywordDefined("name"))
|
||||
throw coreutils::Exception("header tag must have name defined.");
|
||||
if(!keywordDefined("expr") && keywordDefined("value") && hasContainer)
|
||||
|
@ -7,6 +7,7 @@ namespace jet {
|
||||
|
||||
__jet::__jet(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
if(keywordDefined("cgi") && (keywords[resolveKeyword("cgi")] == "true")) {
|
||||
global.cgi = true;
|
||||
coreutils::ZString requestMethod(getenv("REQUEST_METHOD"));
|
||||
if(requestMethod == "POST") {
|
||||
coreutils::ZString contentLength(getenv("CONTENT_LENGTH"));
|
||||
|
@ -7,6 +7,8 @@ namespace jet {
|
||||
|
||||
__stream::__stream(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
output = false;
|
||||
if(!global.cgi)
|
||||
throw coreutils::Exception("must enable cgi mode on jet tag to use stream tag.");
|
||||
if(!keywordDefined("name"))
|
||||
throw coreutils::Exception("stream tag must have a file name to stream.");
|
||||
global.outputHeaders();
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!../jet-2.0
|
||||
<jet>
|
||||
This is output
|
||||
<stream name="test" />
|
||||
</jet>
|
||||
|
@ -1,11 +1,19 @@
|
||||
#!../jet-2.0
|
||||
<jet filterblanklines="true" trimlines="true">
|
||||
<tag name="testform">
|
||||
<tag name="field">
|
||||
<input name="field">
|
||||
<container />
|
||||
</input>
|
||||
</tag>
|
||||
<form>
|
||||
<container />
|
||||
</form>
|
||||
</tag>
|
||||
<testform>
|
||||
zzz
|
||||
<field>
|
||||
xxx
|
||||
</field>
|
||||
</testform>
|
||||
</jet>
|
||||
|
Loading…
x
Reference in New Issue
Block a user