Merge branch 'branch_1' of https://github.com/waga-git/Simple-Web-Server
This commit is contained in:
commit
b841331023
1 changed files with 23 additions and 6 deletions
|
|
@ -78,7 +78,8 @@ namespace SimpleWeb {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
std::string method, path, http_version;
|
std::string method, path, protocol, http_version;
|
||||||
|
bool con_close;
|
||||||
|
|
||||||
Content content;
|
Content content;
|
||||||
|
|
||||||
|
|
@ -301,11 +302,20 @@ namespace SimpleWeb {
|
||||||
if((path_end=line.find(' ', method_end+1))!=std::string::npos) {
|
if((path_end=line.find(' ', method_end+1))!=std::string::npos) {
|
||||||
request->method=line.substr(0, method_end);
|
request->method=line.substr(0, method_end);
|
||||||
request->path=line.substr(method_end+1, path_end-method_end-1);
|
request->path=line.substr(method_end+1, path_end-method_end-1);
|
||||||
if((path_end+6)<line.size())
|
|
||||||
request->http_version=line.substr(path_end+6, line.size()-(path_end+6)-1);
|
request->con_close = false;
|
||||||
|
request->protocol.clear();
|
||||||
|
request->http_version.clear();
|
||||||
|
|
||||||
|
size_t proto_end;
|
||||||
|
if((proto_end=line.find('/', path_end+1))!=std::string::npos) {
|
||||||
|
request->protocol=line.substr(path_end+1, proto_end-path_end-1);
|
||||||
|
request->http_version=line.substr(proto_end+1, line.size()-(proto_end)-1);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
request->http_version="1.0";
|
request->http_version="1.0";
|
||||||
|
|
||||||
|
|
||||||
getline(stream, line);
|
getline(stream, line);
|
||||||
size_t param_end;
|
size_t param_end;
|
||||||
while((param_end=line.find(':'))!=std::string::npos) {
|
while((param_end=line.find(':'))!=std::string::npos) {
|
||||||
|
|
@ -313,8 +323,15 @@ namespace SimpleWeb {
|
||||||
if((value_start)<line.size()) {
|
if((value_start)<line.size()) {
|
||||||
if(line[value_start]==' ')
|
if(line[value_start]==' ')
|
||||||
value_start++;
|
value_start++;
|
||||||
if(value_start<line.size())
|
if(value_start<line.size()) {
|
||||||
request->header.insert(std::make_pair(line.substr(0, param_end), line.substr(value_start, line.size()-value_start-1)));
|
std::string key = line.substr(0, param_end);
|
||||||
|
std::string value = line.substr(value_start, line.size()-value_start-1);
|
||||||
|
|
||||||
|
request->header.insert(std::make_pair(key, value));
|
||||||
|
|
||||||
|
if(boost::iequals(key, "Connection") && boost::iequals(value, "close"))
|
||||||
|
request->con_close = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getline(stream, line);
|
getline(stream, line);
|
||||||
|
|
@ -377,7 +394,7 @@ namespace SimpleWeb {
|
||||||
catch(const std::exception &e) {
|
catch(const std::exception &e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(http_version>1.05)
|
if(http_version>1.05 && !request->con_close)
|
||||||
read_request_and_content(socket);
|
read_request_and_content(socket);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue