Skip to content
Snippets Groups Projects
Commit 68d9cd4a authored by Randi Eggum's avatar Randi Eggum
Browse files

Added try catch when converting the http_version to a float. Should replace...

Added try catch when converting the http_version to a float. Should replace std::cout with error handling in the future.
parent 260755ec
No related branches found
No related tags found
No related merge requests found
......@@ -762,11 +762,17 @@ namespace SimpleWeb {
return;
}
}
try {
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);
this->read(new_session);
return;
}
} catch (const std::invalid_argument& ia){
std::cout << "Invalid argument in HTTP version number " << ia.what() << std::endl;
} catch (const std::out_of_range& oor){
std::cout << "Out of range in HTTP version number " << oor.what() << std::endl;
}
}
else if(this->on_error)
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