Skip to content

Commit 53631e5

Browse files
committed
try remove
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com> Change-Id: If7be4ef1283e581bcd04a9be36634750bb4f6a73
1 parent 8963ea4 commit 53631e5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

net/HttpRequest.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,8 @@ class Session final : public ProtocolHandlerInterface
14871487
{
14881488
LOG_ERR("Error while invoking onFinished client callback: " << exc.what());
14891489
}
1490+
1491+
_onFinished = nullptr;
14901492
}
14911493

14921494
/// Set up a new request and response.
@@ -1891,6 +1893,30 @@ class ServerSession final : public ProtocolHandlerInterface
18911893
/// regardless of the reason (error, timeout, completion).
18921894
void setFinishedHandler(FinishedCallback onFinished) { _onFinished = std::move(onFinished); }
18931895

1896+
std::shared_ptr<ServerSession> shared_from_this()
1897+
{
1898+
return std::static_pointer_cast<ServerSession>(ProtocolHandlerInterface::shared_from_this());
1899+
}
1900+
1901+
void callOnFinished()
1902+
{
1903+
fprintf(stderr, "ServerSession onFinished\n");
1904+
1905+
if (!_onFinished)
1906+
return;
1907+
1908+
LOG_TRC("onFinished calling client");
1909+
std::shared_ptr<ServerSession> self = shared_from_this();
1910+
try
1911+
{
1912+
_onFinished(self);
1913+
}
1914+
catch (const std::exception& exc)
1915+
{
1916+
LOG_ERR("Error while invoking onFinished client callback: " << exc.what());
1917+
}
1918+
}
1919+
18941920
using ResponseHeaders = http::Header::Container;
18951921

18961922
/// Start an asynchronous upload from a file.
@@ -2191,6 +2217,7 @@ class ServerSession final : public ProtocolHandlerInterface
21912217
}
21922218

21932219
_connected = false;
2220+
callOnFinished();
21942221
}
21952222

21962223
int sendTextMessage(const char*, const size_t, bool) const override { return 0; }

0 commit comments

Comments
 (0)