Continued work on cgi interfaces.

This commit is contained in:
Brad Arant 2025-12-09 12:29:39 -08:00
parent ac0865d2da
commit 3bd9ea124f
3 changed files with 3 additions and 54 deletions

View File

@ -56,55 +56,4 @@ namespace jet {
}
}
void Global::setupFormData(coreutils::ZString &formdata) {
coreutils::ZString boundary = formdata.goeol();
while(!formdata.eod()) {
if(formdata.ifNext("Content-Disposition: form-data;")) {
formdata.skipWhitespace();
if(formdata.ifNext("name=\"")) {
coreutils::ZString name = formdata.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
if(formdata.ifNext("\"")) {
formdata.goeol();
formdata.goeol();
coreutils::ZString data = formdata.getTokenExclude("-"); // TODO: Fix this parsing. Need a string exclusion method to check for 'boundary'.
data.trimCRLF();
formdata.ifNext(boundary);
int index = 0;
coreutils::MString namex;
do {
namex = "";
namex << name << ":" << index++;
} while(cgiVariables.count(namex) != 0);
cgiVariables[namex] = data;
if(formdata.ifNext("--"))
break;
formdata.goeol();
}
else
throw coreutils::Exception("expecting closing double quote on variable name in received CGI data.");
} else
throw coreutils::Exception("expecting name subfield in received CGI data.");
} else
throw coreutils::Exception("expecting Content-Disposition header in received CGI data.");
}
}
void Global::setupFormURLEncoded(coreutils::ZString &formdata) {
while(!formdata.eod()) {
coreutils::ZString name = formdata.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
if(formdata.ifNext("=")) {
coreutils::MString data = formdata.getTokenExclude("&");
formdata.ifNext("&");
int index = 0;
coreutils::MString namex;
do {
namex = "";
namex << name << ":" << index++;
} while(cgiVariables.count(namex) != 0);
cgiVariables[namex] = data.fromCGI();
} else
throw coreutils::Exception("expecting = after name in received CGI data.");
}
}
}

View File

@ -3,6 +3,7 @@
# include "MString.h"
# include "CGIFormattedData.h"
# include "CGIFormData.h"
# include <map>
namespace jet {
@ -27,7 +28,7 @@ namespace jet {
char *errorCursor = NULL;
coreutils::CGIFormattedData cookies;
coreutils::CGIFormData *formdata;
coreutils::CGIFormData *cgiData;
std::map<coreutils::MString, coreutils::MString> variables;
std::map<coreutils::MString, __mysql *> sessions;
std::map<coreutils::MString, coreutils::MString> headers;

View File

@ -3,8 +3,7 @@
#include "Tag.h"
#include "ZString.h"
#include "IMFRequest.h"
#include "IMFMessage.h"
//#include "IMFMessage.h"
#include <sstream>
namespace jet {