wsd: http: support sending http::Response directly to the socket
The Socket now accepts http::Response and serializes it before sending it. Change-Id: Id36e2d91b21d168da72ccdbd7e509ec08021b78e Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
parent
0c48809593
commit
88dbe155e4
2 changed files with 15 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
|||
#include <net/SslSocket.hpp>
|
||||
#endif
|
||||
#include "WebSocketHandler.hpp"
|
||||
#include <net/HttpRequest.hpp>
|
||||
|
||||
// Bug in pre C++17 where static constexpr must be defined. Fixed in C++17.
|
||||
constexpr std::chrono::microseconds SocketPoll::DefaultPollTimeoutMicroS;
|
||||
|
@ -596,6 +597,12 @@ void StreamSocket::send(Poco::Net::HTTPResponse& response)
|
|||
send(oss.str());
|
||||
}
|
||||
|
||||
void StreamSocket::send(const http::Response& response)
|
||||
{
|
||||
response.writeData(_outBuffer);
|
||||
flush();
|
||||
}
|
||||
|
||||
void SocketPoll::dumpState(std::ostream& os)
|
||||
{
|
||||
// FIXME: NOT thread-safe! _pollSockets is modified from the polling thread!
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
|
||||
#define LOG_SOCKET_DATA
|
||||
|
||||
namespace http
|
||||
{
|
||||
class Response;
|
||||
}
|
||||
namespace Poco
|
||||
{
|
||||
class MemoryInputStream;
|
||||
|
@ -946,6 +950,10 @@ public:
|
|||
/// Adds Date and User-Agent.
|
||||
void send(Poco::Net::HTTPResponse& response);
|
||||
|
||||
/// Send an http::Response and flush.
|
||||
/// Does not add any fields to the header.
|
||||
void send(const http::Response& response);
|
||||
|
||||
/// Safely flush any outgoing data.
|
||||
inline void flush()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue