Work on the IMFHeader and IMFMessage.

This commit is contained in:
Brad Arant 2024-11-11 15:58:58 -08:00
parent 2e8bb4a123
commit 01180021b4
5 changed files with 22 additions and 5 deletions

View File

@ -1,16 +1,20 @@
#include "IMFHeader.h" #include "IMFHeader.h"
#include "Exception.h" #include "Exception.h"
#include "Log.h" #include "Log.h"
#include <iostream>
namespace coreutils { namespace coreutils {
IMFHeader::IMFHeader(ZString &in) : ZString(in) { IMFHeader::IMFHeader(ZString &in) : ZString(in) {
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789"); key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789");
std::cout << "key: [" << key << "]" << std::endl;
if(key.getLength() != 0) { if(key.getLength() != 0) {
if(!in.ifNext(":")) if(!in.ifNext(":"))
throw coreutils::Exception("Invalid character in expected header token."); throw coreutils::Exception("Invalid character in expected header token.");
in.skipWhitespace(); in.skipWhitespace();
value = in.goeol(); value = in.goeolwithContinuation();
std::cout << "header: [" << value << "]" << std::endl;
} }
else if(in.skipWhitespace() > 0) {} else if(in.skipWhitespace() > 0) {}
else if(in.str() == "") {} else if(in.str() == "") {}

View File

@ -9,8 +9,8 @@ namespace coreutils {
IMFMessage::IMFMessage() : ZString() {} IMFMessage::IMFMessage() : ZString() {}
IMFMessage::IMFMessage(ZString &in) : ZString(in) { IMFMessage::IMFMessage(ZString &in) : ZString(in) {
while (!in.ifNext("\r\n")) while (!in.ifNext("\r\n") && in.ifNext("\n"))
headers.emplace_back(in); headers.emplace_back(in);
ZString type = getHeader("Content-Type"); ZString type = getHeader("Content-Type");

View File

@ -20,8 +20,8 @@ namespace coreutils {
public: public:
IMFMessage(); IMFMessage();
IMFMessage(ZString &in); IMFMessage(ZString &in);
virtual ~IMFMessage(); virtual ~IMFMessage();
void output(std::stringstream &out); void output(std::stringstream &out);
void addHeader(IMFHeader header); void addHeader(IMFHeader header);

View File

@ -455,6 +455,13 @@ namespace coreutils {
return ZString(temp, tempend - temp); return ZString(temp, tempend - temp);
} }
ZString ZString::goeolwithContinuation() {
ZString temp = goeol();
while(ifNextInclude(" \t"))
goeol();
return temp;
}
ZString ZString::trim() { ZString ZString::trim() {
skipWhitespace(); skipWhitespace();
return unparsed(); return unparsed();

View File

@ -329,6 +329,12 @@ namespace coreutils {
ZString goeol(); ZString goeol();
///
///
///
ZString goeolwithContinuation();
/// ///
/// ///
/// ///