JetCore/__jet.cpp
2025-01-15 15:44:53 -08:00

43 lines
1.2 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") && (keywords[resolveKeyword("cgi")] == "true")) {
global.cgi = true;
if(keywordDefined("sessiondir")) {
// if request_has_cookie then
// pull sessionfile from sessiondir.
// else
// generate new session id.
// create session cookie in response.
}
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);
}
}