Added vscode
This commit is contained in:
parent
6894968732
commit
c00476719c
26
.vscode/tasks.json
vendored
Normal file
26
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "/home/barant/Development/HTTPServer/"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -6,10 +6,12 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFMessage::IMFMessage() {}
|
||||
|
||||
IMFMessage::IMFMessage(PString &in) {
|
||||
IMFMessage::IMFMessage() {
|
||||
body = NULL;
|
||||
first = true;
|
||||
}
|
||||
|
||||
IMFMessage::IMFMessage(PString &in) : IMFMessage() {
|
||||
parse(in);
|
||||
}
|
||||
|
||||
@ -17,6 +19,14 @@ namespace coreutils {
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_4) << "parse [" << in.str() << "]";
|
||||
|
||||
if(first) {
|
||||
if(in.str().find(" ") != std::string::npos) {
|
||||
parse(in);
|
||||
first = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(in.str() != "") {
|
||||
headers.emplace_back(in);
|
||||
return true;
|
||||
|
@ -17,7 +17,6 @@ namespace coreutils {
|
||||
bool parse(PString &in);
|
||||
|
||||
void output(std::stringstream &out);
|
||||
IMFRequest *request;
|
||||
|
||||
void addHeader(std::string key, std::string value);
|
||||
|
||||
@ -27,9 +26,13 @@ namespace coreutils {
|
||||
IMFBody *getBody();
|
||||
|
||||
protected:
|
||||
IMFRequest request;
|
||||
std::vector<IMFHeader> headers;
|
||||
IMFBody *body;
|
||||
|
||||
private:
|
||||
bool first = true;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -7,42 +7,33 @@ 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.str();
|
||||
parse(in);
|
||||
}
|
||||
|
||||
bool IMFRequest::parse(PString &in) {
|
||||
parts = in.split(" ");
|
||||
return parts.size() == 3;
|
||||
}
|
||||
|
||||
std::string IMFRequest::getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
void IMFRequest::setMethod(std::string method) {
|
||||
this->method = method;
|
||||
if(parts.size() == 3)
|
||||
return parts[0].str();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string IMFRequest::getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
void IMFRequest::setURI(std::string uri) {
|
||||
this->uri = uri;
|
||||
if(parts.size() == 3)
|
||||
return parts[1].str();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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";
|
||||
if(parts.size() == 3)
|
||||
return parts[2].str();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
15
IMFRequest.h
15
IMFRequest.h
@ -11,19 +11,14 @@ namespace coreutils {
|
||||
IMFRequest();
|
||||
IMFRequest(PString &in);
|
||||
|
||||
std::string getMethod();
|
||||
void setMethod(std::string method);
|
||||
std::string getURI();
|
||||
void setURI(std::string uri);
|
||||
std::string getProtocol();
|
||||
void setProtocol(std::string protocol);
|
||||
bool parse(PString &in);
|
||||
|
||||
void output(std::stringstream &out);
|
||||
std::string getMethod();
|
||||
std::string getURI();
|
||||
std::string getProtocol();
|
||||
|
||||
private:
|
||||
std::string method;
|
||||
std::string uri;
|
||||
std::string protocol;
|
||||
std::vector<PString> parts;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user