From 887def949008d8b2ceb3d7d9b001c60f80d5e840 Mon Sep 17 00:00:00 2001 From: Ilya Tsybulsky <60840213+tsilia@users.noreply.github.com> Date: Thu, 2 Jul 2020 00:09:43 +0300 Subject: [PATCH] Fix logger never called when write_content_with_provider returns false (#549) --- httplib.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/httplib.h b/httplib.h index 2120dbf..a5999c2 100644 --- a/httplib.h +++ b/httplib.h @@ -3908,13 +3908,14 @@ inline bool Server::write_response(Stream &strm, bool close_connection, strm.write(data.data(), data.size()); // Body + auto ret = true; if (req.method != "HEAD") { if (!res.body.empty()) { - if (!strm.write(res.body)) { return false; } + if (!strm.write(res.body)) { ret = false; } } else if (res.content_provider_) { if (!write_content_with_provider(strm, req, res, boundary, content_type)) { - return false; + ret = false; } } } @@ -3922,7 +3923,7 @@ inline bool Server::write_response(Stream &strm, bool close_connection, // Log if (logger_) { logger_(req, res); } - return true; + return ret; } inline bool