CoreUtils/IMFRequest.cpp
2020-03-03 15:46:24 -08:00

53 lines
1.2 KiB
C++

#include "IMFRequest.h"
#include "Exception.h"
#include "Log.h"
namespace coreutils {
IMFRequest::IMFRequest() {}
IMFRequest::IMFRequest(PString &in) {
method = in.getTokenExclude(" ");
if(!in.ifNext(" "))
throw coreutils::Exception("Expecting space after method.");
uri = in.getTokenExclude(" ");
if(!in.ifNext(" "))
throw coreutils::Exception("Expecting space after URI.");
protocol = in.getTokenExclude("\r\n");
coreutils::Log(coreutils::LOG_DEBUG_4) << "[" << in.str() << "]";
if(!in.ifNext("\r\n"))
throw coreutils::Exception("Expecting CRLF after protocol.");
}
std::string IMFRequest::getMethod() {
return method;
}
void IMFRequest::setMethod(std::string method) {
this->method = method;
}
std::string IMFRequest::getURI() {
return uri;
}
void IMFRequest::setURI(std::string uri) {
this->uri = uri;
}
std::string IMFRequest::getProtocol() {
return protocol;
}
void IMFRequest::setProtocol(std::string protocol) {
this->protocol = protocol;
}
void IMFRequest::output(std::stringstream &out) {
out << method << " " << uri << " " << protocol << "\r\n";
}
}