significant work on cookies and cgi formdata variables.
This commit is contained in:
parent
bd5223ca36
commit
9cd8381845
@ -7,23 +7,20 @@ namespace coreutils {
|
|||||||
|
|
||||||
CGIFormattedData::CGIFormattedData(ZString cgiData) {
|
CGIFormattedData::CGIFormattedData(ZString cgiData) {
|
||||||
cgiData.split("&");
|
cgiData.split("&");
|
||||||
for(int ix = 1; ix < cgiData.getList().size(); ++ix) {
|
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
|
||||||
cgiData[0].split("=");
|
cgiData[ix].split("=");
|
||||||
data[cgiData[0]] = cgiData[1];
|
data[cgiData[ix][0]] = cgiData[ix][1];
|
||||||
data[cgiData[0]].fromCGI();
|
data[cgiData[ix][0]].fromCGI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZString CGIFormattedData::operator=(ZString cgiData) {
|
ZString CGIFormattedData::operator=(ZString cgiData) {
|
||||||
std::cout << "000" << std::endl;
|
|
||||||
cgiData.split("&");
|
cgiData.split("&");
|
||||||
std::cout << "001" << std::endl;
|
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
|
||||||
for(int ix = 1; ix < cgiData.getList().size(); ++ix) {
|
cgiData[ix].split("=");
|
||||||
cgiData[0].split("=");
|
data[cgiData[ix][0]] = cgiData[ix][1];
|
||||||
data[cgiData[0]] = cgiData[1];
|
data[cgiData[ix][0]].fromCGI();
|
||||||
data[cgiData[0]].fromCGI();
|
|
||||||
}
|
}
|
||||||
std::cout << "002" << std::endl;
|
|
||||||
return cgiData;
|
return cgiData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,8 @@
|
|||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFFormData::IMFFormData(int fd, ZString boundary) {
|
IMFFormData::IMFFormData(int fd, ZString boundary) {
|
||||||
std::cout << "030" << std::endl;
|
|
||||||
IMFHeader header(fd);
|
IMFHeader header(fd);
|
||||||
std::cout << "031" << std::endl;
|
|
||||||
IMFText text(fd, boundary);
|
IMFText text(fd, boundary);
|
||||||
std::cout << "032" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,12 @@ namespace coreutils {
|
|||||||
|
|
||||||
IMFHeader::IMFHeader(int fd) {
|
IMFHeader::IMFHeader(int fd) {
|
||||||
char ch;
|
char ch;
|
||||||
std::cout << "040" << std::endl;
|
|
||||||
int rc = ::read(fd, &ch, 1);
|
int rc = ::read(fd, &ch, 1);
|
||||||
while(ch != '\r') {
|
while(ch != '\r') {
|
||||||
std::cout << (char)ch << std::endl;
|
|
||||||
IMFHeaderField *headerField = new IMFHeaderField(ch, fd);
|
IMFHeaderField *headerField = new IMFHeaderField(ch, fd);
|
||||||
headers.push_back(headerField);
|
headers.push_back(headerField);
|
||||||
}
|
}
|
||||||
std::cout << "041: " << ch << std::endl;
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
std::cout << "042: " << ch << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,32 +8,26 @@ namespace coreutils {
|
|||||||
|
|
||||||
IMFHeaderField::IMFHeaderField(char &ch, int fd) {
|
IMFHeaderField::IMFHeaderField(char &ch, int fd) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
while(((ch >= 'A') && (ch <= 'Z')) ||
|
||||||
std::cout << "050" << std::endl;
|
((ch >= 'a') && (ch <= 'z')) ||
|
||||||
|
((ch >= '0') && (ch <= '9')) ||
|
||||||
if((ch >= 'A') && (ch <= 'Z'))
|
(ch == '-') || (ch == '_')) {
|
||||||
key.write(ch);
|
key.write(ch);
|
||||||
|
|
||||||
while(ch != ':') {
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
if(ch != ':')
|
|
||||||
key.write(ch);
|
|
||||||
}
|
}
|
||||||
|
if(ch != ':')
|
||||||
std::cout << "051: " << key << std::endl;
|
throw coreutils::Exception("expecting ':' in data stream.");
|
||||||
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
while(ch == ' ')
|
while(ch == ' ')
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
|
|
||||||
while(ch != '\r') {
|
while(ch != '\r') {
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
if(ch != '\r')
|
|
||||||
value.write(ch);
|
value.write(ch);
|
||||||
}
|
|
||||||
std::cout << "052: " << value << std::endl;
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
std::cout << "053" << std::endl;
|
}
|
||||||
|
rc = ::read(fd, &ch, 1);
|
||||||
|
if(ch != '\n')
|
||||||
|
throw coreutils::Exception("expecting '\n' in data stream.");
|
||||||
|
rc = ::read(fd, &ch, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,28 +1,24 @@
|
|||||||
#include "IMFMultipart.h"
|
#include "IMFMultipart.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFMultipart::IMFMultipart(int fd, MString boundary) {
|
IMFMultipart::IMFMultipart(int fd, MString boundary) {
|
||||||
int ch = 0;
|
char ch = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
std::cout << "020" << std::endl;
|
|
||||||
while((ch != '\r') && (ch != '\n')) {
|
while((ch != '\r') && (ch != '\n')) {
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
if((ch != '\r') && (ch != '\n'))
|
if((ch != '\r') && (ch != '\n'))
|
||||||
std::cout << (char)ch;
|
|
||||||
boundary.write(ch);
|
boundary.write(ch);
|
||||||
}
|
}
|
||||||
if(ch == '\r') {
|
if(ch == '\r') {
|
||||||
std::cout << std::endl;
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
}
|
}
|
||||||
while(1) {
|
while(1) {
|
||||||
std::cout << "021: " << boundary << std::endl;
|
|
||||||
IMFFormData *formData = new IMFFormData(fd, boundary);
|
IMFFormData *formData = new IMFFormData(fd, boundary);
|
||||||
std::cout << "022" << std::endl;
|
|
||||||
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
if(ch == '-') {
|
if(ch == '-') {
|
||||||
@ -30,16 +26,12 @@ namespace coreutils {
|
|||||||
if(ch == '-') {
|
if(ch == '-') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if(ch == '\r') {
|
||||||
|
|
||||||
}
|
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
if(ch == '\r') {
|
if(ch != '\n')
|
||||||
rc = ::read(fd, &ch, 1);
|
coreutils::Exception("expecting '\n' in data stream.");
|
||||||
if(ch == '\n') {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
15
IMFText.cpp
15
IMFText.cpp
@ -4,21 +4,20 @@
|
|||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFText::IMFText(int fd, ZString boundary) : MString() {
|
IMFText::IMFText(int fd, ZString boundary) : MString() {
|
||||||
int ch = 0;
|
char ch = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *endcursor;
|
boundary.reset();
|
||||||
char *index = boundary.getData();
|
int blen = boundary.getLength() + 1;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
rc = ::read(fd, &ch, 1);
|
rc = ::read(fd, &ch, 1);
|
||||||
if(ch == *index) {
|
if(boundary.nextChar() == ch) {
|
||||||
++index;
|
if(boundary.eod()) {
|
||||||
ZString check(index, index - endcursor);
|
length -= blen;
|
||||||
if(check == boundary) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
endcursor = index;
|
boundary.reset();
|
||||||
}
|
}
|
||||||
write(ch);
|
write(ch);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user