diff --git a/server_http.hpp b/server_http.hpp index c6402f50c2ac1a52ac4c961da81e361711ebfbc4..bd4b7dc5a86ecf8107ab5022591cb0c2179d7e2b 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -762,10 +762,19 @@ namespace SimpleWeb { return; } } - 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; + + 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(std::invalid_argument &e) { + std::cout << "HTTP version not valid (string)"; + } + catch(std::out_of_range &e) { + std::cout << "HTTP version not valid (out of range)"; } } else if(this->on_error)