diff --git a/include/opendht/http.h b/include/opendht/http.h index 91c233bd68796a32c264cfca382d131fd7b044ea..d43e78cb626864e0990239811e01847a4122f410 100644 --- a/include/opendht/http.h +++ b/include/opendht/http.h @@ -192,9 +192,10 @@ private: struct Response { - unsigned int status_code; + unsigned int status_code {0}; std::map<std::string, std::string> headers; std::string body; + bool aborted {false}; }; class OPENDHT_PUBLIC Request : public std::enable_shared_from_this<Request> diff --git a/src/http.cpp b/src/http.cpp index c6b903416d6c86348a5641042a1865570bfadaaf..0017b0d05593ab844051c44e0051188fd51675d8 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -875,12 +875,14 @@ Request::terminate(const asio::error_code& ec) // set response outcome, ignore end of file and abort if (!ec or ec == asio::error::eof) - response_.status_code = 200; + response_.status_code = parser_->status_code; else response_.status_code = 0; + response_.aborted = ec == asio::error::operation_aborted; + if (logger_) - logger_->d("[http:request:%i] done", id_); + logger_->d("[http:request:%i] done with status code %u", id_, parser_->status_code); if (connection_type_ != restinio::http_connection_header_t::keep_alive) if (auto c = conn_) c->close();