worked on IMF smartbuffers.
This commit is contained in:
parent
3f0a541e80
commit
11f396a749
@ -4,18 +4,9 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFFormData::IMFFormData() {}
|
||||
|
||||
IMFFormData::IMFFormData(ZString &in, ZString &boundary) : IMFMultipart(in, boundary) {}
|
||||
|
||||
ZString IMFFormData::getByName(ZString &name) {
|
||||
for(ZString section: sections) {
|
||||
IMFMessage message(section);
|
||||
if(message.getHeaderKeyPairValue("Content-Disposition", ("name")).equals(name)) {
|
||||
return message.multipart;
|
||||
}
|
||||
}
|
||||
return ZString();
|
||||
IMFFormData::IMFFormData(int fd, ZString boundary) {
|
||||
IMFHeader header(fd);
|
||||
IMFText text(fd, boundary);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,14 @@
|
||||
#ifndef __IMFFormData_h__
|
||||
# define __IMFFormData_h__
|
||||
|
||||
# include "IMFMultipart.h"
|
||||
#include "ZString.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFFormData: public IMFMultipart {
|
||||
class IMFFormData {
|
||||
|
||||
public:
|
||||
IMFFormData();
|
||||
IMFFormData(ZString &in, ZString &boundary);
|
||||
|
||||
ZString getByName(ZString &name);
|
||||
IMFFormData(int fd, ZString boundary);
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,33 +5,11 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFHeader::IMFHeader(ZString &in) : ZString(in) {
|
||||
|
||||
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789");
|
||||
std::cout << "key: [" << key << "]" << std::endl;
|
||||
if(key.getLength() != 0) {
|
||||
if(!in.ifNext(":"))
|
||||
throw coreutils::Exception("Invalid character in expected header token.");
|
||||
in.skipWhitespace();
|
||||
value = in.goeolwithContinuation();
|
||||
std::cout << "header: [" << value << "]" << std::endl;
|
||||
}
|
||||
else if(in.skipWhitespace() > 0) {}
|
||||
else if(in.str() == "") {}
|
||||
}
|
||||
|
||||
IMFHeader::IMFHeader(ZString key, ZString value) : ZString(), key(key), value(value) {}
|
||||
|
||||
ZString IMFHeader::getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
ZString IMFHeader::getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
void IMFHeader::output(std::stringstream &out) {
|
||||
out << key << ": " << value << "\r\n";
|
||||
IMFHeader::IMFHeader(int fd) {
|
||||
while(1) {
|
||||
headers.emplace(fd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
16
IMFHeader.h
16
IMFHeader.h
@ -1,25 +1,17 @@
|
||||
#ifndef __IMFHeader_h__
|
||||
#define __IMFHeader_h__
|
||||
|
||||
#include "ZString.h"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFHeader : public ZString {
|
||||
class IMFHeader {
|
||||
|
||||
public:
|
||||
IMFHeader(ZString &in);
|
||||
IMFHeader(ZString key, ZString value);
|
||||
|
||||
ZString getKey();
|
||||
ZString getValue();
|
||||
|
||||
void output(std::stringstream &out);
|
||||
IMFHeader(int fd);
|
||||
|
||||
private:
|
||||
ZString key;
|
||||
ZString value;
|
||||
std::vector<IMFHeaderField> headers;
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,51 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFMultipart::IMFMultipart() {}
|
||||
IMFMultipart::IMFMultipart(int fd, int length) {
|
||||
int ch = 0;
|
||||
int rc = 0;
|
||||
while((ch != '\r') && (ch != '\n')) {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if((ch != '\r') && (ch != '\n'))
|
||||
boundary.write(ch);
|
||||
}
|
||||
if(ch == '\r') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
}
|
||||
while(1) {
|
||||
sections.emplace_back(fd, boundary);
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '-') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '-') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '\r') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '\n') {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IMFMultipart::IMFMultipart(ZString &in, ZString &boundary) {
|
||||
Log(LOG_DEBUG_1) << in;
|
||||
|
@ -1,25 +1,26 @@
|
||||
#ifndef __IMFMultipart_h__
|
||||
#define __IMFMultipart_h__
|
||||
|
||||
#include "ZString.h"
|
||||
#include "MString.h"
|
||||
#include <vector>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFMultipart: public ZString {
|
||||
class IMFMultipart {
|
||||
|
||||
public:
|
||||
IMFMultipart();
|
||||
IMFMultipart(ZString &in, ZString &boundary);
|
||||
IMFMultipart(int fd, int length);
|
||||
|
||||
std::string toString();
|
||||
int getCount();
|
||||
ZString getSectionAt(int index);
|
||||
// std::string toString();
|
||||
// int getCount();
|
||||
// ZString getSectionAt(int index);
|
||||
|
||||
protected:
|
||||
std::vector<ZString> sections;
|
||||
// protected:
|
||||
// std::vector<ZString> sections;
|
||||
|
||||
private:
|
||||
char *boundary;
|
||||
MString boundary;
|
||||
std::vector<IMFFormData> sections;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user