Skip to content

Commit

Permalink
-removed sending the response from its destructor;
Browse files Browse the repository at this point in the history
  • Loading branch information
kamchatka-volcano committed Jul 8, 2023
1 parent 4b3b291 commit c6b1d00
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
8 changes: 0 additions & 8 deletions include/fcgi_responder/response.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ class Response{
///
explicit Response(ResponseSender sender);

///
/// \brief Destructor
/// calls the send() method
///
~Response();
Response(Response&&) noexcept;
Response& operator=(Response&&) noexcept;

///
/// \brief setData
/// Sets HTTP response data
Expand Down
8 changes: 0 additions & 8 deletions src/response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ Response::Response(ResponseSender sender)
{
}

Response::~Response()
{
send();
}

Response::Response(Response&&) noexcept = default;
Response& Response::operator=(Response&&) noexcept = default;

void Response::send()
{
if (!sender_)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class MockResponder : public Responder{
MOCK_METHOD1(sendData, void(const std::string& data));
MOCK_METHOD0(disconnect, void());
MOCK_METHOD1(doProcessRequest, void(const Request& request));
void processRequest(Request&& request, Response&&) override
void processRequest(Request&& request, Response&& response) override
{
doProcessRequest(request);
response.send();
}

void receive(const std::string& data)
Expand All @@ -50,6 +51,7 @@ class MockResponderWithTestProcessor : public Responder{
auto testMsg = request.stdIn();
std::reverse(testMsg.begin(), testMsg.end());
response.setData(testMsg);
response.send();
}
void receive(const std::string& data)
{
Expand Down

0 comments on commit c6b1d00

Please sign in to comment.