replace Poco in StreamSocket::send

Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Change-Id: I987cc515e27fbaf4e778a5ac6f005a43ff88be71
pull/8408/head
Noel Grandin 2023-10-26 09:20:29 +02:00 committed by Michael Meeks
parent dc72922f1e
commit 8a8e55c16e
5 changed files with 9 additions and 15 deletions

View File

@ -752,15 +752,12 @@ void StreamSocket::dumpState(std::ostream& os)
_outBuffer.dumpHex(os, "\t\toutBuffer:\n", "\t\t");
}
void StreamSocket::send(Poco::Net::HTTPResponse& response)
void StreamSocket::sendWithDateAndAgent(http::Response& response)
{
response.set("Server", http::getServerString());
response.set("Date", Util::getHttpTimeNow());
std::ostringstream oss;
response.write(oss);
send(oss.str());
send(response);
}
bool StreamSocket::send(const http::Response& response)

View File

@ -1029,7 +1029,7 @@ public:
/// Sends HTTP response.
/// Adds Date and User-Agent.
void send(Poco::Net::HTTPResponse& response);
void sendWithDateAndAgent(http::Response& response);
/// Send an http::Request and flush.
/// Does not add any fields to the header.

View File

@ -145,11 +145,10 @@ private:
}
else
{
Poco::Net::HTTPResponse response;
response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
http::Response response(http::StatusCode::BadRequest);
response.setContentLength(0);
LOG_INF("DumpWebSockets bad request");
socket->send(response);
socket->sendWithDateAndAgent(response);
disposition.setClosed();
}
}

View File

@ -491,11 +491,10 @@ bool AdminSocketHandler::handleInitialRequest(
return true;
}
HTTPResponse response;
response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
http::Response response(http::StatusCode::BadRequest);
response.setContentLength(0);
LOG_INF_S("Admin::handleInitialRequest bad request");
socket->send(response);
socket->sendWithDateAndAgent(response);
return false;
}

View File

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