diff --git a/net/HttpRequest.hpp b/net/HttpRequest.hpp index 9e7a4db01a..098a382289 100644 --- a/net/HttpRequest.hpp +++ b/net/HttpRequest.hpp @@ -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. diff --git a/net/Socket.cpp b/net/Socket.cpp index 709c98b5af..2c7921b8d3 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -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)) diff --git a/net/Socket.hpp b/net/Socket.hpp index f85865fb48..90c754bd92 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -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. diff --git a/tools/WebSocketDump.cpp b/tools/WebSocketDump.cpp index 601ba739b2..2afdfdb534 100644 --- a/tools/WebSocketDump.cpp +++ b/tools/WebSocketDump.cpp @@ -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(); } } diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index 398fab8c48..e911b7eafd 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -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; } diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 520a992a06..8c87c3edc5 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -1710,7 +1710,7 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr& 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.");