connection use setter for completeRequestHandler

The Connection object used to set the response object public member.
However, it is cleaner when public interfaces are used.

Change-Id: Ib16950f174106e5fd22aad874f09f31704283ad1
Signed-off-by: John Edward Broadbent <jebr@google.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 4df9300..a1a7045 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -84,7 +84,7 @@
 
     ~Connection()
     {
-        res.completeRequestHandler = nullptr;
+        res.setCompleteRequestHandler(nullptr);
         cancelDeadlineTimer();
 #ifdef BMCWEB_ENABLE_DEBUG
         connectionCount--;
@@ -337,7 +337,7 @@
 
         if (!isInvalidRequest)
         {
-            res.completeRequestHandler = [] {};
+            res.setCompleteRequestHandler(nullptr);
             res.isAliveHelper = [this]() -> bool { return isAlive(); };
 
             req->ioService = static_cast<decltype(req->ioService)>(
@@ -346,10 +346,10 @@
             if (!res.completed)
             {
                 needToCallAfterHandlers = true;
-                res.completeRequestHandler = [self(shared_from_this())] {
+                res.setCompleteRequestHandler([self(shared_from_this())] {
                     boost::asio::post(self->adaptor.get_executor(),
                                       [self] { self->completeRequest(); });
-                };
+                });
                 if (req->isUpgrade() &&
                     boost::iequals(
                         req->getHeaderValue(boost::beast::http::field::upgrade),
@@ -358,7 +358,7 @@
                     handler->handleUpgrade(*req, res, std::move(adaptor));
                     // delete lambda with self shared_ptr
                     // to enable connection destruction
-                    res.completeRequestHandler = nullptr;
+                    res.setCompleteRequestHandler(nullptr);
                     return;
                 }
                 auto asyncResp = std::make_shared<bmcweb::AsyncResp>(res);
@@ -432,7 +432,7 @@
 
             // delete lambda with self shared_ptr
             // to enable connection destruction
-            res.completeRequestHandler = nullptr;
+            res.setCompleteRequestHandler(nullptr);
             return;
         }
         if (res.body().empty() && !res.jsonValue.empty())
@@ -472,7 +472,7 @@
 
         // delete lambda with self shared_ptr
         // to enable connection destruction
-        res.completeRequestHandler = nullptr;
+        res.setCompleteRequestHandler(nullptr);
     }
 
     void readClientIp()
diff --git a/http/http_response.hpp b/http/http_response.hpp
index 72ff9e9..a983d4a 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -136,6 +136,11 @@
         return isAliveHelper && isAliveHelper();
     }
 
+    void setCompleteRequestHandler(std::function<void()> newHandler)
+    {
+        completeRequestHandler = std::move(newHandler);
+    }
+
   private:
     bool completed{};
     std::function<void()> completeRequestHandler;