Skip to content

Commit

Permalink
Clean up and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Méven Car <meven.car@collabora.com>
Change-Id: I9f57ea5db4e338b04f217098ddf1c9231c8a06c7
  • Loading branch information
meven committed Dec 19, 2024
1 parent b2e464e commit 9f6a583
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
66 changes: 33 additions & 33 deletions net/HttpRequest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,25 +1455,25 @@ class Session final : public ProtocolHandlerInterface

void callOnFinished()
{
if (_onFinished)
if (!_onFinished)
return;

LOG_TRC("onFinished calling client");
auto self = shared_from_this();
try
{
LOG_TRC("onFinished calling client");
auto self = shared_from_this();
try
{
[[maybe_unused]] const auto references = self.use_count();
assert(references > 1 && "Expected more than 1 reference to http::Session.");
[[maybe_unused]] const auto references = self.use_count();
assert(references > 1 && "Expected more than 1 reference to http::Session.");

_onFinished(std::static_pointer_cast<Session>(self));
_onFinished(std::static_pointer_cast<Session>(self));

assert(self.use_count() > 1 &&
"Erroneously onFinish reset 'this'. Use 'addCallback()' on the "
"SocketPoll to reset on idle instead.");
}
catch (const std::exception& exc)
{
LOG_ERR("Error while invoking onFinished client callback: " << exc.what());
}
assert(self.use_count() > 1 &&
"Erroneously onFinish reset 'this'. Use 'addCallback()' on the "
"SocketPoll to reset on idle instead.");
}
catch (const std::exception& exc)
{
LOG_ERR("Error while invoking onFinished client callback: " << exc.what());
}
}

Expand Down Expand Up @@ -1628,23 +1628,24 @@ class Session final : public ProtocolHandlerInterface

void callOnConnectFail()
{
if (_onConnectFail) {
auto self = shared_from_this();
try
{
[[maybe_unused]] const auto references = self.use_count();
assert(references > 1 && "Expected more than 1 reference to http::Session.");
if (!_onConnectFail)
return;

_onConnectFail(std::static_pointer_cast<Session>(self));
auto self = shared_from_this();
try
{
[[maybe_unused]] const auto references = self.use_count();
assert(references > 1 && "Expected more than 1 reference to http::Session.");

assert(self.use_count() > 1 &&
"Erroneously onConnectFail reset 'this'. Use 'addCallback()' on the "
"SocketPoll to reset on idle instead.");
}
catch (const std::exception& exc)
{
LOG_ERR("Error while invoking onConnectFail client callback: " << exc.what());
}
_onConnectFail(std::static_pointer_cast<Session>(self));

assert(self.use_count() > 1 &&
"Erroneously onConnectFail reset 'this'. Use 'addCallback()' on the "
"SocketPoll to reset on idle instead.");
}
catch (const std::exception& exc)
{
LOG_ERR("Error while invoking onConnectFail client callback: " << exc.what());
}
}

Expand Down Expand Up @@ -1676,9 +1677,8 @@ class Session final : public ProtocolHandlerInterface
}

_connected = false;
if (_response) {
if (_response)
_response->finish();
}

_fd = -1; // No longer our socket fd.
}
Expand Down
2 changes: 1 addition & 1 deletion net/Socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ class StreamSocket : public Socket,

if (closed)
{
LOG_TRC("Closed. Firing onDisconnect." << "hanging up? " << (events & POLLHUP) );
LOG_TRC("Closed. Firing onDisconnect.");
_socketHandler->onDisconnect();
setClosed(disposition);
}
Expand Down
7 changes: 4 additions & 3 deletions wsd/ClientRequestDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,8 @@ bool ClientRequestDispatcher::handleWopiAccessCheckRequest(const Poco::Net::HTTP
sendResult(CheckStatus::NoScheme);
return true;
}
else if (protocol != http::Session::Protocol::HttpSsl)
// if the wopi hosts uses https, so must cool or it will have Mixed Content
else if (protocol == http::Session::Protocol::HttpSsl && !request.getURI().starts_with("https://"))
{
sendResult(CheckStatus::NotHttps);
return true;
Expand All @@ -1247,11 +1248,11 @@ bool ClientRequestDispatcher::handleWopiAccessCheckRequest(const Poco::Net::HTTP
bool wopiHostAllowed = false;
if (Util::iequal(ConfigUtil::getString("storage.wopi.alias_groups[@mode]", "first"), "first"))
// if first mode was selected and wopi Hosts are empty
// the domain is allowed, as it will be the "first"
// the domain is allowed, as it will be the effective "first" host
wopiHostAllowed = HostUtil::isWopiHostsEmpty();

if (!wopiHostAllowed) {
// port and scheme from wopi host config are currently ignored
// port and scheme from wopi host config are currently ignored by HostUtil
LOG_TRC("Wopi Access Check, matching allowed wopi host for host " << host);
wopiHostAllowed = HostUtil::allowedWopiHost(host);
}
Expand Down

0 comments on commit 9f6a583

Please sign in to comment.