More development on the messaging.

This commit is contained in:
Brad Arant 2020-05-07 10:20:22 -07:00
parent f4496fc682
commit 591705f897
5 changed files with 12 additions and 15 deletions

View File

@ -13,7 +13,7 @@ namespace coreutils {
} }
void IMFMessage::parse(PString &in) { void IMFMessage::parse(PString &in) {
coreutils::Log(coreutils::LOG_DEBUG_4) << "[" << in.str() << "]"; coreutils::Log(coreutils::LOG_DEBUG_4) << "parse [" << in.str() << "]";
if(in.size() == 0) if(in.size() == 0)
return; return;

View File

@ -9,22 +9,22 @@
namespace coreutils { namespace coreutils {
class IMFMessage { class IMFMessage {
public: public:
IMFMessage(); IMFMessage();
IMFMessage(PString &in); IMFMessage(PString &in);
void parse(PString &in); void parse(PString &in);
void output(std::stringstream &out); void output(std::stringstream &out);
IMFRequest *request; IMFRequest *request;
void addHeader(std::string key, std::string value); void addHeader(std::string key, std::string value);
std::string getHeader(std::string key, bool valueOnly = true); std::string getHeader(std::string key, bool valueOnly = true);
std::string getHeaderKeyPairValue(std::string headerKey, std::string key); std::string getHeaderKeyPairValue(std::string headerKey, std::string key);
IMFBody *getBody(); IMFBody *getBody();
protected: protected:
std::vector<IMFHeader> headers; std::vector<IMFHeader> headers;

View File

@ -13,12 +13,8 @@ namespace coreutils {
uri = in.getTokenExclude(" "); uri = in.getTokenExclude(" ");
if(!in.ifNext(" ")) if(!in.ifNext(" "))
throw coreutils::Exception("Expecting space after URI."); throw coreutils::Exception("Expecting space after URI.");
protocol = in.getTokenExclude("\r"); protocol = in.str();
coreutils::Log(coreutils::LOG_DEBUG_4) << "[" << in.str() << "]";
if(!in.ifNext("\r"))
throw coreutils::Exception("Expecting CRLF after protocol.");
} }
std::string IMFRequest::getMethod() { std::string IMFRequest::getMethod() {

View File

@ -31,7 +31,7 @@ namespace coreutils {
while(pos < pstring.length()) { while(pos < pstring.length()) {
end = pstring.find(delimiter, pos); end = pstring.find(delimiter, pos);
if(end == std::string::npos) if(end == -1)
end = pstring.length(); end = pstring.length();
list.push_back(PString(pstring.substr(pos, end - pos))); list.push_back(PString(pstring.substr(pos, end - pos)));
pos = end + delimiter.size(); pos = end + delimiter.size();
@ -78,7 +78,8 @@ namespace coreutils {
int PString::skipWhitespace() { int PString::skipWhitespace() {
size_t found = pstring.find_first_not_of(" \t", cursor); size_t found = pstring.find_first_not_of(" \t", cursor);
return found != cursor::npos ? cursor + found: 0; coreutils::Log(coreutils::LOG_DEBUG_2) << "Skipping whitespace for " << found << " spaces.";
return found;
} }
int PString::size() { int PString::size() {

View File

@ -82,7 +82,7 @@ namespace coreutils {
/// ///
/// ///
void skipWhitespace(); int skipWhitespace();
/// ///
/// ///