JetCore/__jet.cpp

32 lines
1.0 KiB
C++

#include "__jet.h"
#include "Exception.h"
#include <iostream>
#include <fstream>
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"))
resolveKeyword("cgi");
if(keywords["cgi"] == "true") {
coreutils::ZString requestMethod(getenv("REQUEST_METHOD"));
if(requestMethod == "POST") {
coreutils::ZString contentLength(getenv("CONTENT_LENGTH"));
coreutils::ZString contentType(getenv("CONTENT_TYPE"));
std::ofstream outFile("/tmp/output.txt");
coreutils::MString postdata;
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")
global.setupFormURLEncoded(postdata);
}
}
processContainer(container);
}
}