Skip to content
Snippets Groups Projects
Commit 0620c2bc authored by Jan Loennechen's avatar Jan Loennechen
Browse files

Add try/catch to fix server crash on invalid HTTP-version number.

parent 260755ec
Branches master
No related tags found
No related merge requests found
...@@ -762,11 +762,18 @@ namespace SimpleWeb { ...@@ -762,11 +762,18 @@ namespace SimpleWeb {
return; return;
} }
} }
try {
if(std::stof(response->session->request->http_version) >= 1.1) { if(std::stof(response->session->request->http_version) >= 1.1) {
auto new_session = std::make_shared<Session>(this->config.max_request_streambuf_size, response->session->connection); auto new_session = std::make_shared<Session>(this->config.max_request_streambuf_size, response->session->connection);
this->read(new_session); this->read(new_session);
return; return;
} }
}catch(const std::invalid_argument &ex) {
std::cerr << "HTTP-version number must float (please read documentation). Defaulting to 1.1" << std::endl;
}
catch(const std::out_of_range &ex) {
std::cerr << "HTTP-version number is too large (please read documentation). Defaulting to 1.1" << std::endl;
}
} }
else if(this->on_error) else if(this->on_error)
this->on_error(response->session->request, ec); this->on_error(response->session->request, ec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment