Continued work on cgi interfaces.
This commit is contained in:
parent
ac0865d2da
commit
3bd9ea124f
51
Global.cpp
51
Global.cpp
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
3
Global.h
3
Global.h
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user