more IMF work.
This commit is contained in:
parent
fd7a9ed860
commit
2866056072
@ -10,7 +10,7 @@ namespace coreutils {
|
||||
int rc = ::read(fd, &ch, 1);
|
||||
while(ch != 'r') {
|
||||
IMFHeaderField *headerField = new IMFHeaderField(ch, fd);
|
||||
headers.add(headerField);
|
||||
headers.push_back(headerField);
|
||||
}
|
||||
rc = ::read(fd, &ch, 1);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace coreutils {
|
||||
IMFHeader(int fd);
|
||||
|
||||
private:
|
||||
std::vector<IMFHeaderField> headers;
|
||||
std::vector<IMFHeaderField*> headers;
|
||||
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace coreutils {
|
||||
int rc = 0;
|
||||
|
||||
if((ch >= 'A') && (ch <= 'Z'))
|
||||
key.write();
|
||||
key.write(ch);
|
||||
|
||||
while(ch != ':') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
|
@ -1,28 +1,26 @@
|
||||
#include "IMFMultipart.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFMultipart::IMFMultipart(int fd, ZString boundary) {
|
||||
IMFMultipart::IMFMultipart(int fd, MString boundary) {
|
||||
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;
|
||||
}
|
||||
@ -30,40 +28,14 @@ namespace coreutils {
|
||||
|
||||
}
|
||||
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;
|
||||
std::stringstream temp;
|
||||
temp << "--" << boundary;
|
||||
sections = in.split(temp.str().c_str());
|
||||
for(int ix = 0; ix < sections.size(); ++ix) {
|
||||
sections[ix].ifNext("\r\n");
|
||||
sections[ix].trimCRLF();
|
||||
Log(LOG_DEBUG_1) << "[" << sections[ix] << "].";
|
||||
if(sections[ix].equals("--"))
|
||||
sections[ix] = ZString("");
|
||||
sections[ix].ifNext("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string IMFMultipart::toString() {
|
||||
return std::string(getData(), getLength());
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace coreutils {
|
||||
class IMFMultipart {
|
||||
|
||||
public:
|
||||
IMFMultipart(int fd, ZString boundary);
|
||||
IMFMultipart(int fd, MString boundary);
|
||||
|
||||
private:
|
||||
MString boundary;
|
||||
|
@ -18,12 +18,12 @@ namespace coreutils {
|
||||
if(mode == LENGTH) {
|
||||
sprintf(contentLength, "%li", content.str().length());
|
||||
ZString conlen(contentLength);
|
||||
addHeader(IMFHeader("Content-Length", conlen));
|
||||
// addHeader(IMFHeader("Content-Length", conlen));
|
||||
}
|
||||
else
|
||||
addHeader(IMFHeader("Transfer-Encoding", "chunked"));
|
||||
|
||||
addHeader(IMFHeader("Server", "JETServer v0.0.1"));
|
||||
// addHeader(IMFHeader("Server", "JETServer v0.0.1"));
|
||||
|
||||
output(response);
|
||||
response << content.str();
|
||||
|
@ -87,6 +87,7 @@ namespace coreutils {
|
||||
ZString code;
|
||||
ZString text;
|
||||
|
||||
char contentLength[32];
|
||||
const char *CRLF = "\r\n";
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user