Skip to content
Snippets Groups Projects
Commit 17fb9265 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

http: check parser before use

parent 294034f0
No related branches found
No related tags found
No related merge requests found
...@@ -874,7 +874,7 @@ Request::terminate(const asio::error_code& ec) ...@@ -874,7 +874,7 @@ Request::terminate(const asio::error_code& ec)
logger_->e("[http:request:%i] end with error: %s", id_, ec.message().c_str()); logger_->e("[http:request:%i] end with error: %s", id_, ec.message().c_str());
// set response outcome, ignore end of file and abort // set response outcome, ignore end of file and abort
if (!ec or ec == asio::error::eof) if ((!ec or ec == asio::error::eof) and parser_)
response_.status_code = parser_->status_code; response_.status_code = parser_->status_code;
else else
response_.status_code = 0; response_.status_code = 0;
...@@ -882,7 +882,7 @@ Request::terminate(const asio::error_code& ec) ...@@ -882,7 +882,7 @@ Request::terminate(const asio::error_code& ec)
response_.aborted = ec == asio::error::operation_aborted; response_.aborted = ec == asio::error::operation_aborted;
if (logger_) if (logger_)
logger_->d("[http:request:%i] done with status code %u", id_, parser_->status_code); logger_->d("[http:request:%i] done with status code %u", id_, response_.status_code);
if (connection_type_ != restinio::http_connection_header_t::keep_alive) if (connection_type_ != restinio::http_connection_header_t::keep_alive)
if (auto c = conn_) if (auto c = conn_)
c->close(); c->close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment