From 26440d94f1ea4c75cf9a450eeb9c7c2a70f8ec4e Mon Sep 17 00:00:00 2001 From: hagen Date: Fri, 26 Aug 2016 14:00:00 +0000 Subject: [PATCH] * HTTPServer : keep response data for async_write() --- HTTPServer.cpp | 4 ++-- HTTPServer.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 52ef09e3..309e3f6b 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -762,8 +762,8 @@ namespace http { reply.add_header("Content-Type", "text/html"); reply.body = content; - std::string res = reply.to_string(); - boost::asio::async_write (*m_Socket, boost::asio::buffer(res), + m_SendBuffer = reply.to_string(); + boost::asio::async_write (*m_Socket, boost::asio::buffer(m_SendBuffer), std::bind (&HTTPConnection::Terminate, shared_from_this (), std::placeholders::_1)); } diff --git a/HTTPServer.h b/HTTPServer.h index bf7f5c65..5246af8b 100644 --- a/HTTPServer.h +++ b/HTTPServer.h @@ -31,6 +31,7 @@ namespace http { boost::asio::deadline_timer m_Timer; char m_Buffer[HTTP_CONNECTION_BUFFER_SIZE + 1]; size_t m_BufferLen; + std::string m_SendBuffer; bool needAuth; std::string user; std::string pass;