wsd: remove sendWithDateAndAgent

The explicit header entries were needed
with Poco, but since we always set them
in our http::Response constructor, these
are redundant.

Change-Id: Ifde48fd3048018747dae3e84560b31960e511a25
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
pull/8581/head
Ashod Nakashian 2024-03-18 06:23:41 -04:00 committed by Ashod Nakashian
parent 7fb6ccf4ee
commit 882350ed70
6 changed files with 7 additions and 16 deletions

View File

@ -934,6 +934,10 @@ public:
/// Serializes the Server Response into the given buffer.
bool writeData(Buffer& out) const
{
assert(!get("Date").empty() && "Date is always set in http::Response ctor");
assert(get("Server") == http::getServerString() &&
"Server Agent is always set in http::Response ctor");
_statusLine.writeData(out);
_header.writeData(out);
out.append("\r\n"); // End of header.

View File

@ -809,15 +809,6 @@ void StreamSocket::dumpState(std::ostream& os)
_outBuffer.dumpHex(os, "\t\toutBuffer:\n", "\t\t");
}
void StreamSocket::sendWithDateAndAgent(http::Response& response)
{
assert(response.get("Server") == http::getServerString() &&
"Server Agent is always set in http::Response ctor");
assert(!response.get("Date").empty() && "Date is always set in http::Response ctor");
send(response);
}
bool StreamSocket::send(const http::Response& response)
{
if (response.writeData(_outBuffer))

View File

@ -1034,10 +1034,6 @@ public:
send(str.data(), str.size(), doFlush);
}
/// Sends HTTP response.
/// Adds Date and User-Agent.
void sendWithDateAndAgent(http::Response& response);
/// Send an http::Request and flush.
/// Does not add any fields to the header.
/// Will shutdown the socket upon error and return false.

View File

@ -148,7 +148,7 @@ private:
http::Response response(http::StatusCode::BadRequest);
response.setContentLength(0);
LOG_INF("DumpWebSockets bad request");
socket->sendWithDateAndAgent(response);
socket->send(response);
disposition.setClosed();
}
}

View File

@ -494,7 +494,7 @@ bool AdminSocketHandler::handleInitialRequest(
http::Response response(http::StatusCode::BadRequest);
response.setContentLength(0);
LOG_INF_S("Admin::handleInitialRequest bad request");
socket->sendWithDateAndAgent(response);
socket->send(response);
return false;
}

View File

@ -1710,7 +1710,7 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr<Message>& pay
{
http::Response response(http::StatusCode::Unauthorized);
response.set("X-ERROR-KIND", errorKind);
_saveAsSocket->sendWithDateAndAgent(response);
_saveAsSocket->send(response);
// Conversion failed, cleanup fake session.
LOG_TRC("Removing save-as ClientSession after conversion error.");