significant work on cookies and cgi formdata variables.

This commit is contained in:
Brad Arant 2025-03-18 16:46:20 -07:00
parent bd5223ca36
commit 9cd8381845
6 changed files with 37 additions and 62 deletions

View File

@ -7,23 +7,20 @@ namespace coreutils {
CGIFormattedData::CGIFormattedData(ZString cgiData) {
cgiData.split("&");
for(int ix = 1; ix < cgiData.getList().size(); ++ix) {
cgiData[0].split("=");
data[cgiData[0]] = cgiData[1];
data[cgiData[0]].fromCGI();
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
cgiData[ix].split("=");
data[cgiData[ix][0]] = cgiData[ix][1];
data[cgiData[ix][0]].fromCGI();
}
}
ZString CGIFormattedData::operator=(ZString cgiData) {
std::cout << "000" << std::endl;
cgiData.split("&");
std::cout << "001" << std::endl;
for(int ix = 1; ix < cgiData.getList().size(); ++ix) {
cgiData[0].split("=");
data[cgiData[0]] = cgiData[1];
data[cgiData[0]].fromCGI();
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
cgiData[ix].split("=");
data[cgiData[ix][0]] = cgiData[ix][1];
data[cgiData[ix][0]].fromCGI();
}
std::cout << "002" << std::endl;
return cgiData;
}

View File

@ -5,11 +5,8 @@
namespace coreutils {
IMFFormData::IMFFormData(int fd, ZString boundary) {
std::cout << "030" << std::endl;
IMFHeader header(fd);
std::cout << "031" << std::endl;
IMFText text(fd, boundary);
std::cout << "032" << std::endl;
}
}

View File

@ -7,16 +7,12 @@ namespace coreutils {
IMFHeader::IMFHeader(int fd) {
char ch;
std::cout << "040" << std::endl;
int rc = ::read(fd, &ch, 1);
while(ch != '\r') {
std::cout << (char)ch << std::endl;
IMFHeaderField *headerField = new IMFHeaderField(ch, fd);
headers.push_back(headerField);
}
std::cout << "041: " << ch << std::endl;
rc = ::read(fd, &ch, 1);
std::cout << "042: " << ch << std::endl;
}
}

View File

@ -8,32 +8,26 @@ namespace coreutils {
IMFHeaderField::IMFHeaderField(char &ch, int fd) {
int rc = 0;
std::cout << "050" << std::endl;
if((ch >= 'A') && (ch <= 'Z'))
key.write(ch);
while(ch != ':') {
while(((ch >= 'A') && (ch <= 'Z')) ||
((ch >= 'a') && (ch <= 'z')) ||
((ch >= '0') && (ch <= '9')) ||
(ch == '-') || (ch == '_')) {
key.write(ch);
rc = ::read(fd, &ch, 1);
if(ch != ':')
key.write(ch);
}
std::cout << "051: " << key << std::endl;
if(ch != ':')
throw coreutils::Exception("expecting ':' in data stream.");
rc = ::read(fd, &ch, 1);
while(ch == ' ')
rc = ::read(fd, &ch, 1);
rc = ::read(fd, &ch, 1);
while(ch != '\r') {
value.write(ch);
rc = ::read(fd, &ch, 1);
if(ch != '\r')
value.write(ch);
}
std::cout << "052: " << value << std::endl;
rc = ::read(fd, &ch, 1);
std::cout << "053" << std::endl;
if(ch != '\n')
throw coreutils::Exception("expecting '\n' in data stream.");
rc = ::read(fd, &ch, 1);
}
}

View File

@ -1,28 +1,24 @@
#include "IMFMultipart.h"
#include "Log.h"
#include "Exception.h"
#include <unistd.h>
namespace coreutils {
IMFMultipart::IMFMultipart(int fd, MString boundary) {
int ch = 0;
char ch = 0;
int rc = 0;
std::cout << "020" << std::endl;
while((ch != '\r') && (ch != '\n')) {
rc = ::read(fd, &ch, 1);
if((ch != '\r') && (ch != '\n'))
std::cout << (char)ch;
boundary.write(ch);
}
if(ch == '\r') {
std::cout << std::endl;
rc = ::read(fd, &ch, 1);
}
while(1) {
std::cout << "021: " << boundary << std::endl;
IMFFormData *formData = new IMFFormData(fd, boundary);
std::cout << "022" << std::endl;
rc = ::read(fd, &ch, 1);
if(ch == '-') {
@ -30,16 +26,12 @@ namespace coreutils {
if(ch == '-') {
break;
}
} else if(ch == '\r') {
rc = ::read(fd, &ch, 1);
if(ch != '\n')
coreutils::Exception("expecting '\n' in data stream.");
}
}
rc = ::read(fd, &ch, 1);
if(ch == '\r') {
rc = ::read(fd, &ch, 1);
if(ch == '\n') {
}
}
}
}
}

View File

@ -4,21 +4,20 @@
namespace coreutils {
IMFText::IMFText(int fd, ZString boundary) : MString() {
int ch = 0;
char ch = 0;
int rc = 0;
char *endcursor;
char *index = boundary.getData();
boundary.reset();
int blen = boundary.getLength() + 1;
while(1) {
rc = ::read(fd, &ch, 1);
if(ch == *index) {
++index;
ZString check(index, index - endcursor);
if(check == boundary) {
rc = ::read(fd, &ch, 1);
if(boundary.nextChar() == ch) {
if(boundary.eod()) {
length -= blen;
break;
}
} else {
endcursor = index;
} else {
boundary.reset();
}
write(ch);
}