Reponse: Fix incomplete implementation in write
Write function in http_response.hpp missing implementation for first
write after changing from filebody.
Usecase:
Current resonse type is filebody. Developer tries to change the body
type to stringbody by calling write function.
Observed:
The write fails to update the body type.
Expected:
Write should succeed and body should change to string body.
Tested:
Unit test has been added for crow::Response.
Manual sanity test done for file offloads using curl.
Change-Id: Icbf8585b5b04c3ac5120d7b334c13d89ed3eb4aa
Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>
diff --git a/http/http_response.hpp b/http/http_response.hpp
index a5f95a9..ec54a90 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -12,7 +12,7 @@
#include <optional>
#include <string>
#include <string_view>
-
+#include <utility>
namespace crow
{
@@ -262,7 +262,10 @@
str->body() += bodyPart;
return;
}
- response.emplace<string_response>(result(), 11, std::move(bodyPart));
+ http::header<false> headTemp = std::move(fields());
+ string_response& stringResponse =
+ response.emplace<string_response>(std::move(headTemp));
+ stringResponse.body() = std::move(bodyPart);
}
void end()